Sha256: eabc031403a8a5f9044d4688b242ae21fd696e14bb3b47c045408074ee0cba2d

Contents?: true

Size: 1.18 KB

Versions: 9

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

module Decidim
  module ParticipatoryProcesses
    module ContentBlocks
      class HighlightedProcessesCell < Decidim::ViewModel
        include Decidim::SanitizeHelper

        delegate :current_user, to: :controller

        def show
          if single_process?
            render "single_process"
          elsif highlighted_processes.any?
            render
          end
        end

        def single_process?
          highlighted_processes.to_a.length == 1
        end

        def max_results
          model.settings.max_results
        end

        def highlighted_processes
          @highlighted_processes ||= (
            OrganizationPublishedParticipatoryProcesses.new(current_organization, current_user) |
            HighlightedParticipatoryProcesses.new |
            FilteredParticipatoryProcesses.new("active")
          ).query.includes([:organization]).limit(max_results)
        end

        def i18n_scope
          "decidim.participatory_processes.pages.home.highlighted_processes"
        end

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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
decidim-participatory_processes-0.23.6 app/cells/decidim/participatory_processes/content_blocks/highlighted_processes_cell.rb
decidim-participatory_processes-0.23.5 app/cells/decidim/participatory_processes/content_blocks/highlighted_processes_cell.rb
decidim-participatory_processes-0.23.4 app/cells/decidim/participatory_processes/content_blocks/highlighted_processes_cell.rb
decidim-participatory_processes-0.23.3 app/cells/decidim/participatory_processes/content_blocks/highlighted_processes_cell.rb
decidim-participatory_processes-0.23.2 app/cells/decidim/participatory_processes/content_blocks/highlighted_processes_cell.rb
decidim-participatory_processes-0.23.1 app/cells/decidim/participatory_processes/content_blocks/highlighted_processes_cell.rb
decidim-participatory_processes-0.23.1.rc1 app/cells/decidim/participatory_processes/content_blocks/highlighted_processes_cell.rb
decidim-participatory_processes-0.23.0 app/cells/decidim/participatory_processes/content_blocks/highlighted_processes_cell.rb
decidim-participatory_processes-0.22.0 app/cells/decidim/participatory_processes/content_blocks/highlighted_processes_cell.rb