Sha256: 4c623671fa86103266aa8e643cadda984d4eb92b5e6476629578a9fd3618205b

Contents?: true

Size: 1.54 KB

Versions: 5

Compression:

Stored size: 1.54 KB

Contents

# frozen_string_literal: true

module Decidim
  module ParticipatoryProcessGroups
    module ContentBlocks
      class HighlightedParticipatoryProcessesCell < Decidim::ViewModel
        include Decidim::CardHelper
        include Decidim::IconHelper
        include ActionView::Helpers::FormOptionsHelper
        include Decidim::FiltersHelper
        include Decidim::FilterResource

        def participatory_process_group
          @participatory_process_group ||= Decidim::ParticipatoryProcessGroup.find(model.scoped_resource_id)
        end

        def decidim_participatory_processes
          Decidim::ParticipatoryProcesses::Engine.routes.url_helpers
        end

        def block_id
          "processes-grid"
        end

        def filtered_relation
          @filtered_relation ||= search.result
        end

        def default_date_filter
          return "active" if filtered_relation.any?(&:active?)
          return "upcoming" if filtered_relation.any?(&:upcoming?)
          return "past" if filtered_relation.any?(&:past?)

          "all"
        end

        private

        def search_collection
          base_relation
        end

        def default_filter_params
          {
            with_any_scope: nil,
            with_area: nil,
            with_type: nil
          }
        end

        def base_relation
          @base_relation ||= Decidim::ParticipatoryProcesses::GroupPublishedParticipatoryProcesses.new(
            participatory_process_group,
            current_user
          ).query
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
decidim-participatory_processes-0.27.9 app/cells/decidim/participatory_process_groups/content_blocks/highlighted_participatory_processes_cell.rb
decidim-participatory_processes-0.27.8 app/cells/decidim/participatory_process_groups/content_blocks/highlighted_participatory_processes_cell.rb
decidim-participatory_processes-0.27.7 app/cells/decidim/participatory_process_groups/content_blocks/highlighted_participatory_processes_cell.rb
decidim-participatory_processes-0.27.6 app/cells/decidim/participatory_process_groups/content_blocks/highlighted_participatory_processes_cell.rb
decidim-participatory_processes-0.27.5 app/cells/decidim/participatory_process_groups/content_blocks/highlighted_participatory_processes_cell.rb