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

Instance Method Details

#destroy_scoped_styleObject



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

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



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

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



16
17
18
# File 'app/controllers/decidim/decidim_awesome/admin/config_controller.rb', line 16

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

#updateObject



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

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