diff --git a/admin/app/components/solidus_admin/tax_categories/edit/component.html.erb b/admin/app/components/solidus_admin/tax_categories/edit/component.html.erb index a5feeef7251..a02e97cb830 100644 --- a/admin/app/components/solidus_admin/tax_categories/edit/component.html.erb +++ b/admin/app/components/solidus_admin/tax_categories/edit/component.html.erb @@ -24,5 +24,3 @@ <% end %> <% end %> <% end %> - -<%= render component("tax_categories/index").new(page: @page) %> diff --git a/admin/app/components/solidus_admin/tax_categories/edit/component.rb b/admin/app/components/solidus_admin/tax_categories/edit/component.rb index 31ddbd13d72..abb9f83a5b5 100644 --- a/admin/app/components/solidus_admin/tax_categories/edit/component.rb +++ b/admin/app/components/solidus_admin/tax_categories/edit/component.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true class SolidusAdmin::TaxCategories::Edit::Component < SolidusAdmin::TaxCategories::Index::Component - def initialize(page:, tax_category:) - @page = page + def initialize(tax_category:) @tax_category = tax_category end diff --git a/admin/app/components/solidus_admin/tax_categories/index/component.rb b/admin/app/components/solidus_admin/tax_categories/index/component.rb index c2ce2b16ca2..bb2b9ec8bae 100644 --- a/admin/app/components/solidus_admin/tax_categories/index/component.rb +++ b/admin/app/components/solidus_admin/tax_categories/index/component.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true class SolidusAdmin::TaxCategories::Index::Component < SolidusAdmin::Taxes::Component - def row_url(tax_category) - spree.edit_admin_tax_category_path(tax_category, _turbo_frame: :edit_tax_category_modal) + def edit_path(tax_category) + spree.edit_admin_tax_category_path(tax_category) end def model_class @@ -17,7 +17,10 @@ def page_actions render component("ui/button").new( tag: :a, text: t('.add'), - href: solidus_admin.new_tax_category_path, data: { turbo_frame: :new_tax_category_modal }, + href: solidus_admin.new_tax_category_path, data: { + turbo_frame: :new_tax_category_modal, + turbo_prefetch: false, + }, icon: "add-line", class: "align-self-end w-full", ) @@ -47,9 +50,30 @@ def batch_actions def columns [ - :name, - :tax_code, - :description, + { + header: :name, + data: ->(tax_category) do + link_to tax_category.name, edit_path(tax_category), + data: { turbo_frame: :edit_tax_category_modal, turbo_prefetch: false }, + class: 'body-link' + end + }, + { + header: :tax_code, + data: ->(tax_category) do + link_to_if tax_category.tax_code, tax_category.tax_code, edit_path(tax_category), + data: { turbo_frame: :edit_tax_category_modal, turbo_prefetch: false }, + class: 'body-link' + end + }, + { + header: :description, + data: ->(tax_category) do + link_to_if tax_category.description, tax_category.description, edit_path(tax_category), + data: { turbo_frame: :edit_tax_category_modal, turbo_prefetch: false }, + class: 'body-link' + end + }, { header: :is_default, data: ->(tax_category) { diff --git a/admin/app/components/solidus_admin/tax_categories/new/component.html.erb b/admin/app/components/solidus_admin/tax_categories/new/component.html.erb index b1a97dcc9be..f112dce4e7f 100644 --- a/admin/app/components/solidus_admin/tax_categories/new/component.html.erb +++ b/admin/app/components/solidus_admin/tax_categories/new/component.html.erb @@ -24,5 +24,3 @@ <% end %> <% end %> <% end %> - -<%= render component("tax_categories/index").new(page: @page) %> diff --git a/admin/app/components/solidus_admin/tax_categories/new/component.rb b/admin/app/components/solidus_admin/tax_categories/new/component.rb index d61ef1e3dd5..5bf598a3cd7 100644 --- a/admin/app/components/solidus_admin/tax_categories/new/component.rb +++ b/admin/app/components/solidus_admin/tax_categories/new/component.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true class SolidusAdmin::TaxCategories::New::Component < SolidusAdmin::TaxCategories::Index::Component - def initialize(page:, tax_category:) - @page = page + def initialize(tax_category:) @tax_category = tax_category end diff --git a/admin/app/controllers/solidus_admin/tax_categories_controller.rb b/admin/app/controllers/solidus_admin/tax_categories_controller.rb index 96a7d96a750..20922dc0e19 100644 --- a/admin/app/controllers/solidus_admin/tax_categories_controller.rb +++ b/admin/app/controllers/solidus_admin/tax_categories_controller.rb @@ -9,20 +9,16 @@ class TaxCategoriesController < SolidusAdmin::BaseController def new @tax_category = Spree::TaxCategory.new - set_index_page - respond_to do |format| - format.html { render component('tax_categories/new').new(page: @page, tax_category: @tax_category) } + format.html { render component('tax_categories/new').new(tax_category: @tax_category) } end end def edit @tax_category = Spree::TaxCategory.find(params[:id]) - set_index_page - respond_to do |format| - format.html { render component('tax_categories/edit').new(page: @page, tax_category: @tax_category) } + format.html { render component('tax_categories/edit').new(tax_category: @tax_category) } end end @@ -44,11 +40,9 @@ def create end end else - set_index_page - respond_to do |format| format.html do - page_component = component('tax_categories/new').new(page: @page, tax_category: @tax_category) + page_component = component('tax_categories/new').new(tax_category: @tax_category) render page_component, status: :unprocessable_entity end end @@ -69,11 +63,9 @@ def update end end else - set_index_page - respond_to do |format| format.html do - page_component = component('tax_categories/edit').new(page: @page, tax_category: @tax_category) + page_component = component('tax_categories/edit').new(tax_category: @tax_category) render page_component, status: :unprocessable_entity end end