Discard changes by reloading the page

Now there's a popup asking to confirm, which I think is worth keeping!
This commit is contained in:
David Cook
2024-04-03 15:12:04 +11:00
committed by Filipe
parent 8696e05e66
commit 2c71f7f1ed
3 changed files with 8 additions and 3 deletions

View File

@@ -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

View File

@@ -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;

View File

@@ -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 }