Bug 38268: Callers of confirmModal need to remove the modal as the first step in their callback function

Templates that use confirmModal to show a pretty confirm() need to
remove the modal in their callback function, or they are at risk of
having the first callback called for subsequent calls that think they
will get their own callback called. opac-user.tt is already fixed,
opac-shelves.tt is currently affected, and opace-suggestions.tt,
opac-tags.tt, and sco/sco-main.tt are at risk of being affected if
anyone adds another confirmModal caller.

Test plan:
 1. Without the patch, open the OPAC, log in, search for something that
    will return several results
 2. Select all - Add to list - New list
 3. Lists - {your list name}
 4. Click the checkboxes for the first two items
 5. Instead of clicking Remove from list, accidentally click Delete list
 6. In the confirmation popup, realize it was a mistake and click No, do
    not delete
 7. Click Remove from list
 8. Poof, your whole list is gone
 9. Apply patch
10. Repeat steps 1-7, but instead of the whole list being deleted, see
    that only the selected two items were removed
11. Now intentionally click Delete list and click Yes, delete, you'll
    see that it is deleted rather than getting a message about nothing
    being removed like you would have gotten without the patch if you
    started by removing an item
12. On any bib detail page, click Add tag(s) and add one
13. Your account - Tags, check the checkbox for the tag, Remove selected
    tags, Yes, delete tag and verify that it was deleted
14. Purchase suggestions - New purchase suggestion, fill in a title and
    submit your suggestion, click the checkbox for your suggestion,
    Delete selected, Yes, delete suggestion and verify it was deleted
15. In the staff interface, find and copy the barcode for any item that can
    be checked out, then go to /cgi-bin/koha/sco/sco-main.pl with the
    OPAC hostname and port, not the staff, and log in
16. Paste the barcode in the input, click Submit, then click Finish, and
    in the confirmation popup click Print recept and end session, and
    verify that it tries to print

Sponsored-by: Chetco Community Public Library
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
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 6b470caa92)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: wainuiwitikapark <wainuiwitikapark@catalyst.net.nz>
This commit is contained in:
Phil Ringnalda 2024-10-25 11:15:08 -07:00 committed by wainuiwitikapark
parent edcabe5d80
commit 7e5319280a
4 changed files with 6 additions and 0 deletions

View File

@ -952,6 +952,7 @@ $(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,6 +1005,7 @@ $(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();
}
@ -1016,6 +1018,7 @@ $(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

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

View File

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

View File

@ -607,6 +607,7 @@
[% 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';