Module: Decidim::Meetings::MapHelper

Included in:
ApplicationHelper, MeetingsMapCell
Defined in:
app/helpers/decidim/meetings/map_helper.rb

Overview

This helper include some methods for rendering meetings dynamic maps.

Instance Method Summary collapse

Instance Method Details

#meetings_data_for_map(meetings) ⇒ Object

Serialize a collection of geocoded meetings to be used by the dynamic map component

meetings - A collection of meetings



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/helpers/decidim/meetings/map_helper.rb', line 10

def meetings_data_for_map(meetings)
  geocoded_meetings = meetings.select(&:geocoded?)
  geocoded_meetings.map do |meeting|
    meeting.slice(:latitude, :longitude, :address).merge(title: translated_attribute(meeting.title),
                                                         description: translated_attribute(meeting.description),
                                                         startTimeDay: l(meeting.start_time, format: "%d"),
                                                         startTimeMonth: l(meeting.start_time, format: "%B"),
                                                         startTimeYear: l(meeting.start_time, format: "%Y"),
                                                         startTime: "#{meeting.start_time.strftime("%H:%M")} - #{meeting.end_time.strftime("%H:%M")}",
                                                         icon: icon("meetings", width: 40, height: 70, remove_icon_class: true),
                                                         location: translated_attribute(meeting.location),
                                                         locationHints: translated_attribute(meeting.location_hints),
                                                         link: resource_locator(meeting).path)
  end
end