Sha256: 5772372f6daef6cb9bce498d27eb4dda557c8623e6e9f46745e7336113c09757

Contents?: true

Size: 1.23 KB

Versions: 4

Compression:

Stored size: 1.23 KB

Contents

# frozen_string_literal: true
module Decidim
  module Proposals
    # Custom helpers, scoped to the proposals engine.
    #
    module ApplicationHelper
      include Decidim::Comments::CommentsHelper
      include PaginateHelper
      include ProposalVotesHelper
      include ProposalOrderHelper
      include Decidim::MapHelper
      include Decidim::Proposals::MapHelper

      # Public: The state of a proposal in a way a human can understand.
      #
      # state - The String state of the proposal.
      #
      # Returns a String.
      def humanize_proposal_state(state)
        value = if state == "accepted"
                  "accepted"
                elsif state == "rejected"
                  "rejected"
                else
                  "not_answered"
                end

        I18n.t(value, scope: "decidim.proposals.answers")
      end

      # Public: The css class applied based on the proposal state.
      #
      # state - The String state of the proposal.
      #
      # Returns a String.
      def proposal_state_css_class(state)
        if state == "accepted"
          "text-success"
        elsif state == "rejected"
          "text-alert"
        else
          "text-warning"
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
decidim-proposals-0.1.0 app/helpers/decidim/proposals/application_helper.rb
decidim-0.1.0 decidim-proposals/app/helpers/decidim/proposals/application_helper.rb
decidim-proposals-0.0.8.1 app/helpers/decidim/proposals/application_helper.rb
decidim-0.0.8.1 decidim-proposals/app/helpers/decidim/proposals/application_helper.rb