From a647c0ef161f0c63cc19f1cc7fb60fb5c0bfb850 Mon Sep 17 00:00:00 2001 From: Phil Ringnalda Date: Fri, 25 Oct 2024 11:15:08 -0700 Subject: [PATCH] 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 Signed-off-by: Owen Leonard Signed-off-by: Martin Renvoize --- 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/sco/sco-main.tt | 1 + 4 files changed, 6 insertions(+) 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 143491b555c..5f59a2d9b7d 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt @@ -951,6 +951,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 ); @@ -1003,6 +1004,7 @@ $(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(); } @@ -1015,6 +1017,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(); } 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 312015c6ebe..0e33f7e39c3 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt @@ -638,6 +638,7 @@ }); } 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 7e6dfa05e94..1f5cce9bb19 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-tags.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-tags.tt @@ -255,6 +255,7 @@ }); } 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/sco/sco-main.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt index 1e68d62898b..e705b2069f4 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,6 +612,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'; -- 2.47.1