Module: Decidim::Proposals::Admin::ProposalBulkActionsHelper
- Defined in:
- 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.
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.
13 14 15 16 |
# File 'app/helpers/decidim/proposals/admin/proposal_bulk_actions_helper.rb', line 13 def bulk_valuators_select(participatory_space, prompt) = find_valuators_for_select(participatory_space) select(:valuator_role, :id, , prompt: prompt) end |
#find_valuators_for_select(participatory_space) ⇒ Object
Internal: A method to cache to queries to find the valuators for the current space.
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/helpers/decidim/proposals/admin/proposal_bulk_actions_helper.rb', line 20 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 |