diff --git a/app/helpers/concerns/decidim/simple_proposal/scopes_helper_override.rb b/app/helpers/concerns/decidim/simple_proposal/scopes_helper_override.rb index 15a273bd7c..2654d05639 100644 --- a/app/helpers/concerns/decidim/simple_proposal/scopes_helper_override.rb +++ b/app/helpers/concerns/decidim/simple_proposal/scopes_helper_override.rb @@ -4,9 +4,8 @@ module Decidim module SimpleProposal module ScopesHelperOverride extend ActiveSupport::Concern - included do - def scopes_picker_field(form, name, root: false, options: { checkboxes_on_top: true, sort_by_weight: true }) + def scopes_picker_field(form, name, root: false, options: { checkboxes_on_top: true }) options.merge!(selected: selected_scope(form)) if selected_scope(form) form.select(name, simple_scope_options(root: root, options: options), include_blank: t("decidim.scopes.prompt")) end @@ -23,11 +22,9 @@ def selected_scope(form) def simple_scope_options(root: false, options: {}) scopes_array = [] roots = root ? root.children : ancestors - roots.sort_by { |ancestor| ancestor.weight || 0 }.each do |ancestor| children_after_parent(ancestor, scopes_array, "") end - selected = options.has_key?(:selected) ? options[:selected] : params.dig(:filter, :decidim_scope_id) options_for_select(scopes_array, selected) end @@ -37,7 +34,7 @@ def ancestors end def children_after_parent(ancestor, array, prefix) - array << ["#{prefix} #{translated_attribute(ancestor.name)}", ancestor.id, ancestor.weight] + array << ["#{prefix} #{translated_attribute(ancestor.name)}", ancestor.id] ancestor.children.sort_by { |child| child.weight || 0 }.each do |child| children_after_parent(child, array, "#{prefix}-") end