Class: Katalyst::Navigation::MenusController
- Inherits:
-
Object
- Object
- Katalyst::Navigation::MenusController
- Defined in:
- app/controllers/katalyst/navigation/menus_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
-
#update ⇒ Object
PATCH /admins/navigation_menus/:slug.
Instance Method Details
#create ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/controllers/katalyst/navigation/menus_controller.rb', line 35 def create @menu = Menu.new() editor = Katalyst::Navigation::EditorComponent.new(menu: @menu) if @menu.save @menu.build_draft_version @menu.save! redirect_to @menu, status: :see_other else render :new, locals: { menu: @menu, editor: }, status: :unprocessable_entity end end |
#destroy ⇒ Object
73 74 75 76 77 78 79 |
# File 'app/controllers/katalyst/navigation/menus_controller.rb', line 73 def destroy = Menu.find(params[:id]) .destroy! redirect_to action: :index, status: :see_other end |
#edit ⇒ Object
28 29 30 31 32 33 |
# File 'app/controllers/katalyst/navigation/menus_controller.rb', line 28 def edit = Menu.find(params[:id]) editor = Katalyst::Navigation::EditorComponent.new(menu:) render locals: { menu:, editor: } end |
#index ⇒ Object
8 9 10 11 12 |
# File 'app/controllers/katalyst/navigation/menus_controller.rb', line 8 def index collection = Katalyst::Tables::Collection::Base.new(sorting: :title).with_params(params).apply(Menu.all) render locals: { collection: } end |
#new ⇒ Object
21 22 23 24 25 26 |
# File 'app/controllers/katalyst/navigation/menus_controller.rb', line 21 def new = Menu.new editor = Katalyst::Navigation::EditorComponent.new(menu:) render locals: { menu:, editor: } end |
#show ⇒ Object
14 15 16 17 18 19 |
# File 'app/controllers/katalyst/navigation/menus_controller.rb', line 14 def show = Menu.find(params[:id]) editor = Katalyst::Navigation::EditorComponent.new(menu:) render locals: { menu:, editor: } end |
#update ⇒ Object
PATCH /admins/navigation_menus/:slug
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'app/controllers/katalyst/navigation/menus_controller.rb', line 49 def update = Menu.find(params[:id]) editor = Katalyst::Navigation::EditorComponent.new(menu:) .attributes = unless .valid? return respond_to do |format| format.turbo_stream { render editor.errors, status: :unprocessable_entity } end end case params[:commit] when "publish" .save! .publish! when "save" .save! when "revert" .revert! end redirect_to , status: :see_other end |