Class: Decidim::DecidimAwesome::Admin::ConfigController

Inherits:
ApplicationController
  • Object
show all
Includes:
ConfigConstraintsHelpers, NeedsAwesomeConfig
Defined in:
app/controllers/decidim/decidim_awesome/admin/config_controller.rb

Overview

Global configuration controller

Instance Method Summary collapse

Methods included from ConfigConstraintsHelpers

#check, #component_manifests, #components_list, #config_enabled?, #enabled_configs, #participatory_space_manifests, #participatory_spaces_list, #translate_constraint_value

Methods included from NeedsAwesomeConfig

extended, included

Methods inherited from ApplicationController

#permission_class_chain

Instance Method Details

#destroy_scoped_styleObject



52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'app/controllers/decidim/decidim_awesome/admin/config_controller.rb', line 52

def destroy_scoped_style
  DestroyScopedStyle.call(params[:key], current_organization) do
    on(:ok) do |key|
      flash[:notice] = I18n.t("config.destroy_scoped_style.success", key: key, scope: "decidim.decidim_awesome.admin")
    end

    on(:invalid) do |message|
      flash[:alert] = I18n.t("config.destroy_scoped_style.error", error: message, scope: "decidim.decidim_awesome.admin")
    end
  end

  redirect_to decidim_admin_decidim_awesome.config_path(:styles)
end

#new_scoped_styleObject



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/controllers/decidim/decidim_awesome/admin/config_controller.rb', line 38

def new_scoped_style
  CreateScopedStyle.call(current_organization) do
    on(:ok) do |key|
      flash[:notice] = I18n.t("config.create_scoped_style.success", key: key, scope: "decidim.decidim_awesome.admin")
    end

    on(:invalid) do |message|
      flash[:alert] = I18n.t("config.create_scoped_style.error", error: message, scope: "decidim.decidim_awesome.admin")
    end
  end

  redirect_to decidim_admin_decidim_awesome.config_path(:styles)
end

#showObject



19
20
21
# File 'app/controllers/decidim/decidim_awesome/admin/config_controller.rb', line 19

def show
  @form = form(ConfigForm).from_params(organization_awesome_config)
end

#updateObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/decidim/decidim_awesome/admin/config_controller.rb', line 23

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 |message|
      flash.now[:alert] = I18n.t("config.update.error", error: message, scope: "decidim.decidim_awesome.admin")
      render :show
    end
  end
end