From 2c71f7f1ed2942a19db530a2ede0a6320fdc365f Mon Sep 17 00:00:00 2001 From: David Cook Date: Wed, 3 Apr 2024 15:12:04 +1100 Subject: [PATCH] Discard changes by reloading the page Now there's a popup asking to confirm, which I think is worth keeping! --- app/views/admin/products_v3/_table.html.haml | 4 +++- app/webpacker/css/admin_v3/components/buttons.scss | 3 ++- spec/system/admin/products_v3/products_spec.rb | 4 +++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/views/admin/products_v3/_table.html.haml b/app/views/admin/products_v3/_table.html.haml index 6b85adaf05..6f9850e778 100644 --- a/app/views/admin/products_v3/_table.html.haml +++ b/app/views/admin/products_v3/_table.html.haml @@ -35,7 +35,9 @@ -# Y products could not be saved correctly. Please review errors and try again = t('.error_summary.invalid', count: @error_counts[:invalid]) .form-buttons - = form.submit t('.reset'), type: :reset, class: "medium" + + %a.button.reset.medium{ href: admin_products_path(page: @page, per_page: @per_page) } + = t('.reset') = form.submit t('.save'), class: "medium" %tr %th.align-left= # image diff --git a/app/webpacker/css/admin_v3/components/buttons.scss b/app/webpacker/css/admin_v3/components/buttons.scss index f213dd7bc3..01ede577d1 100644 --- a/app/webpacker/css/admin_v3/components/buttons.scss +++ b/app/webpacker/css/admin_v3/components/buttons.scss @@ -158,7 +158,8 @@ button:not(.plain):not(.trix-button), } // --- Reset buttons --- -input[type="reset"] { +input[type="reset"], +.reset { // Reset button looks like a link, but has a border the same as buttons when active. background: none; border: 1px solid transparent; diff --git a/spec/system/admin/products_v3/products_spec.rb b/spec/system/admin/products_v3/products_spec.rb index 14e1765036..0f23adf05c 100644 --- a/spec/system/admin/products_v3/products_spec.rb +++ b/spec/system/admin/products_v3/products_spec.rb @@ -369,7 +369,9 @@ describe 'As an admin, I can manage products', feature: :admin_style_v3 do product_a.update! sku: "APL-10" expect { - click_button "Discard changes" + accept_confirm do + click_on "Discard changes" + end product_a.reload }.not_to change { product_a.name }