From 0d653066763d03abfbc78f4c7c5449facd9abe18 Mon Sep 17 00:00:00 2001 From: Petro Vashchuk Date: Tue, 10 Sep 2024 13:00:27 +0300 Subject: [PATCH] Bug 37880: Fix unwanted form submission on RenewAll button Currently when there's 0 renewable items and you press RenewAll button, js does pointless form submission. Steps to reproduce: 1. Have a patron with one or more holds that shouldn't be possible to renew. 2. Press RenewAll button. 3. Apply the patch. 4. Repeat step 2 but this time you should get "There is no items to renew." alert. Signed-off-by: Olivier V --- koha-tmpl/intranet-tmpl/prog/js/checkouts.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js index 64979297be..f414de1996 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js +++ b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js @@ -739,6 +739,11 @@ $(document).ready(function() { } let item_ids = $(".renew:checked:visible").map((i, c) => c.value); + if ( item_ids.length == 0 ) { + // Skip if no items to renew otherwise we will die in .then below + alert( __("There is no items to renew.") ); + return false; + } renew_all(item_ids, renew).then(() => { // Refocus on barcode field if it exists -- 2.34.1