diff --git a/admin/app/components/solidus_admin/stock_items/edit/component.html.erb b/admin/app/components/solidus_admin/stock_items/edit/component.html.erb index 64a8d7cc594..725bf505ae2 100644 --- a/admin/app/components/solidus_admin/stock_items/edit/component.html.erb +++ b/admin/app/components/solidus_admin/stock_items/edit/component.html.erb @@ -11,7 +11,9 @@ <%= link_to spree.edit_admin_product_variant_path( @stock_item.variant.product, @stock_item.variant, - ), class: 'hover:bg-gray-25 rounded p-1 w-1/2 border border-gray-100' do %> + ), + data: {turbo_frame: "_top"}, + class: 'hover:bg-gray-25 rounded p-1 w-1/2 border border-gray-100' do %> <%= render component("ui/resource_item").new( thumbnail: ( @@ -23,7 +25,9 @@ "#{@stock_item.variant.sku}#{@stock_item.variant.options_text.presence&.prepend(" - ")}", ) %> <% end %> - <%= link_to spree.edit_admin_stock_location_path(@stock_item.stock_location), class: 'hover:bg-gray-25 rounded p-1 w-1/2 border border-gray-100' do %> + <%= link_to spree.edit_admin_stock_location_path(@stock_item.stock_location), + data: {turbo_frame: "_top"}, + class: 'hover:bg-gray-25 rounded p-1 w-1/2 border border-gray-100' do %> <%= render component("ui/resource_item").new( title: @stock_item.stock_location.name, subtitle: "#{Spree::StockLocation.model_name.human} #{@stock_item.stock_location.code}", @@ -78,6 +82,4 @@ <% end %> <% end %> <% end %> - - <%= render component("stock_items/index").new(page: @page) %> diff --git a/admin/app/components/solidus_admin/stock_items/edit/component.rb b/admin/app/components/solidus_admin/stock_items/edit/component.rb index 3573444d413..bdb9e27f6d8 100644 --- a/admin/app/components/solidus_admin/stock_items/edit/component.rb +++ b/admin/app/components/solidus_admin/stock_items/edit/component.rb @@ -1,9 +1,8 @@ # frozen_string_literal: true class SolidusAdmin::StockItems::Edit::Component < SolidusAdmin::BaseComponent - def initialize(stock_item:, page:) + def initialize(stock_item:) @stock_item = stock_item - @page = page end def title diff --git a/admin/app/components/solidus_admin/stock_items/index/component.rb b/admin/app/components/solidus_admin/stock_items/index/component.rb index fc20bb93f71..d9d91d817a7 100644 --- a/admin/app/components/solidus_admin/stock_items/index/component.rb +++ b/admin/app/components/solidus_admin/stock_items/index/component.rb @@ -13,8 +13,8 @@ def search_url solidus_admin.stock_items_path end - def row_url(stock_item) - solidus_admin.edit_stock_item_path(stock_item, _turbo_frame: :edit_stock_item_modal) + def edit_path(stock_item) + solidus_admin.edit_stock_item_path(stock_item) end def scopes @@ -90,7 +90,9 @@ def name_column { header: :name, data: ->(stock_item) do - content_tag :div, stock_item.variant.name + link_to stock_item.variant.name, edit_path(stock_item), + data: { turbo_frame: :edit_stock_item_modal, turbo_prefetch: false }, + class: 'body-link' end } end @@ -99,7 +101,9 @@ def sku_column { header: :sku, data: ->(stock_item) do - content_tag :div, stock_item.variant.sku + link_to stock_item.variant.sku, edit_path(stock_item), + data: { turbo_frame: :edit_stock_item_modal, turbo_prefetch: false }, + class: 'body-link' end } end diff --git a/admin/app/controllers/solidus_admin/stock_items_controller.rb b/admin/app/controllers/solidus_admin/stock_items_controller.rb index 1333dbe672c..dba5ffc3d35 100644 --- a/admin/app/controllers/solidus_admin/stock_items_controller.rb +++ b/admin/app/controllers/solidus_admin/stock_items_controller.rb @@ -3,7 +3,7 @@ module SolidusAdmin class StockItemsController < SolidusAdmin::BaseController include SolidusAdmin::ControllerHelpers::Search - before_action :load_stock_items, only: [:index, :edit, :update] + before_action :load_stock_items, only: [:index] before_action :load_stock_item, only: [:edit, :update] search_scope(:all, default: true) { _1 } @@ -20,7 +20,7 @@ def index def edit respond_to do |format| - format.html { render component('stock_items/edit').new(stock_item: @stock_item, page: @page) } + format.html { render component('stock_items/edit').new(stock_item: @stock_item) } end end @@ -36,7 +36,8 @@ def update end else respond_to do |format| - format.html { render component('stock_items/edit').new(stock_item: @stock_item, page: @page), status: :unprocessable_entity } + format.html { render component('stock_items/edit').new(stock_item: @stock_item), + status: :unprocessable_entity } end end end