Module: Decidim::Proposals::ApplicationHelper
- Includes:
- Comments::CommentsHelper, MapHelper, MapHelper, ProposalVotesHelper, PaginateHelper
- Defined in:
- app/helpers/decidim/proposals/application_helper.rb
Overview
Custom helpers, scoped to the proposals engine.
Instance Method Summary collapse
- #current_user_proposals ⇒ Object
-
#humanize_proposal_state(state) ⇒ Object
Public: The state of a proposal in a way a human can understand.
- #proposal_limit ⇒ Object
- #proposal_limit_enabled? ⇒ Boolean
-
#proposal_state_badge_css_class(state) ⇒ Object
Public: The css class applied based on the proposal state to the proposal badge.
-
#proposal_state_css_class(state) ⇒ Object
Public: The css class applied based on the proposal state.
Methods included from MapHelper
Methods included from ProposalVotesHelper
#current_user_can_vote?, #maximum_votes_per_proposal, #maximum_votes_per_proposal_enabled?, #remaining_votes_count_for, #vote_button_classes, #vote_limit, #vote_limit_enabled?, #votes_blocked?, #votes_count_classes, #votes_enabled?
Instance Method Details
#current_user_proposals ⇒ Object
68 69 70 |
# File 'app/helpers/decidim/proposals/application_helper.rb', line 68 def current_user_proposals Proposal.where(feature: current_feature, author: current_user) end |
#humanize_proposal_state(state) ⇒ Object
Public: The state of a proposal in a way a human can understand.
state - The String state of the proposal.
Returns a String.
19 20 21 |
# File 'app/helpers/decidim/proposals/application_helper.rb', line 19 def humanize_proposal_state(state) I18n.t(state, scope: "decidim.proposals.answers", default: :not_answered) end |
#proposal_limit ⇒ Object
62 63 64 65 66 |
# File 'app/helpers/decidim/proposals/application_helper.rb', line 62 def proposal_limit return if feature_settings.proposal_limit.zero? feature_settings.proposal_limit end |
#proposal_limit_enabled? ⇒ Boolean
58 59 60 |
# File 'app/helpers/decidim/proposals/application_helper.rb', line 58 def proposal_limit_enabled? proposal_limit.present? end |
#proposal_state_badge_css_class(state) ⇒ Object
Public: The css class applied based on the proposal state to
the proposal badge.
state - The String state of the proposal.
Returns a String.
47 48 49 50 51 52 53 54 55 56 |
# File 'app/helpers/decidim/proposals/application_helper.rb', line 47 def proposal_state_badge_css_class(state) case state when "accepted" "success" when "rejected" "warning" when "evaluating" "secondary" end end |
#proposal_state_css_class(state) ⇒ Object
Public: The css class applied based on the proposal state.
state - The String state of the proposal.
Returns a String.
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/helpers/decidim/proposals/application_helper.rb', line 28 def proposal_state_css_class(state) case state when "accepted" "text-success" when "rejected" "text-alert" when "evaluating" "text-info" else "text-warning" end end |