Module: GeographicItemsHelper

Defined in:
app/helpers/geographic_items_helper.rb

Instance Method Summary collapse

Instance Method Details

#center_coord_tag(geographic_item) ⇒ Object



13
14
15
# File 'app/helpers/geographic_items_helper.rb', line 13

def center_coord_tag(geographic_item)
  geographic_item.center_coords.join(', ')
end


41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'app/helpers/geographic_items_helper.rb', line 41

def children_through_geographic_areas_links(geographic_item)
  data = {}
  geographic_item.geographic_areas.each do |a| 
    a.children.collect{ |c|
      data[c] = c.geographic_items.all
    }
  end 

  links = []
  data.each do |k,v|
    next if v.nil?
    links += v.collect{ |i| geographic_item_link(i, k.name) }
  end 
  links.join(', ').html_safe
end


17
18
19
20
21
# File 'app/helpers/geographic_items_helper.rb', line 17

def geographic_item_link(geographic_item, link_text = nil)
  return nil if geographic_item.nil?
  link_text ||= geographic_item.to_param
  link_to(link_text, geographic_item_path(geographic_item), data: {turbolinks: false})
end


23
24
25
26
# File 'app/helpers/geographic_items_helper.rb', line 23

def geographic_item_links(geographic_items)
  return (:em, 'none') if geographic_items.count == 0
  geographic_items.collect { |a| geographic_item_link(a) }.join(', ').html_safe
end


28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/helpers/geographic_items_helper.rb', line 28

def geographic_item_parent_nav_links(geographic_item)
  data = {} 
  geographic_item.parent_geographic_areas.each do |a|
    data[a] = a.geographic_items
  end 

  (:div,
              data.collect { |k, v| [
                (:ul, v.collect { |b|
                  (:li, geographic_item_link(b, k.name)) }.join.html_safe)
              ] }.flatten.join.html_safe)
end

#geographic_item_tag(geographic_item) ⇒ Object



3
4
5
6
# File 'app/helpers/geographic_items_helper.rb', line 3

def geographic_item_tag(geographic_item)
  return nil if geographic_item.nil?
  geographic_item.to_param 
end

#json_tag(geographic_item) ⇒ Object



8
9
10
11
# File 'app/helpers/geographic_items_helper.rb', line 8

def json_tag(geographic_item)
  retval = geographic_item.to_geo_json_feature.to_json
  retval
end