Module: Decidim::Proposals::Admin::ProposalBulkActionsHelper
- Defined in:
- decidim-proposals/app/helpers/decidim/proposals/admin/proposal_bulk_actions_helper.rb
Instance Method Summary collapse
-
#bulk_templates_select(component, prompt, id: nil) ⇒ Object
Public: Generates a select field with the templates of the given component.
- #find_templates_for_select(component) ⇒ Object
-
#find_valuators_for_select(participatory_space, current_user) ⇒ Object
find the valuators for the current space.
- #proposal_find(id) ⇒ Object
Instance Method Details
#bulk_templates_select(component, prompt, id: nil) ⇒ Object
Public: Generates a select field with the templates of the given component.
component - A component 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_templates_select(component, prompt, id: nil) = find_templates_for_select(component) select(:template, :template_id, , prompt:, id:) end |
#find_templates_for_select(component) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'decidim-proposals/app/helpers/decidim/proposals/admin/proposal_bulk_actions_helper.rb', line 22 def find_templates_for_select(component) return [] unless Decidim.module_installed? :templates return @templates_for_select if @templates_for_select templates = Decidim::Templates::Template.where( target: :proposal_answer, templatable: component ).order(:templatable_id) @templates_for_select = templates.map do |template| [translated_attribute(template.name), template.id] end end |
#find_valuators_for_select(participatory_space, current_user) ⇒ Object
find the valuators for the current space.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'decidim-proposals/app/helpers/decidim/proposals/admin/proposal_bulk_actions_helper.rb', line 37 def find_valuators_for_select(participatory_space, current_user) valuator_roles = participatory_space.user_roles(:valuator).order_by_name valuators = Decidim::User.where(id: valuator_roles.pluck(:decidim_user_id)).to_a filtered_valuator_roles = valuator_roles.filter do |role| role.decidim_user_id != current_user.id end filtered_valuator_roles.map do |role| valuator = valuators.find { |user| user.id == role.decidim_user_id } [valuator.name, role.id] end end |