Sha256: 10c19e5d3e179abc4e350d2559976a65f27ec5099d7ce6af724f4ab7ccdde942
Contents?: true
Size: 1.19 KB
Versions: 9
Compression:
Stored size: 1.19 KB
Contents
# frozen_string_literal: true module Decidim # Exposes the scopes text search so users can choose a scope writing its name. class ScopesController < Decidim::ApplicationController skip_before_action :store_current_location def picker authorize! :pick, Scope title = params[:title] || t("decidim.scopes.picker.title", field: params[:field]&.downcase) root = Scope.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 || Scope.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 end end
Version data entries
9 entries across 9 versions & 1 rubygems