Sha256: 9a85ceba5367b4a2b5dd39130707999254b79552b31c0b6ddd2b1dafd437344d

Contents?: true

Size: 1.17 KB

Versions: 13

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

module Decidim
  module ParticipatoryProcessGroups
    module ContentBlocks
      class RelatedProcessesCell < Decidim::ParticipatoryProcesses::ContentBlocks::RelatedProcessesCell
        def related_processes
          @related_processes ||=
            Decidim::ParticipatoryProcesses::GroupPublishedParticipatoryProcesses.new(
              resource,
              current_user
            ).query
        end

        def filtered_processes
          return related_processes unless filter_active?

          related_processes.active
        end

        def total_count
          filtered_processes.size
        end

        private

        def filter_active?
          default_filter == "active"
        end

        def default_filter
          return if model.blank?

          model.settings.try(:default_filter)
        end

        def title
          if filter_active?
            t("active", scope: "decidim.participatory_process_groups.content_blocks.participatory_processes")
          else
            t("name", scope: "decidim.participatory_process_groups.content_blocks.participatory_processes")
          end
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
decidim-participatory_processes-0.29.1 app/cells/decidim/participatory_process_groups/content_blocks/related_processes_cell.rb
decidim-participatory_processes-0.28.4 app/cells/decidim/participatory_process_groups/content_blocks/related_processes_cell.rb
decidim-participatory_processes-0.29.0 app/cells/decidim/participatory_process_groups/content_blocks/related_processes_cell.rb
decidim-participatory_processes-0.28.3 app/cells/decidim/participatory_process_groups/content_blocks/related_processes_cell.rb
decidim-participatory_processes-0.29.0.rc4 app/cells/decidim/participatory_process_groups/content_blocks/related_processes_cell.rb
decidim-participatory_processes-0.29.0.rc3 app/cells/decidim/participatory_process_groups/content_blocks/related_processes_cell.rb
decidim-participatory_processes-0.29.0.rc2 app/cells/decidim/participatory_process_groups/content_blocks/related_processes_cell.rb
decidim-participatory_processes-0.29.0.rc1 app/cells/decidim/participatory_process_groups/content_blocks/related_processes_cell.rb
decidim-participatory_processes-0.28.2 app/cells/decidim/participatory_process_groups/content_blocks/related_processes_cell.rb
decidim-participatory_processes-0.28.1 app/cells/decidim/participatory_process_groups/content_blocks/related_processes_cell.rb
decidim-participatory_processes-0.28.0 app/cells/decidim/participatory_process_groups/content_blocks/related_processes_cell.rb
decidim-participatory_processes-0.28.0.rc5 app/cells/decidim/participatory_process_groups/content_blocks/related_processes_cell.rb
decidim-participatory_processes-0.28.0.rc4 app/cells/decidim/participatory_process_groups/content_blocks/related_processes_cell.rb