Class: Decidim::DecidimAwesome::Admin::MenuHacksController

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

Overview

Editing menu items

Constant Summary

Constants included from ConfigConstraintsHelpers

ConfigConstraintsHelpers::OTHER_MANIFESTS

Instance Method Summary collapse

Methods included from ConfigConstraintsHelpers

#check, #component_manifests, #components_list, #config_enabled?, #enabled_configs, #md5, #menus, #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

#createObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/controllers/decidim/decidim_awesome/admin/menu_hacks_controller.rb', line 26

def create
  @form = form(MenuForm).from_params(params)
  CreateMenuHack.call(@form, current_menu_name) do
    on(:ok) do
      flash[:notice] = I18n.t("menu_hacks.create.success", scope: "decidim.decidim_awesome.admin")
      redirect_to decidim_admin_decidim_awesome.menu_hacks_path
    end

    on(:invalid) do |message|
      flash.now[:alert] = I18n.t("menu_hacks.create.error", error: message, scope: "decidim.decidim_awesome.admin")
      render :new
    end
  end
end

#destroyObject



60
61
62
63
64
65
66
67
68
69
70
# File 'app/controllers/decidim/decidim_awesome/admin/menu_hacks_controller.rb', line 60

def destroy
  DestroyMenuHack.call(menu_item, current_menu_name, current_organization) do
    on(:ok) do
      flash[:notice] = I18n.t("menu_hacks.destroy.success", scope: "decidim.decidim_awesome.admin")
    end
    on(:invalid) do |error|
      flash[:alert] = I18n.t("menu_hacks.destroy.error", scope: "decidim.decidim_awesome.admin", error: error)
    end
  end
  redirect_to decidim_admin_decidim_awesome.menu_hacks_path
end

#editObject



41
42
43
# File 'app/controllers/decidim/decidim_awesome/admin/menu_hacks_controller.rb', line 41

def edit
  @form = form(MenuForm).from_model(menu_item)
end

#indexObject



20
# File 'app/controllers/decidim/decidim_awesome/admin/menu_hacks_controller.rb', line 20

def index; end

#newObject



22
23
24
# File 'app/controllers/decidim/decidim_awesome/admin/menu_hacks_controller.rb', line 22

def new
  @form = form(MenuForm).instance
end

#updateObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'app/controllers/decidim/decidim_awesome/admin/menu_hacks_controller.rb', line 45

def update
  @form = form(MenuForm).from_params(params)
  UpdateMenuHack.call(@form, current_menu_name) do
    on(:ok) do
      flash[:notice] = I18n.t("menu_hacks.update.success", scope: "decidim.decidim_awesome.admin")
      redirect_to decidim_admin_decidim_awesome.menu_hacks_path
    end

    on(:invalid) do |message|
      flash.now[:alert] = I18n.t("menu_hacks.update.error", error: message, scope: "decidim.decidim_awesome.admin")
      render :edit
    end
  end
end