Sha256: cf34d72ba822cc0174e3054039ca83ad2184dbb4688dcea6443b267dfd4d7c24

Contents?: true

Size: 1.84 KB

Versions: 35

Compression:

Stored size: 1.84 KB

Contents

# frozen_string_literal: true

module Decidim
  module Proposals
    # Custom helpers, scoped to the proposals engine.
    #
    module ProposalCellsHelper
      include Decidim::Proposals::ApplicationHelper
      include Decidim::Proposals::Engine.routes.url_helpers
      include Decidim::LayoutHelper
      include Decidim::ApplicationHelper
      include Decidim::TranslationsHelper
      include Decidim::ResourceReferenceHelper
      include Decidim::TranslatableAttributes
      include Decidim::CardHelper

      delegate :title, :state, :published_state?, :withdrawn?, :amendable?, :emendation?, to: :model

      def has_actions?
        return context[:has_actions] if context[:has_actions].present?

        proposals_controller? && index_action? && current_settings.votes_enabled? && !model.draft?
      end

      def has_footer?
        return context[:has_footer] if context[:has_footer].present?

        proposals_controller? && index_action? && current_settings.votes_enabled? && !model.draft?
      end

      def proposals_controller?
        context[:controller].class.to_s == "Decidim::Proposals::ProposalsController"
      end

      def index_action?
        context[:controller].action_name == "index"
      end

      def current_settings
        model.component.current_settings
      end

      def component_settings
        model.component.settings
      end

      def current_component
        model.component
      end

      def from_context
        @options[:from]
      end

      def badge_name
        humanize_proposal_state state
      end

      def state_classes
        case state
        when "accepted"
          ["success"]
        when "rejected"
          ["alert"]
        when "evaluating"
          ["warning"]
        when "withdrawn"
          ["alert"]
        else
          ["muted"]
        end
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
decidim-proposals-0.26.10 app/helpers/decidim/proposals/proposal_cells_helper.rb
decidim-proposals-0.26.9 app/helpers/decidim/proposals/proposal_cells_helper.rb
decidim-proposals-0.26.8 app/helpers/decidim/proposals/proposal_cells_helper.rb
decidim-proposals-0.26.7 app/helpers/decidim/proposals/proposal_cells_helper.rb
decidim-proposals-0.26.5 app/helpers/decidim/proposals/proposal_cells_helper.rb
decidim-proposals-0.26.4 app/helpers/decidim/proposals/proposal_cells_helper.rb
decidim-proposals-0.26.3 app/helpers/decidim/proposals/proposal_cells_helper.rb
decidim-proposals-0.26.2 app/helpers/decidim/proposals/proposal_cells_helper.rb
decidim-proposals-0.26.1 app/helpers/decidim/proposals/proposal_cells_helper.rb
decidim-proposals-0.26.0 app/helpers/decidim/proposals/proposal_cells_helper.rb
decidim-proposals-0.26.0.rc2 app/helpers/decidim/proposals/proposal_cells_helper.rb
decidim-proposals-0.26.0.rc1 app/helpers/decidim/proposals/proposal_cells_helper.rb
decidim-proposals-0.25.2 app/helpers/decidim/proposals/proposal_cells_helper.rb
decidim-proposals-0.25.1 app/helpers/decidim/proposals/proposal_cells_helper.rb
decidim-proposals-0.25.0 app/helpers/decidim/proposals/proposal_cells_helper.rb
decidim-proposals-0.25.0.rc4 app/helpers/decidim/proposals/proposal_cells_helper.rb
decidim-proposals-0.25.0.rc3 app/helpers/decidim/proposals/proposal_cells_helper.rb
decidim-proposals-0.25.0.rc2 app/helpers/decidim/proposals/proposal_cells_helper.rb
decidim-proposals-0.25.0.rc1 app/helpers/decidim/proposals/proposal_cells_helper.rb
decidim-proposals-0.24.3 app/helpers/decidim/proposals/proposal_cells_helper.rb