From 232c7d921352ea86493c37bd031f6cf1bc3206ee Mon Sep 17 00:00:00 2001 From: Emmi Takkinen Date: Mon, 15 Jun 2020 13:19:35 +0300 Subject: [PATCH] Bug 23415: Display confirm dialog only once On detail page when patron has multiple checkouts and they are renewed from checkouts list, confirmation dialog box is displayed as many times as patron has checkouts. This patch reworks some code so this dialog box is displayed only once. To test: 1. Find patron with multiple checkouts (at least two) 2. Renew all checkouts from checkout list 3. Confirmation pop-up is displayed for every checkout 4. Apply this patch 5. Renew again => Confirmation dialog box is displayed only once Sponsored-by: Koha-Suomi Oy Signed-off-by: Stina Hallin Signed-off-by: Petro Vashchuk Signed-off-by: Veli-Matti --- koha-tmpl/intranet-tmpl/prog/js/checkouts.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js index 84c8a0c992..19296cea90 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js +++ b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js @@ -7,6 +7,8 @@ $(document).ready(function() { var onHoldDueDateSet = false; + var show_confirm = true; + var onHoldChecked = function() { var isChecked = false; $('input[data-on-reserve]').each(function() { @@ -152,15 +154,13 @@ $(document).ready(function() { var itemnumber = $(this).val(); - var can_renew = true; - - if( parseFloat(fines) > parseFloat(amountlimit) ) { + if(show_confirm && parseFloat(fines) > parseFloat(amountlimit) ) { var result = confirm(MSG_CONFRIM_RENEW); - if(result){ - can_renew = true; - }else{ - can_renew = false; + if(!result){ + return false; } + // Prevent displaying confirm box again + show_confirm = false; } var params = { @@ -185,10 +185,8 @@ $(document).ready(function() { params.date_due = dueDate } - if(can_renew) { - $(this).parent().parent().replaceWith(""); - renew(params); - } + $(this).parent().parent().replaceWith(""); + renew(params); }); // Refocus on barcode field if it exists -- 2.30.2