Sha256: 2081f107a2f74b256dab8d697cedb911b6f9b4632ea0377c1eb3001aac3bf9a4

Contents?: true

Size: 1.73 KB

Versions: 5

Compression:

Stored size: 1.73 KB

Contents

# frozen_string_literal: true

module Decidim
  module Meetings
    # This helper include some methods for rendering meetings dynamic maps.
    module MapHelper
      include Decidim::SanitizeHelper
      # Serialize a collection of geocoded meetings to be used by the dynamic map component
      #
      # meetings - A collection of meetings
      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: html_truncate(translated_attribute(meeting.description), length: 200),
                                                               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: decidim_html_escape(translated_attribute(meeting.location_hints)),
                                                               link: resource_locator(meeting).path)
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
decidim-meetings-0.24.2 app/helpers/decidim/meetings/map_helper.rb
decidim-meetings-0.24.1 app/helpers/decidim/meetings/map_helper.rb
decidim-meetings-0.24.0 app/helpers/decidim/meetings/map_helper.rb
decidim-meetings-0.24.0.rc2 app/helpers/decidim/meetings/map_helper.rb
decidim-meetings-0.24.0.rc1 app/helpers/decidim/meetings/map_helper.rb