Module: PeopleHelper
- Defined in:
- app/helpers/people_helper.rb
Instance Method Summary collapse
- #author_annotation_tag(author) ⇒ Object
- #author_list_tag(object) ⇒ Object
- #editor_list_tag(object) ⇒ Object
- #label_for_person(person) ⇒ Object
-
#people_names(people) ⇒ String?
A formatted list of people's last names TODO: deprecate for native call.
- #people_search_form ⇒ Object
- #person_active_tag(person) ⇒ Object
- #person_autocomplete_tag(person, term = nil, use_count: nil, role_types: [], in_project: false) ⇒ Object
- #person_link(person) ⇒ Object
- #person_lived_tag(person) ⇒ Object
- #person_project_membership_tag(in_project: false) ⇒ Object
- #person_tag(person) ⇒ Object
- #person_timeframe_tag(person) ⇒ Object
- #person_used_tag(use_count: nil, role_types: []) ⇒ Object
Instance Method Details
#author_annotation_tag(author) ⇒ Object
113 114 115 116 |
# File 'app/helpers/people_helper.rb', line 113 def () return nil if .nil? content_tag(:span, .name, class: [:annotation__author]) end |
#author_list_tag(object) ⇒ Object
118 119 120 121 122 123 124 |
# File 'app/helpers/people_helper.rb', line 118 def (object) return nil unless object..any? content_tag(:h3, 'Authors') + content_tag(:ul, class: 'annotations_author_list') do object..collect{|a| content_tag(:li, (a)) }.join.html_safe end end |
#editor_list_tag(object) ⇒ Object
126 127 128 129 130 131 132 |
# File 'app/helpers/people_helper.rb', line 126 def editor_list_tag(object) return nil unless object.editors.any? content_tag(:h3, 'Editors') + content_tag(:ul, class: 'annotations_editor_list') do object.editors.collect{|a| content_tag(:li, (a)) }.join.html_safe end end |
#label_for_person(person) ⇒ Object
12 13 14 15 |
# File 'app/helpers/people_helper.rb', line 12 def label_for_person(person) return nil if person.nil? person.cached end |
#people_names(people) ⇒ String?
Returns A formatted list of people's last names TODO: deprecate for native call.
109 110 111 |
# File 'app/helpers/people_helper.rb', line 109 def people_names(people) Utilities::Strings.( people.collect{ |a| a.full_last_name } ) end |
#people_search_form ⇒ Object
102 103 104 |
# File 'app/helpers/people_helper.rb', line 102 def people_search_form render('/people/quick_search_form') end |
#person_active_tag(person) ⇒ Object
64 65 66 67 68 69 70 71 |
# File 'app/helpers/people_helper.rb', line 64 def person_active_tag(person) return ('active: ' + content_tag(:i, 'unknown')).html_safe if person.year_active_start.nil? && person.year_active_end.nil? ae = person.year_active_end ae = nil if !ae.nil? && ae == person.year_active_start 'active ~ ' + [ person.year_active_start || '?', ae || '?'].join('-') end |
#person_autocomplete_tag(person, term = nil, use_count: nil, role_types: [], in_project: false) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/helpers/people_helper.rb', line 28 def person_autocomplete_tag( person, term = nil, use_count: nil, role_types: [], in_project: false ) return nil if person.nil? s = [ person_tag(person), person_timeframe_tag(person), person_used_tag(use_count:, role_types:), person_project_membership_tag(in_project:) ].compact.join(' ') mark_tag(s, term) end |
#person_link(person) ⇒ Object
17 18 19 20 |
# File 'app/helpers/people_helper.rb', line 17 def person_link(person) return nil if person.nil? link_to(person_tag(person), person.) end |
#person_lived_tag(person) ⇒ Object
51 52 53 |
# File 'app/helpers/people_helper.rb', line 51 def person_lived_tag(person) 'lived: ' + [person.year_born || '?', person.year_died || '?'].join('-') end |
#person_project_membership_tag(in_project: false) ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'app/helpers/people_helper.rb', line 55 def person_project_membership_tag(in_project: false) return nil unless in_project content_tag( :span, 'In Project'.html_safe, class: [:feedback, 'feedback-thin', 'feedback-success'] ) end |
#person_tag(person) ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'app/helpers/people_helper.rb', line 3 def person_tag(person) return nil if person.nil? if person.new_record? person.bibtex_name else person.cached ? person.cached : 'CACHED VALUE NOT BUILT, CONTACT AN ADMIN.' end end |
#person_timeframe_tag(person) ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'app/helpers/people_helper.rb', line 42 def person_timeframe_tag(person) content_tag( :span, class: [ :feedback, 'feedback-secondary', 'feedback-thin' ] ) do (person_lived_tag(person) + ' ' + person_active_tag(person)).html_safe end.html_safe end |
#person_used_tag(use_count: nil, role_types: []) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'app/helpers/people_helper.rb', line 73 def person_used_tag(use_count: nil, role_types: []) count = use_count || 0 if count == 0 return content_tag( :span, 'unused', class: [:feedback, 'feedback-thin', 'feedback-danger'] ) end types = role_types .map(&:safe_constantize).compact .collect(&:human_name).join(', ') content_tag( :span, "#{count} #{"use".pluralize(count)}", class: [:feedback, 'feedback-thin', 'feedback-primary'], data: {count:} ) + ' ' + content_tag( :span, types, class: [:feedback, 'feedback-thin', 'feedback-secondary'] ) end |