Module: Decidim::Proposals::ApplicationHelper
- Includes:
- Comments::CommentsHelper, MapHelper, MapHelper, ProposalEndorsementsHelper, ProposalVotesHelper, PaginateHelper
- Included in:
- ProposalCellsHelper
- 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
- #follow_button_for(model) ⇒ 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 ProposalEndorsementsHelper
#current_user_can_endorse?, #endorsement_button, #endorsement_button_classes, #endorsement_identity_presenter, #endorsements_blocked?, #endorsements_count_classes, #endorsements_enabled?, #fully_endorsed?, #render_endorsement_identity, #show_endorsements_card?
Methods included from ProposalVotesHelper
#can_accumulate_supports_beyond_threshold?, #current_user_can_vote?, #remaining_votes_count_for, #threshold_per_proposal, #threshold_per_proposal_enabled?, #vote_button_classes, #vote_limit, #vote_limit_enabled?, #votes_blocked?, #votes_count_classes, #votes_enabled?
Instance Method Details
#current_user_proposals ⇒ Object
71 72 73 |
# File 'app/helpers/decidim/proposals/application_helper.rb', line 71 def current_user_proposals Proposal.where(component: current_component, author: current_user) end |
#follow_button_for(model) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 |
# File 'app/helpers/decidim/proposals/application_helper.rb', line 75 def (model) if current_user render partial: "decidim/shared/follow_button.html", locals: { followable: model } else content_tag(:p, class: "mt-s mb-none") do t("decidim.proposals.proposals.show.sign_in_or_up", in: link_to(t("decidim.proposals.proposals.show.sign_in"), decidim.new_user_session_path), up: link_to(t("decidim.proposals.proposals.show.sign_up"), decidim.new_user_registration_path)).html_safe end end 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.
20 21 22 |
# File 'app/helpers/decidim/proposals/application_helper.rb', line 20 def humanize_proposal_state(state) I18n.t(state, scope: "decidim.proposals.answers", default: :not_answered) end |
#proposal_limit ⇒ Object
65 66 67 68 69 |
# File 'app/helpers/decidim/proposals/application_helper.rb', line 65 def proposal_limit return if component_settings.proposal_limit.zero? component_settings.proposal_limit end |
#proposal_limit_enabled? ⇒ Boolean
61 62 63 |
# File 'app/helpers/decidim/proposals/application_helper.rb', line 61 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.
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/helpers/decidim/proposals/application_helper.rb', line 48 def proposal_state_badge_css_class(state) case state when "accepted" "success" when "rejected" "warning" when "evaluating" "secondary" when "withdrawn" "alert" 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.
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/helpers/decidim/proposals/application_helper.rb', line 29 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 |