app/controllers/katalyst/navigation/menus_controller.rb in katalyst-navigation-1.6.0 vs app/controllers/katalyst/navigation/menus_controller.rb in katalyst-navigation-1.8.0
- old
+ new
@@ -1,23 +1,16 @@
# frozen_string_literal: true
module Katalyst
module Navigation
class MenusController < Katalyst::Navigation.config.base_controller.constantize
- include Katalyst::Tables::Backend
+ helper Katalyst::Tables::Frontend
def index
collection = Katalyst::Tables::Collection::Base.new(sorting: :title).with_params(params).apply(Menu.all)
- table = Katalyst::Turbo::TableComponent.new(collection:,
- id: "index-table",
- class: "index-table",
- caption: true)
- respond_to do |format|
- format.turbo_stream { render(table) } if self_referred?
- format.html { render :index, locals: { table: } }
- end
+ render locals: { collection: }
end
def show
menu = Menu.find(params[:id])
editor = Katalyst::Navigation::EditorComponent.new(menu:)
@@ -38,11 +31,11 @@
render locals: { menu:, editor: }
end
def create
- @menu = Menu.new(menu_params)
+ @menu = Menu.new(menu_params)
editor = Katalyst::Navigation::EditorComponent.new(menu: @menu)
if @menu.save
@menu.build_draft_version
@menu.save!
@@ -52,10 +45,10 @@
end
end
# PATCH /admins/navigation_menus/:slug
def update
- menu = Menu.find(params[:id])
+ menu = Menu.find(params[:id])
editor = Katalyst::Navigation::EditorComponent.new(menu:)
menu.attributes = menu_params
unless menu.valid?