Sha256: 9034a55b7c60581fd9935518e84f34a3a90fd06741b4f22a02917f1aa5c213c1

Contents?: true

Size: 1.57 KB

Versions: 1

Compression:

Stored size: 1.57 KB

Contents

# frozen_string_literal: true

module Decidim
  module DecidimAwesome
    module ContentBlocks
      class MapCell < Decidim::ViewModel
        include Decidim::DecidimAwesome::MapHelper
        include Decidim::CardHelper

        delegate :snippets, to: :controller
        delegate :settings, to: :model
        alias current_settings settings

        def hide_controls
          true
        end

        def all_categories
          return if @all_categories.present?

          @category_ids ||= Decidim::Category.pluck(:id, :decidim_participatory_space_type, :decidim_participatory_space_id).select do |category|
            _id, space_type, space_id = category
            space = space_type.constantize.find(space_id)
            space.organization == current_organization
          end.map(&:first)

          @all_categories ||= Decidim::Category.where(id: @category_ids)
        end

        def global_map_components
          @global_map_components ||= Decidim::Component.where(manifest_name: [:meetings, :proposals]).published.filter do |component|
            case component.manifest.name
            when :meetings
              true
            when :proposals
              component.settings.geocoding_enabled
            else
              false
            end
          end
        end

        def section_title
          return if model.settings.title.blank?
          return if model.settings.title.values.join.blank?

          content_tag :h3, class: "section-heading" do
            translated_attribute(model.settings.title)
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
decidim-decidim_awesome-0.7.2 app/cells/decidim/decidim_awesome/content_blocks/map_cell.rb