From eed19b44552a3ed5e43b3386cd10771e245fe260 Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Mon, 9 Dec 2024 10:57:52 +0000 Subject: [PATCH] Bug 38268: (Follow-ups) Prevent callbacks from being duplicated --- koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt | 3 --- koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt | 1 - koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-tags.tt | 1 - koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt | 5 ----- koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt | 1 - koha-tmpl/opac-tmpl/bootstrap/js/global.js | 4 +++- 6 files changed, 3 insertions(+), 12 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt index 5f59a2d9b7d..143491b555c 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt @@ -951,7 +951,6 @@ $(function() { }); } confirmModal( message, title, yes_label, no_label, function( result ){ - $("#bootstrap-confirm-box-modal").remove(); if( result ){ if( biblionumber ){ $("#shelf_delete_biblionumber").val( biblionumber ); @@ -1004,7 +1003,6 @@ $(function() { message += "

" + _("This list is shared. Other users will lose access to it.") + "

"; } confirmModal( message, _("Are you sure you want to delete this list?"), _("Yes, delete"), _("No, do not delete"), function( result ){ - $("#bootstrap-confirm-box-modal").remove(); if( result ){ $("#deleteshelf" + shelf_number ).submit(); } @@ -1017,7 +1015,6 @@ $(function() { var shelf_name = $(this).data("shelfname"); var shelf_number = $(this).data("shelfnumber"); confirmModal( shelf_name, _("Are you sure you want to remove sharing? You will no longer have access to the list."), _("Yes, remove sharing"), _("No, do not remove sharing"), function( result ){ - $("#bootstrap-confirm-box-modal").remove(); if( result ){ $("#unshare" + shelf_number ).submit(); } diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt index 0e33f7e39c3..312015c6ebe 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt @@ -638,7 +638,6 @@ }); } confirmModal( message, title, yes_label, no_label, function( result ){ - $("#bootstrap-confirm-box-modal").remove(); if( result ){ $("#delete_suggestions").submit(); } diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-tags.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-tags.tt index 93e6973a093..85d74f1196c 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-tags.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-tags.tt @@ -256,7 +256,6 @@ }); } confirmModal( message, title, yes_label, no_label, function( result ){ - $("#bootstrap-confirm-box-modal").remove(); if( result ){ $("#deletetags").submit(); } diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt index 12163f0e4f0..a6295f4e129 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt @@ -1119,7 +1119,6 @@ var hold_title = $(this).data("title"); var reserve_id = $(this).data("reserve_id"); confirmModal( hold_title, _("Are you sure you want to cancel this hold?"), _("Yes, cancel hold"), _("No, do not cancel hold"), function( result ){ - $("#bootstrap-confirm-box-modal").remove() if( result ){ $("#delete_hold_" + reserve_id ).submit(); } @@ -1132,7 +1131,6 @@ var hold_title = $(this).data("title"); var reserve_id = $(this).data("reserve_id"); confirmModal( hold_title, _("Are you sure you want to request cancelling this hold?"), _("Yes"), _("No"), function( result ){ - $("#bootstrap-confirm-box-modal").remove() if( result ){ $("#req_cancel_hold_" + reserve_id ).submit(); } @@ -1146,7 +1144,6 @@ var article_request_id = $(this).data("article-request_id"); (function(row){ var doCancel = function( result ){ - $("#bootstrap-confirm-box-modal").remove(); if( result ){ $.ajax({ type: "DELETE", @@ -1197,7 +1194,6 @@ var title = _("Are you sure you want to suspend all holds?"); var body = _("All holds will be suspended."); confirmModal( body, title, _("Yes, suspend all holds"), "", function( result ){ - $("#bootstrap-confirm-box-modal").remove() if( result ){ $("#suspend_all_holds").submit(); } @@ -1210,7 +1206,6 @@ var title = _("Are you sure you want to resume all suspended holds?"); var body = _("All holds will resume."); confirmModal( body, title, _("Yes, resume all holds"), _("No, do not resume holds"), function( result ){ - $("#bootstrap-confirm-box-modal").remove() if( result ){ $("#resume_all_holds").submit(); } diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt index e705b2069f4..1e68d62898b 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt @@ -612,7 +612,6 @@ [% IF Koha.Preference('SelfCheckReceiptPrompt') %] var confirmStart = Date.now(); confirmModal("", _("Would you like to print a receipt?"), _("Print receipt and end session"), _("End session"), function(result) { - $("#bootstrap-confirm-box-modal").remove(); if ( result && (Date.now() - confirmStart) < [% SelfCheckTimeout | html %] ) { var win = window.open("/cgi-bin/koha/sco/printslip.pl?print=qslip"); location.href = '/cgi-bin/koha/sco/sco-main.pl?op=logout'; diff --git a/koha-tmpl/opac-tmpl/bootstrap/js/global.js b/koha-tmpl/opac-tmpl/bootstrap/js/global.js index accdf699865..ebc755270f3 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/js/global.js +++ b/koha-tmpl/opac-tmpl/bootstrap/js/global.js @@ -133,8 +133,10 @@ function confirmModal(message, title, yes_label, no_label, callback) { return false; }); $("#bootstrap-confirm-box-modal").on("hide.bs.modal", function () { - if (callback) + if (callback) { callback($("#bootstrap-confirm-box-modal").data("confirm-yes")); + $("#bootstrap-confirm-box-modal").remove(); + } }); } -- 2.39.5 (Apple Git-154)