From 6f798ff886fa4bb764515ff0ade3ca9bc144a9bb Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 7 Nov 2023 11:35:22 +0000 Subject: [PATCH] Bug 31041: (follow-up) Clean up and generalise This patch cleans out the print media css rules that were originally added for modalprinting. The window.open method is simpler to maintain and will more reliably print modal content as expected. We factor out the printer code into it's own JS asset that we can apply to other printable modals and then use it in the two existing places where such modals have been defined already (cashup summary and bundle confirmation). Signed-off-by: Martin Renvoize Signed-off-by: Lucas Gass Signed-off-by: Tomas Cohen Arazi (cherry picked from commit ef880e349f959686a830bda67ec5a295e3d76eb4) Signed-off-by: Fridolin Somers (cherry picked from commit 39a8ff6bb5c97b07cf8e73424e7432cf675b3777) Signed-off-by: Pedro Amorim --- .../prog/css/src/staff-global.scss | 33 ---------- .../prog/en/modules/circ/returns.tt | 17 +---- .../prog/en/modules/pos/register.tt | 1 + .../intranet-tmpl/prog/js/cashup_modal.js | 56 ----------------- .../intranet-tmpl/prog/js/modal_printer.js | 63 +++++++++++++++++++ 5 files changed, 65 insertions(+), 105 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/js/modal_printer.js diff --git a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss index e7cfc23ab6..f3c27d8efd 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss +++ b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss @@ -4485,36 +4485,3 @@ div .suggestion_note { border-bottom-right-radius: 5px; } } - -@media print { - body.modalprinter * { - visibility: hidden; - } - - body.modalprinter .modal-dialog.focused { - position: absolute; - padding: 0; - margin: 0; - left: 0; - top: 0; - } - - body.modalprinter .modal-dialog.focused .modal-content { - border-width: 0; - } - - body.modalprinter .modal-dialog.focused .modal-content .modal-header .modal-title, - body.modalprinter .modal-dialog.focused .modal-content .modal-body, - body.modalprinter .modal-dialog.focused .modal-content .modal-body * { - visibility: visible; - } - - body.modalprinter .modal-dialog.focused .modal-content .modal-header, - body.modalprinter .modal-dialog.focused .modal-content .modal-body { - padding: 0; - } - - body.modalprinter .modal-dialog.focused .modal-content .modal-header .modal-title { - margin-bottom: 20px; - } -} diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt index 9df383d3cc..825ae64910 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt @@ -1601,22 +1601,6 @@ "order": [[ 1, 'asc' ], [ 0, 'asc' ]] })); - // print modals - $('.modal.printable').on('shown.bs.modal', function() { - $('.modal-dialog', this).addClass('focused'); - $('body').addClass('modalprinter'); - - if ($(this).hasClass('autoprint')) { - window.print(); - } - }).on('hidden.bs.modal', function() { - $('.modal-dialog', this).removeClass('focused'); - $('body').removeClass('modalprinter'); - }); - - $('.printModal').click(function() { - window.print(); - }); [% IF ( !(Koha.Preference('TransfersBlockCirc')) && Koha.Preference('AutomaticConfirmTransfer') ) %] $("#wrong-transfer-modal").on('hidden.bs.modal',function(){ $("#wrongtransferform").submit(); @@ -1628,6 +1612,7 @@ [% END %] [% END %] }); + [% Asset.js("js/modal_printer.js") | $raw %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt index 21c4329512..ce95116c8e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt @@ -351,6 +351,7 @@ [% INCLUDE 'format_price.inc' %] [% INCLUDE 'js-date-format.inc' %] [% Asset.js("js/cashup_modal.js") | $raw %] + [% Asset.js("js/modal_printer.js") | $raw %] [% INCLUDE 'calendar.inc' %]