diff --git a/admin/app/components/solidus_admin/return_reasons/edit/component.html.erb b/admin/app/components/solidus_admin/return_reasons/edit/component.html.erb index 8782aa23c43..5e14b95e423 100644 --- a/admin/app/components/solidus_admin/return_reasons/edit/component.html.erb +++ b/admin/app/components/solidus_admin/return_reasons/edit/component.html.erb @@ -23,4 +23,3 @@ <% end %> <% end %> <% end %> -<%= render component("return_reasons/index").new(page: @page) %> diff --git a/admin/app/components/solidus_admin/return_reasons/edit/component.rb b/admin/app/components/solidus_admin/return_reasons/edit/component.rb index 2ce5ed7f0bf..a73bca5670a 100644 --- a/admin/app/components/solidus_admin/return_reasons/edit/component.rb +++ b/admin/app/components/solidus_admin/return_reasons/edit/component.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true class SolidusAdmin::ReturnReasons::Edit::Component < SolidusAdmin::BaseComponent - def initialize(page:, return_reason:) - @page = page + def initialize(return_reason:) @return_reason = return_reason end diff --git a/admin/app/components/solidus_admin/return_reasons/index/component.rb b/admin/app/components/solidus_admin/return_reasons/index/component.rb index 175d9575828..8a6ee9f80ef 100644 --- a/admin/app/components/solidus_admin/return_reasons/index/component.rb +++ b/admin/app/components/solidus_admin/return_reasons/index/component.rb @@ -13,8 +13,8 @@ def search_key :name_cont end - def row_url(return_reason) - spree.edit_admin_return_reason_path(return_reason, _turbo_frame: :edit_return_reason_modal) + def edit_path(return_reason) + spree.edit_admin_return_reason_path(return_reason) end def turbo_frames @@ -29,7 +29,7 @@ def page_actions tag: :a, text: t('.add'), href: solidus_admin.new_return_reason_path, - data: { turbo_frame: :new_return_reason_modal }, + data: { turbo_frame: :new_return_reason_modal, turbo_prefetch: false }, icon: "add-line", class: "align-self-end w-full", ) @@ -48,7 +48,14 @@ def batch_actions def columns [ - :name, + { + header: :name, + data: ->(return_reason) do + link_to return_reason.name, edit_path(return_reason), + data: { turbo_frame: :edit_return_reason_modal, turbo_prefetch: false }, + class: 'body-link' + end + }, { header: :active, data: ->(return_reason) do diff --git a/admin/app/components/solidus_admin/return_reasons/new/component.html.erb b/admin/app/components/solidus_admin/return_reasons/new/component.html.erb index 7a55ebbcacd..237315fb3e8 100644 --- a/admin/app/components/solidus_admin/return_reasons/new/component.html.erb +++ b/admin/app/components/solidus_admin/return_reasons/new/component.html.erb @@ -23,5 +23,3 @@ <% end %> <% end %> <% end %> - -<%= render component("return_reasons/index").new(page: @page) %> diff --git a/admin/app/components/solidus_admin/return_reasons/new/component.rb b/admin/app/components/solidus_admin/return_reasons/new/component.rb index 7efe494f634..35ae39d7dbe 100644 --- a/admin/app/components/solidus_admin/return_reasons/new/component.rb +++ b/admin/app/components/solidus_admin/return_reasons/new/component.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true class SolidusAdmin::ReturnReasons::New::Component < SolidusAdmin::BaseComponent - def initialize(page:, return_reason:) - @page = page + def initialize(return_reason:) @return_reason = return_reason end diff --git a/admin/app/controllers/solidus_admin/return_reasons_controller.rb b/admin/app/controllers/solidus_admin/return_reasons_controller.rb index 892603806ca..7effdd9f213 100644 --- a/admin/app/controllers/solidus_admin/return_reasons_controller.rb +++ b/admin/app/controllers/solidus_admin/return_reasons_controller.rb @@ -17,10 +17,8 @@ def index def new @return_reason = Spree::ReturnReason.new - set_index_page - respond_to do |format| - format.html { render component('return_reasons/new').new(page: @page, return_reason: @return_reason) } + format.html { render component('return_reasons/new').new(return_reason: @return_reason) } end end @@ -40,11 +38,9 @@ def create end end else - set_index_page - respond_to do |format| format.html do - page_component = component('return_reasons/new').new(page: @page, return_reason: @return_reason) + page_component = component('return_reasons/new').new(return_reason: @return_reason) render page_component, status: :unprocessable_entity end end @@ -52,10 +48,8 @@ def create end def edit - set_index_page - respond_to do |format| - format.html { render component('return_reasons/edit').new(page: @page, return_reason: @return_reason) } + format.html { render component('return_reasons/edit').new(return_reason: @return_reason) } end end @@ -73,11 +67,9 @@ def update end end else - set_index_page - respond_to do |format| format.html do - page_component = component('return_reasons/edit').new(page: @page, return_reason: @return_reason) + page_component = component('return_reasons/edit').new(return_reason: @return_reason) render page_component, status: :unprocessable_entity end end diff --git a/admin/spec/features/return_reasons_spec.rb b/admin/spec/features/return_reasons_spec.rb index 41c978da8de..721b00ecc98 100644 --- a/admin/spec/features/return_reasons_spec.rb +++ b/admin/spec/features/return_reasons_spec.rb @@ -67,7 +67,7 @@ before do Spree::ReturnReason.create(name: "Good Reason") visit "/admin/return_reasons#{query}" - find_row("Good Reason").click + click_on "Good Reason" expect(page).to have_selector("dialog", wait: 5) expect(page).to have_content("Edit Return Reason") expect(page).to be_axe_clean