Class: Decidim::ScopesController
- Inherits:
-
ApplicationController
- Object
- DecidimController
- ApplicationController
- Decidim::ScopesController
- Defined in:
- app/controllers/decidim/scopes_controller.rb
Overview
Exposes the scopes text search so users can choose a scope writing its name.
Instance Method Summary collapse
Methods included from HttpCachingDisabler
Methods included from NeedsOrganization
enhance_controller, extended, included
Instance Method Details
#picker ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/controllers/decidim/scopes_controller.rb', line 8 def picker :pick, :scope title = params[:title] || t("decidim.scopes.picker.title", field: params[:field]&.downcase) root = current_organization.scopes.find(params[:root]) if params[:root] context = root ? { root: root.id, title: title } : { title: title } required = params[:required] && params[:required] != "false" if params[:current] current = (root&.descendants || current_organization.scopes).find_by(id: params[:current]) || root scopes = current.children parent_scopes = current.part_of_scopes(root) else current = root scopes = root&.children || current_organization.scopes.top_level parent_scopes = [root].compact end render :picker, layout: nil, locals: { required: required, title: title, root: root, current: current, scopes: scopes.order(name: :asc), parent_scopes: parent_scopes, global_value: params[:global_value], context: context } end |