Module: GeographicItemsHelper

Defined in:
app/helpers/geographic_items_helper.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) center_coord_tag(geographic_item)



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

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


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

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


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

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: {no_turbolink: true})
end


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

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


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

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

- (Object) geographic_item_tag(geographic_item)



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

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

- (Object) json_tag(geographic_item)



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

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