From ab34dbf200672ffe4c12da21ad38701c8df1e304 Mon Sep 17 00:00:00 2001 From: Stephen Nelson Date: Fri, 15 Dec 2023 14:17:32 +1030 Subject: [PATCH] Fix items controller integration --- .../katalyst/navigation/items_controller.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/controllers/katalyst/navigation/items_controller.rb b/app/controllers/katalyst/navigation/items_controller.rb index 69172bb..68c7dff 100644 --- a/app/controllers/katalyst/navigation/items_controller.rb +++ b/app/controllers/katalyst/navigation/items_controller.rb @@ -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] @@ -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 @@ -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 @@ -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