Bug 38072: Fix regression in modal_printer

This patch updates the JS for the modal printer to make it more
reliable.

I found that in recent versions of chrome the print dialog failed to
open and instead you were just faced with a flash of white before the
new tab autoclosed and no print takes place.

Test plan
1) Enable cash registers and point of sale preferences
2) Add a debit type and mark it as 'Can be sold'
3) Add a cash register
4) Use 'Point of sale' to sell one of the above item for cash against
   the register you just created.
5) Navigate to the register and 'cashup'
6) Click the 'summary' link to display a modal
7) Use the 'Print' option in the modal and confirm you face a print
   dialog and can print
8) The print tab should be closed and you should be back to Koha

Signed-off-by: David Nind <david@davidnind.com>

Bug 38072: Ensure the printing tab closes

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
[EDIT] Squashed and tidied.
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Martin Renvoize 2024-10-03 15:41:05 +01:00 committed by Lucas Gass
parent a6ba625592
commit af31453c63
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
1 changed files with 7 additions and 1 deletions

View File

@ -40,8 +40,14 @@ $(document).ready(function () {
`);
win.document.write(title);
win.document.write(contents);
win.document.close();
win.addEventListener("afterprint", function () {
win.addEventListener("focus", function () {
win.close();
});
win.close();
});
win.print();
win.close();
}
// Set focused on printable modals on open and autoprint if required