From 3b8d0b9c3151e76e3a290fefe30fd2ffab7a06b9 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 --- .../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 19533f9c7b8..36de4a7b331 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss +++ b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss @@ -4748,36 +4748,3 @@ div .suggestion_note { border-bottom-right-radius: 5px; } } - -@media print { - body.modalprinter * { - visibility: hidden; - } - - body.modalprinter .modal-dialog.focused { - left: 0; - margin: 0; - padding: 0; - position: absolute; - 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 5154b71b0b1..da493f261e8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt @@ -1638,22 +1638,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(); @@ -1665,6 +1649,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 bb00da9cc2c..b61702d6154 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt @@ -352,6 +352,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' %]