aboutsummaryrefslogtreecommitdiff
path: root/app/helpers/application_helper.rb
blob: aa3a8d76f801842f2188d73337d54fdebeac36b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
module ApplicationHelper
  def current_agency
    current_user.agencies.where(agent: current_agent).first
  end
  %w(observer editor maintainer leader).each do |role|
    define_method :"current_user_#{role}?" do
      current_agency.send(:"#{role}?")
    end
  end

  def map_container(map = Map.first)
    raw tag.div(
          tag.div(id: 'map',
                  data: {
                    target: 'map.container'
                  }),
          data: {
            controller: 'map',
            'map-latitude': map.latitude,
            'map-longitude': map.longitude,
            'map-zoom': map.zoom
          })
  end
end