Bug 38268: (follow-up) Prevent callbacks from being duplicated

This patch moves the logic up one level into the confirmModal function
to prevent future regressions

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit 1fc336d6bd)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
Matt Blenkinsop 2024-12-09 10:57:52 +00:00 committed by Paul Derscheid
parent 9f41e794d9
commit df35003e45
No known key found for this signature in database
GPG Key ID: C25F9FD44CED595B
6 changed files with 3 additions and 12 deletions

View File

@ -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 += "<p>" + _("This list is shared. Other users will lose access to it.") + "</p>";
}
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();
}

View File

@ -638,7 +638,6 @@
});
}
confirmModal( message, title, yes_label, no_label, function( result ){
$("#bootstrap-confirm-box-modal").remove();
if( result ){
$("#delete_suggestions").submit();
}

View File

@ -255,7 +255,6 @@
});
}
confirmModal( message, title, yes_label, no_label, function( result ){
$("#bootstrap-confirm-box-modal").remove();
if( result ){
$("#deletetags").submit();
}

View File

@ -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();
}

View File

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

View File

@ -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();
}
});
}