Module: CollectingEventsHelper
- Defined in:
- app/helpers/collecting_events_helper.rb
Instance Method Summary collapse
- #collecting_event_autocomplete_tag(collecting_event, join_string = '<br>') ⇒ Object
-
#collecting_event_browse_next_by_identifier(collecting_event) ⇒ link_to
This may not work for all identifier types, i.e.
-
#collecting_event_browse_previous_by_identifier(collecting_event) ⇒ link_to
This may not work for all identifier types, i.e.
- #collecting_event_collectors_tag(collecting_event) ⇒ Object
- #collecting_event_coordinates_tag(collecting_event) ⇒ Object
- #collecting_event_dates_tag(collecting_event) ⇒ Object
- #collecting_event_geographic_names_tag(collecting_event) ⇒ Object
- #collecting_event_identifiers_tag(collecting_event) ⇒ Object
-
#collecting_event_label_tag(label_text) ⇒ HTML
A pre tag formatting a label.
- #collecting_event_link(collecting_event) ⇒ Object
- #collecting_event_method_habitat_tag(collecting_event) ⇒ Object
-
#collecting_event_namespace_select_tag ⇒ String
Short string of use in autocomplete selects.
- #collecting_event_next_by_start_date(collecting_event) ⇒ Object
- #collecting_event_tag(collecting_event) ⇒ Object
- #collecting_event_uses_tag(collecting_event) ⇒ Object
- #collecting_event_verbatim_locality_tag(collecting_event) ⇒ Object
- #collecting_events_search_form ⇒ Object
-
#date_range_tag(collecting_event) ⇒ String?
Summary of date data.
-
#elevation_tag(collecting_event) ⇒ String?
Summary of elevation data.
- #next_without_georeference_for_google_maps_link(collecting_event) ⇒ Object
-
#verbatim_gis_tag(collecting_event) ⇒ String?
Summary of verbatim gis related data.
Instance Method Details
#collecting_event_autocomplete_tag(collecting_event, join_string = '<br>') ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/helpers/collecting_events_helper.rb', line 15 def collecting_event_autocomplete_tag(collecting_event, join_string = '<br>') return nil if collecting_event.nil? [ collecting_event_identifiers_tag(collecting_event), collecting_event_geographic_names_tag(collecting_event), collecting_event_verbatim_locality_tag(collecting_event), collecting_event_dates_tag(collecting_event), collecting_event_collectors_tag(collecting_event), collecting_event_coordinates_tag(collecting_event), collecting_event_method_habitat_tag(collecting_event), collecting_event_uses_tag(collecting_event) ].compact.join(join_string).html_safe end |
#collecting_event_browse_next_by_identifier(collecting_event) ⇒ link_to
Returns this may not work for all identifier types, i.e. those with identifiers like `123.34` or `3434.33X` may not increment correctly.
176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'app/helpers/collecting_events_helper.rb', line 176 def collecting_event_browse_next_by_identifier(collecting_event) return nil if collecting_event.nil? o = collecting_event.next_by_identifier return content_tag(:div, 'None', 'class' => 'navigation-item disable') if o.nil? link_text = content_tag(:span, 'Next by id', 'class' => 'small-icon icon-right', 'data-icon' => 'arrow-right') link_to( link_text, browse_collecting_events_task_path(collecting_event_id: o.id), data: { arrow: :next, 'no-turbolinks' => 'false', help: 'Sorts by identifier type, namespace, then an conversion of identifier into integer. Will not work for all identifier types.'}, class:'navigation-item') end |
#collecting_event_browse_previous_by_identifier(collecting_event) ⇒ link_to
Returns this may not work for all identifier types, i.e. those with identifiers like `123.34` or `3434.33X` may not increment correctly.
160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'app/helpers/collecting_events_helper.rb', line 160 def collecting_event_browse_previous_by_identifier(collecting_event) return nil if collecting_event.nil? o = collecting_event.previous_by_identifier return content_tag(:div, 'None', 'class' => 'navigation-item disable') if o.nil? link_text = content_tag(:span, 'Previous by id', 'class' => 'small-icon icon-left', 'data-icon' => 'arrow-left') link_to( link_text, browse_collecting_events_task_path(collecting_event_id: o.id), data: { arrow: :previous, 'no-turbolinks' => 'true', help: 'Sorts by identifier type, namespace, then an conversion of identifier into integer. Will not work for all identifier types.'}, class: 'navigation-item') end |
#collecting_event_collectors_tag(collecting_event) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 |
# File 'app/helpers/collecting_events_helper.rb', line 65 def collecting_event_collectors_tag(collecting_event) return nil if collecting_event.nil? || (collecting_event.verbatim_collectors.blank? && !collecting_event.collectors.load.any?) a = '' a << content_tag( :span, Utilities::Strings.(collecting_event.collectors.collect{|a| a.cached}) ) if collecting_event.collectors.any? a << ' '.html_safe + content_tag(:span, collecting_event.verbatim_collectors, class: [:feedback, 'feedback-thin','feedback-secondary']) if collecting_event.verbatim_collectors a end |
#collecting_event_coordinates_tag(collecting_event) ⇒ Object
77 78 79 80 81 |
# File 'app/helpers/collecting_events_helper.rb', line 77 def collecting_event_coordinates_tag(collecting_event) return nil if collecting_event.nil? || collecting_event.map_center_method.nil? c = collecting_event.map_center content_tag(:span, [c.x.round(4), c.y.round(4)].join(' — ').html_safe) end |
#collecting_event_dates_tag(collecting_event) ⇒ Object
83 84 85 86 87 88 89 90 91 92 |
# File 'app/helpers/collecting_events_helper.rb', line 83 def collecting_event_dates_tag(collecting_event) return nil if collecting_event.nil? || !collecting_event.has_some_date? s = collecting_event.date_range.join(' — ').html_safe a = '' a = content_tag(:span, s) if !s.blank? a << ' '.html_safe + content_tag(:span, collecting_event.verbatim_date, class: [ :feedback, 'feedback-thin', 'feedback-secondary' ]) if collecting_event.verbatim_date a.html_safe end |
#collecting_event_geographic_names_tag(collecting_event) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/helpers/collecting_events_helper.rb', line 48 def collecting_event_geographic_names_tag(collecting_event) return nil if collecting_event.nil? a = [collecting_event.cached_level0_geographic_name, collecting_event.cached_level1_geographic_name, collecting_event.cached_level2_geographic_name ].compact return nil if a.empty? content_tag(:span, a.join(': ')) end |
#collecting_event_identifiers_tag(collecting_event) ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'app/helpers/collecting_events_helper.rb', line 37 def collecting_event_identifiers_tag(collecting_event) return nil if collecting_event.nil? if i = collecting_event.identifiers.load.first collecting_event.identifiers.collect{|j| content_tag(:span, j.cached, class: [ :feedback, 'feedback-thin', 'feedback-secondary' ]) }.join else nil end end |
#collecting_event_label_tag(label_text) ⇒ HTML
Returns a pre tag formatting a label.
151 152 153 |
# File 'app/helpers/collecting_events_helper.rb', line 151 def collecting_event_label_tag(label_text) content_tag(:pre, label_text, class: [:large_type, :word_break] ) # large_type needs to be larger end |
#collecting_event_link(collecting_event) ⇒ Object
99 100 101 102 |
# File 'app/helpers/collecting_events_helper.rb', line 99 def collecting_event_link(collecting_event) return nil if collecting_event.nil? link_to(collecting_event_tag(collecting_event).html_safe, collecting_event) end |
#collecting_event_method_habitat_tag(collecting_event) ⇒ Object
60 61 62 63 |
# File 'app/helpers/collecting_events_helper.rb', line 60 def collecting_event_method_habitat_tag(collecting_event) return nil if collecting_event.nil? || (collecting_event.verbatim_method.blank? && collecting_event.verbatim_habitat.blank?) content_tag(:span, [collecting_event.verbatim_method, collecting_event.verbatim_habitat].compact.join('; ')) end |
#collecting_event_namespace_select_tag ⇒ String
Returns short string of use in autocomplete selects.
118 119 120 |
# File 'app/helpers/collecting_events_helper.rb', line 118 def collecting_event_namespace_select_tag select_tag(:ce_namespace, (Namespace.pluck(:short_name).uniq), prompt: 'Select a namespace') end |
#collecting_event_next_by_start_date(collecting_event) ⇒ Object
190 191 |
# File 'app/helpers/collecting_events_helper.rb', line 190 def collecting_event_next_by_start_date(collecting_event) end |
#collecting_event_tag(collecting_event) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 |
# File 'app/helpers/collecting_events_helper.rb', line 3 def collecting_event_tag(collecting_event) return nil if collecting_event.nil? if a = [ collecting_event.verbatim_label, collecting_event.print_label, collecting_event.document_label ].compact.first [ collecting_event_identifiers_tag(collecting_event), a].compact.join(' ').html_safe else collecting_event_autocomplete_tag(collecting_event, '; ').html_safe end end |
#collecting_event_uses_tag(collecting_event) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'app/helpers/collecting_events_helper.rb', line 28 def collecting_event_uses_tag(collecting_event) return nil if collecting_event.nil? if collecting_event.collection_objects.any? content_tag(:span, 'Uses: ' + collecting_event.collection_objects.count.to_s, class: [ :feedback, 'feedback-thin', 'feedback-secondary' ]) else nil end end |
#collecting_event_verbatim_locality_tag(collecting_event) ⇒ Object
94 95 96 97 |
# File 'app/helpers/collecting_events_helper.rb', line 94 def collecting_event_verbatim_locality_tag(collecting_event) return nil unless !(collecting_event&.verbatim_locality&.blank?) content_tag(:span, collecting_event.verbatim_locality) end |
#collecting_events_search_form ⇒ Object
104 105 106 |
# File 'app/helpers/collecting_events_helper.rb', line 104 def collecting_events_search_form render('/collecting_events/quick_search_form') end |
#date_range_tag(collecting_event) ⇒ String?
Returns summary of date data.
134 135 136 137 |
# File 'app/helpers/collecting_events_helper.rb', line 134 def date_range_tag(collecting_event) return if collecting_event.nil? [collecting_event.start_date_string, collecting_event.end_date_string].compact.join(' - ') end |
#elevation_tag(collecting_event) ⇒ String?
Returns summary of elevation data.
124 125 126 127 128 129 130 |
# File 'app/helpers/collecting_events_helper.rb', line 124 def elevation_tag(collecting_event) return nil if collecting_event.nil? [ Utilities::Strings.nil_wrap(nil, [collecting_event.minimum_elevation, collecting_event.maximum_elevation].compact.join('-'), 'm'), Utilities::Strings.nil_wrap(' +/-', collecting_event.elevation_precision, nil) ].compact.join.html_safe end |
#next_without_georeference_for_google_maps_link(collecting_event) ⇒ Object
108 109 110 111 112 113 114 |
# File 'app/helpers/collecting_events_helper.rb', line 108 def next_without_georeference_for_google_maps_link(collecting_event) if n = collecting_event.next_without_georeference link_to('Skip to next CE without georeference', new_georeferences_google_map_path(georeference: {collecting_event_id: n.to_param}), id: :next_without_georeference) else nil end end |
#verbatim_gis_tag(collecting_event) ⇒ String?
Returns summary of verbatim gis related data.
141 142 143 144 145 146 147 148 |
# File 'app/helpers/collecting_events_helper.rb', line 141 def verbatim_gis_tag(collecting_event) return if collecting_event.nil? [collecting_event.verbatim_latitude, collecting_event.verbatim_longitude, Utilities::Strings.nil_wrap(' (+/-', collecting_event.verbatim_geolocation_uncertainty, ')'), Utilities::Strings.nil_wrap(' [via ', collecting_event.verbatim_datum, ']'), ].compact.join(', ') end |