Sha256: 1e125b92813d1a2cdd2d7e4ad56de6ecd2c388d99d9504adc0912fec10adb28a

Contents?: true

Size: 1.59 KB

Versions: 15

Compression:

Stored size: 1.59 KB

Contents

# frozen_string_literal: true

module Decidim
  module ParticipatoryProcessGroups
    module ContentBlocks
      class TitleCell < Decidim::ViewModel
        include Decidim::SanitizeHelper
        include Decidim::IconHelper
        include Decidim::TwitterSearchHelper

        delegate :group_url, to: :participatory_process_group

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

        def hashtag_text
          @hashtag_text ||= decidim_html_escape(participatory_process_group.hashtag || "")
        end

        def has_hashtag?
          hashtag_text.present?
        end

        def has_group_url?
          group_url.present?
        end

        def meta_scope
          @meta_scope ||= translated_attribute(participatory_process_group.meta_scope)
        end

        def has_meta_scope?
          meta_scope.present?
        end

        def group_url_text
          group_uri.host + group_uri.path
        end

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

        def participatory_processes_count
          @participatory_processes_count ||= processes.count
        end

        private

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

        def group_uri
          @group_uri = URI.parse(group_url)
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
decidim-participatory_processes-0.27.9 app/cells/decidim/participatory_process_groups/content_blocks/title_cell.rb
decidim-participatory_processes-0.27.8 app/cells/decidim/participatory_process_groups/content_blocks/title_cell.rb
decidim-participatory_processes-0.27.7 app/cells/decidim/participatory_process_groups/content_blocks/title_cell.rb
decidim-participatory_processes-0.27.6 app/cells/decidim/participatory_process_groups/content_blocks/title_cell.rb
decidim-participatory_processes-0.26.10 app/cells/decidim/participatory_process_groups/content_blocks/title_cell.rb
decidim-participatory_processes-0.26.9 app/cells/decidim/participatory_process_groups/content_blocks/title_cell.rb
decidim-participatory_processes-0.27.5 app/cells/decidim/participatory_process_groups/content_blocks/title_cell.rb
decidim-participatory_processes-0.26.8 app/cells/decidim/participatory_process_groups/content_blocks/title_cell.rb
decidim-participatory_processes-0.27.4 app/cells/decidim/participatory_process_groups/content_blocks/title_cell.rb
decidim-participatory_processes-0.27.3 app/cells/decidim/participatory_process_groups/content_blocks/title_cell.rb
decidim-participatory_processes-0.26.7 app/cells/decidim/participatory_process_groups/content_blocks/title_cell.rb
decidim-participatory_processes-0.26.5 app/cells/decidim/participatory_process_groups/content_blocks/title_cell.rb
decidim-participatory_processes-0.27.2 app/cells/decidim/participatory_process_groups/content_blocks/title_cell.rb
decidim-participatory_processes-0.27.1 app/cells/decidim/participatory_process_groups/content_blocks/title_cell.rb
decidim-participatory_processes-0.26.4 app/cells/decidim/participatory_process_groups/content_blocks/title_cell.rb