Class: Decidim::DecidimAwesome::Admin::ConfigController
- Inherits:
-
ApplicationController
- Object
- Admin::ApplicationController
- ApplicationController
- Decidim::DecidimAwesome::Admin::ConfigController
- Includes:
- ConfigConstraintsHelpers, NeedsAwesomeConfig
- Defined in:
- app/controllers/decidim/decidim_awesome/admin/config_controller.rb
Overview
Global configuration controller
Direct Known Subclasses
ForceAuthorizationsController, ProposalCustomFieldsController, ScopedAdminsController, ScopedStylesController
Constant Summary
Constants included from ConfigConstraintsHelpers
Decidim::DecidimAwesome::Admin::ConfigConstraintsHelpers::APPLICATION_CONTEXTS, Decidim::DecidimAwesome::Admin::ConfigConstraintsHelpers::OTHER_MANIFESTS
Instance Method Summary collapse
Methods included from ConfigConstraintsHelpers
#check, #component_manifests, #components_list, #contexts_list, #enabled_configs, #md5, #participatory_space_manifests, #participatory_spaces_list, #translate_constraint_value
Methods included from NeedsAwesomeConfig
Methods inherited from ApplicationController
Instance Method Details
#rename_scope_label ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'app/controllers/decidim/decidim_awesome/admin/config_controller.rb', line 59 def rename_scope_label RenameScopeLabel.call(params, current_organization) do on(:ok) do |result| render json: result.merge({ html: render_to_string(partial: "decidim/decidim_awesome/admin/config/constraints", locals: { key: result[:scope], constraints: constraints_for(result[:scope]) }) }) end on(:invalid) do || render json: { error: }, status: :unprocessable_entity end end end |
#show ⇒ Object
17 18 19 20 21 22 |
# File 'app/controllers/decidim/decidim_awesome/admin/config_controller.rb', line 17 def show @form = form(ConfigForm).from_params(organization_awesome_config) path = main_path_for(config_var) redirect_to decidim_admin_decidim_awesome.send(path[0], *path[1]) unless path[0] == :config_path end |
#update ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/controllers/decidim/decidim_awesome/admin/config_controller.rb', line 24 def update @form = form(ConfigForm).from_params(params[:config]) UpdateConfig.call(@form) do on(:ok) do flash[:notice] = I18n.t("config.update.success", scope: "decidim.decidim_awesome.admin") redirect_to decidim_admin_decidim_awesome.config_path end on(:invalid) do |, err| flash.now[:alert] = I18n.t("config.update.error", error: , scope: "decidim.decidim_awesome.admin") render :show, locals: { errors: err.presence } end end end |
#users ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'app/controllers/decidim/decidim_awesome/admin/config_controller.rb', line 39 def users respond_to do |format| format.json do if (term = params[:term].to_s).present? query = current_organization.users.order(name: :asc) query = query.where("name ILIKE :term OR nickname ILIKE :term OR email ILIKE :term", term: "%#{term}%") render json: query.all.collect { |u| { value: u.id, text: format_user_name(u), is_admin: u.read_attribute("admin") } } else render json: [] end end end end |