Module: Decidim::Proposals::Admin::ProposalsHelper
- Includes:
- Admin::ResourceScopeHelper, TranslatableAttributes
- Defined in:
- app/helpers/decidim/proposals/admin/proposals_helper.rb
Overview
This class contains helpers needed to format Meetings in order to use them in select forms for Proposals.
Instance Method Summary collapse
- #available_states ⇒ Object
- #coauthor_presenters_for(proposal) ⇒ Object
- #endorsers_presenters_for(proposal) ⇒ Object
- #icon_with_link_to_proposal(proposal) ⇒ Object
-
#meetings_as_authors_selected ⇒ Object
Public: A formatted collection of Meetings to be used in forms.
- #proposal_complete_state(proposal) ⇒ Object
Instance Method Details
#available_states ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'app/helpers/decidim/proposals/admin/proposals_helper.rb', line 13 def available_states [ Decidim::Proposals::ProposalState.where(component: current_component).new( token: "not_answered", title: t("decidim.proposals.answers.not_answered") ) ] + Decidim::Proposals::ProposalState.where(component: current_component).all end |
#coauthor_presenters_for(proposal) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'app/helpers/decidim/proposals/admin/proposals_helper.rb', line 30 def (proposal) proposal..map do |identity| if identity.is_a?(Decidim::Organization) Decidim::Proposals::OfficialAuthorPresenter.new else present(identity) end end end |
#endorsers_presenters_for(proposal) ⇒ Object
40 41 42 |
# File 'app/helpers/decidim/proposals/admin/proposals_helper.rb', line 40 def endorsers_presenters_for(proposal) proposal.endorsements.for_listing.map { |identity| present(identity.) } end |
#icon_with_link_to_proposal(proposal) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'app/helpers/decidim/proposals/admin/proposals_helper.rb', line 51 def icon_with_link_to_proposal(proposal) icon, tooltip = if allowed_to?(:create, :proposal_answer, proposal:) && !proposal.emendation? [ "question-answer-line", t(:answer_proposal, scope: "decidim.proposals.actions") ] else [ "information-line", t(:show, scope: "decidim.proposals.actions") ] end icon_link_to(icon, proposal_path(proposal), tooltip, class: "icon--small action-icon--show-proposal") end |
#meetings_as_authors_selected ⇒ Object
Public: A formatted collection of Meetings to be used in forms.
24 25 26 27 28 |
# File 'app/helpers/decidim/proposals/admin/proposals_helper.rb', line 24 def return unless @proposal.present? && @proposal.official_meeting? @meetings_as_authors_selected ||= @proposal..pluck(:id) end |
#proposal_complete_state(proposal) ⇒ Object
44 45 46 47 48 49 |
# File 'app/helpers/decidim/proposals/admin/proposals_helper.rb', line 44 def proposal_complete_state(proposal) return humanize_proposal_state(:withdrawn).html_safe if proposal.withdrawn? return humanize_proposal_state("not_answered").html_safe if proposal.proposal_state.nil? translated_attribute(proposal&.proposal_state&.title) end |