Module: Decidim::Proposals::Admin::ProposalBulkActionsHelper
- Defined in:
- decidim-proposals/app/helpers/decidim/proposals/admin/proposal_bulk_actions_helper.rb
Instance Method Summary collapse
-
#bulk_valuators_select(participatory_space, prompt) ⇒ Object
Public: Generates a select field with the valuators of the given participatory space.
-
#find_valuators_for_select(participatory_space) ⇒ Object
Internal: A method to cache to queries to find the valuators for the current space.
- #proposal_find(id) ⇒ Object
Instance Method Details
#bulk_valuators_select(participatory_space, prompt) ⇒ Object
Public: Generates a select field with the valuators of the given participatory space.
participatory_space - A participatory space instance. prompt - An i18n string to show as prompt
Returns a String.
17 18 19 20 |
# File 'decidim-proposals/app/helpers/decidim/proposals/admin/proposal_bulk_actions_helper.rb', line 17 def bulk_valuators_select(participatory_space, prompt) = find_valuators_for_select(participatory_space) select(:valuator_role, :id, , prompt:) end |
#find_valuators_for_select(participatory_space) ⇒ Object
Internal: A method to cache to queries to find the valuators for the current space.
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'decidim-proposals/app/helpers/decidim/proposals/admin/proposal_bulk_actions_helper.rb', line 24 def find_valuators_for_select(participatory_space) return @valuators_for_select if @valuators_for_select valuator_roles = participatory_space.user_roles(:valuator) valuators = Decidim::User.where(id: valuator_roles.pluck(:decidim_user_id)).to_a @valuators_for_select = valuator_roles.map do |role| valuator = valuators.find { |user| user.id == role.decidim_user_id } [valuator.name, role.id] end end |