Skip to content

Commit

Permalink
Fix items controller integration
Browse files Browse the repository at this point in the history
  • Loading branch information
sfnelson committed Dec 15, 2023
1 parent c21fb38 commit ab34dbf
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions app/controllers/katalyst/navigation/items_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Katalyst
module Navigation
class ItemsController < ApplicationController
class ItemsController < Katalyst::Navigation.config.base_controller.constantize
before_action :set_menu, only: %i[new create]
before_action :set_item, except: %i[new create]

Expand All @@ -11,6 +11,9 @@ class ItemsController < ApplicationController
layout nil

def new
@item = @menu.items.build(new_item_params)
@editor = Katalyst::Navigation::EditorComponent.new(menu:, item:)

render_editor
end

Expand All @@ -19,6 +22,9 @@ def edit
end

def create
@item = @menu.items.build(item_params)
@editor = Katalyst::Navigation::EditorComponent.new(menu:, item:)

if item.save
render :update, locals: { editor:, item:, previous: @menu.items.build(type: item.type) }
else
Expand Down Expand Up @@ -60,8 +66,6 @@ def item_params

def set_menu
@menu = Menu.find(params[:menu_id])
@item = @menu.items.build(item_params)
@editor = Katalyst::Navigation::EditorComponent.new(menu:, item:)
end

def set_item
Expand Down

0 comments on commit ab34dbf

Please sign in to comment.