Module: Tasks::Gis::LocalityHelper
- Defined in:
- app/helpers/tasks/gis/locality_helper.rb
Instance Method Summary collapse
- #anchor_shade(letter) ⇒ Object
- #ay_range ⇒ Object
- #az_range ⇒ Object
- #collecting_event_georeference_count(collecting_event) ⇒ Object
- #distance_between(collecting_event_1, collecting_event_2) ⇒ Object
- #distance_select_tag(digit, tag_string) ⇒ Object
- #is_checked(digit, value) ⇒ Object
- #locality_georeferences(collecting_events, geographic_area) ⇒ Object
- #missing_verbatim_locality_count(collecting_events) ⇒ Object
- #nearby_link(collecting_event) ⇒ Object
-
#select_locality(letter) ⇒ Object
localities within @geographic_item which have a verbatim_locality starting with letter.
- #select_locality_count(letter) ⇒ Object
- #within_count ⇒ Object
Instance Method Details
#anchor_shade(letter) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/helpers/tasks/gis/locality_helper.rb', line 11 def anchor_shade(letter) style = 'display:inline;' if select_locality_count(letter) == 0 style += 'color:lightgrey;' end #"<p> # <h3 style=\>#{letter}</h3> # <a href=\"#top\">top</a> #</p>" "<p><h3 style=\"#{style}\">#{letter}</h3> <a href=\"#top\">top</a></p>" # TODO: change to class # content_tag(:p) do # content_tag(:h3, letter, style: style ) do # link_to('top', '#top') # end # end end |
#ay_range ⇒ Object
3 4 5 |
# File 'app/helpers/tasks/gis/locality_helper.rb', line 3 def ay_range ('A'..'Y') end |
#az_range ⇒ Object
7 8 9 |
# File 'app/helpers/tasks/gis/locality_helper.rb', line 7 def az_range ay_range.to_a.push('Z') end |
#collecting_event_georeference_count(collecting_event) ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'app/helpers/tasks/gis/locality_helper.rb', line 59 def collecting_event_georeference_count(collecting_event) count = collecting_event.georeferences.count - 1 if count > 0 count.to_s else 'none' end end |
#distance_between(collecting_event_1, collecting_event_2) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'app/helpers/tasks/gis/locality_helper.rb', line 68 def distance_between(collecting_event_1, collecting_event_2) distance = collecting_event_1.distance_to(collecting_event_2.preferred_georeference.geographic_item_id).round # to the nearest meter case when distance >= 1000.0 metric = '%1.3fkm' distance /= 1000.0 else metric = '%im' end metric % distance end |
#distance_select_tag(digit, tag_string) ⇒ Object
86 87 88 89 90 91 |
# File 'app/helpers/tasks/gis/locality_helper.rb', line 86 def distance_select_tag(digit, tag_string) tag = tag_string.gsub(',', '') label_tag(digit, tag_string) (digit, tag.to_s) end |
#is_checked(digit, value) ⇒ Object
93 94 95 |
# File 'app/helpers/tasks/gis/locality_helper.rb', line 93 def is_checked(digit, value) (params[digit] == value) ? true : false end |
#locality_georeferences(collecting_events, geographic_area) ⇒ Object
44 45 46 47 48 49 50 51 52 53 |
# File 'app/helpers/tasks/gis/locality_helper.rb', line 44 def locality_georeferences(collecting_events, geographic_area) retval = [] unless collecting_events.nil? retval = collecting_events.map(&:georeferences).flatten end if retval.empty? retval.push(geographic_area) end retval end |
#missing_verbatim_locality_count(collecting_events) ⇒ Object
55 56 57 |
# File 'app/helpers/tasks/gis/locality_helper.rb', line 55 def missing_verbatim_locality_count(collecting_events) collecting_events.where(verbatim_locality: nil).count end |
#nearby_link(collecting_event) ⇒ Object
81 82 83 84 |
# File 'app/helpers/tasks/gis/locality_helper.rb', line 81 def nearby_link(collecting_event) return nil if collecting_event.nil? link_to('nearby', collecting_event) end |
#select_locality(letter) ⇒ Object
localities within @geographic_item which have a verbatim_locality starting with letter
37 38 39 40 41 42 |
# File 'app/helpers/tasks/gis/locality_helper.rb', line 37 def select_locality(letter) s = CollectingEvent.where(id: @collecting_events.ids) .where('verbatim_locality like ?', letter.to_s + '%') .order(:verbatim_locality) s end |
#select_locality_count(letter) ⇒ Object
32 33 34 |
# File 'app/helpers/tasks/gis/locality_helper.rb', line 32 def select_locality_count(letter) select_locality(letter).count end |
#within_count ⇒ Object
97 98 99 |
# File 'app/helpers/tasks/gis/locality_helper.rb', line 97 def within_count @collecting_events_count = CollectingEvent.contained_within(@geographic_item).count end |