From 033cd306c1f0f1317afb4ec1112c760fdced3586 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Sat, 26 Mar 2022 11:17:08 +0100 Subject: [PATCH] Improved products/chore merge dialogs form validation --- localization/strings.pot | 2 +- public/viewjs/chores.js | 9 +++++- public/viewjs/products.js | 9 +++++- views/chores.blade.php | 66 +++++++++++++++++++++------------------ views/products.blade.php | 66 +++++++++++++++++++++------------------ 5 files changed, 89 insertions(+), 63 deletions(-) diff --git a/localization/strings.pot b/localization/strings.pot index e1d4938d..4b17ab64 100644 --- a/localization/strings.pot +++ b/localization/strings.pot @@ -2040,7 +2040,7 @@ msgstr "" msgid "After merging, this product will be kept" msgstr "" -msgid "After merging, all occurences of this product will be replaced by \"Product to keep\" (means this product will not exist anymore)" +msgid "After merging, all occurences of this product will be replaced by the kept product (means this product will not exist anymore)" msgstr "" msgid "Merge" diff --git a/public/viewjs/chores.js b/public/viewjs/chores.js index 37a4958d..6c2f789d 100644 --- a/public/viewjs/chores.js +++ b/public/viewjs/chores.js @@ -88,8 +88,15 @@ $(".merge-chores-button").on("click", function(e) $("#merge-chores-modal").modal("show"); }); -$("#merge-chores-save-button").on("click", function() +$("#merge-chores-save-button").on("click", function(e) { + e.preventDefault(); + + if (!Grocy.FrontendHelpers.ValidateForm("merge-chores-form", true)) + { + return; + } + var choreIdToKeep = $("#merge-chores-keep").val(); var choreIdToRemove = $("#merge-chores-remove").val(); diff --git a/public/viewjs/products.js b/public/viewjs/products.js index 894e858b..3810d122 100644 --- a/public/viewjs/products.js +++ b/public/viewjs/products.js @@ -137,8 +137,15 @@ $(".merge-products-button").on("click", function(e) $("#merge-products-modal").modal("show"); }); -$("#merge-products-save-button").on("click", function() +$("#merge-products-save-button").on("click", function(e) { + e.preventDefault(); + + if (!Grocy.FrontendHelpers.ValidateForm("merge-products-form", true)) + { + return; + } + var productIdToKeep = $("#merge-products-keep").val(); var productIdToRemove = $("#merge-products-remove").val(); diff --git a/views/chores.blade.php b/views/chores.blade.php index b0ace94b..cb369ec6 100644 --- a/views/chores.blade.php +++ b/views/chores.blade.php @@ -163,34 +163,41 @@ diff --git a/views/products.blade.php b/views/products.blade.php index b6aee6ce..b2fd4543 100644 --- a/views/products.blade.php +++ b/views/products.blade.php @@ -233,34 +233,41 @@