Sha256: 58d92dd0e25f89abf4241960b0a11da3ec2ab634046f51a9a99b2efd7707b3e6

Contents?: true

Size: 1.64 KB

Versions: 31

Compression:

Stored size: 1.64 KB

Contents

# frozen_string_literal: true

module Decidim
  module Votings
    module ContentBlocks
      module LandingPage
        class PollingStationsCell < Decidim::ViewModel
          include Decidim::MapHelper
          include Decidim::SanitizeHelper
          include Decidim::LayoutHelper
          include Decidim::IconHelper
          include Decidim::NeedsSnippets

          delegate :current_participatory_space,
                   :snippets,
                   to: :controller

          def show
            return if current_participatory_space.online_voting?

            render
          end

          private

          def geolocation_enabled?
            Decidim::Map.available?(:geocoding)
          end

          def polling_stations
            @polling_stations ||= current_participatory_space.polling_stations
          end

          def polling_stations_geocoded
            @polling_stations_geocoded ||= polling_stations.geocoded
          end

          def polling_stations_geocoded_data_for_map
            polling_stations_geocoded.map do |polling_station|
              polling_station_data_for_map(polling_station)
            end
          end

          def polling_station_data_for_map(polling_station)
            polling_station.slice(:latitude, :longitude, :address)
                           .merge(
                             title: translated_attribute(polling_station.title),
                             location: translated_attribute(polling_station.location),
                             locationHints: translated_attribute(polling_station.location_hints)
                           )
          end
        end
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
decidim-elections-0.27.9 app/cells/decidim/votings/content_blocks/landing_page/polling_stations_cell.rb
decidim-elections-0.27.8 app/cells/decidim/votings/content_blocks/landing_page/polling_stations_cell.rb
decidim-elections-0.27.7 app/cells/decidim/votings/content_blocks/landing_page/polling_stations_cell.rb
decidim-elections-0.27.6 app/cells/decidim/votings/content_blocks/landing_page/polling_stations_cell.rb
decidim-elections-0.26.10 app/cells/decidim/votings/content_blocks/landing_page/polling_stations_cell.rb
decidim-elections-0.26.9 app/cells/decidim/votings/content_blocks/landing_page/polling_stations_cell.rb
decidim-elections-0.27.5 app/cells/decidim/votings/content_blocks/landing_page/polling_stations_cell.rb
decidim-elections-0.26.8 app/cells/decidim/votings/content_blocks/landing_page/polling_stations_cell.rb
decidim-elections-0.27.4 app/cells/decidim/votings/content_blocks/landing_page/polling_stations_cell.rb
decidim-elections-0.27.3 app/cells/decidim/votings/content_blocks/landing_page/polling_stations_cell.rb
decidim-elections-0.26.7 app/cells/decidim/votings/content_blocks/landing_page/polling_stations_cell.rb
decidim-elections-0.26.5 app/cells/decidim/votings/content_blocks/landing_page/polling_stations_cell.rb
decidim-elections-0.27.2 app/cells/decidim/votings/content_blocks/landing_page/polling_stations_cell.rb
decidim-elections-0.27.1 app/cells/decidim/votings/content_blocks/landing_page/polling_stations_cell.rb
decidim-elections-0.26.4 app/cells/decidim/votings/content_blocks/landing_page/polling_stations_cell.rb
decidim-elections-0.27.0 app/cells/decidim/votings/content_blocks/landing_page/polling_stations_cell.rb
decidim-elections-0.26.3 app/cells/decidim/votings/content_blocks/landing_page/polling_stations_cell.rb
decidim-elections-0.27.0.rc2 app/cells/decidim/votings/content_blocks/landing_page/polling_stations_cell.rb
decidim-elections-0.27.0.rc1 app/cells/decidim/votings/content_blocks/landing_page/polling_stations_cell.rb
decidim-elections-0.26.2 app/cells/decidim/votings/content_blocks/landing_page/polling_stations_cell.rb