Sha256: 2c2d2bdd516697f9ebcb65586e21e7600d4faaedf8750a06e965f61f87d253f8

Contents?: true

Size: 1.25 KB

Versions: 21

Compression:

Stored size: 1.25 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
      enforce_permission_to :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
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
decidim-core-0.18.1 app/controllers/decidim/scopes_controller.rb
decidim-core-0.17.2 app/controllers/decidim/scopes_controller.rb
decidim-core-0.18.0 app/controllers/decidim/scopes_controller.rb
decidim-core-0.17.1 app/controllers/decidim/scopes_controller.rb
decidim-core-0.16.1 app/controllers/decidim/scopes_controller.rb
decidim-core-0.17.0 app/controllers/decidim/scopes_controller.rb
decidim-core-0.16.0 app/controllers/decidim/scopes_controller.rb
decidim-core-0.15.2 app/controllers/decidim/scopes_controller.rb
decidim-core-0.15.1 app/controllers/decidim/scopes_controller.rb
decidim-core-0.15.0 app/controllers/decidim/scopes_controller.rb
decidim-core-0.14.4 app/controllers/decidim/scopes_controller.rb
decidim-core-0.14.3 app/controllers/decidim/scopes_controller.rb
decidim-core-0.14.2 app/controllers/decidim/scopes_controller.rb
decidim-core-0.14.1 app/controllers/decidim/scopes_controller.rb
decidim-core-0.13.1 app/controllers/decidim/scopes_controller.rb
decidim-core-0.12.2 app/controllers/decidim/scopes_controller.rb
decidim-core-0.13.0 app/controllers/decidim/scopes_controller.rb
decidim-core-0.12.1 app/controllers/decidim/scopes_controller.rb
decidim-core-0.13.0.pre1 app/controllers/decidim/scopes_controller.rb
decidim-core-0.12.0 app/controllers/decidim/scopes_controller.rb