From ef880e349f959686a830bda67ec5a295e3d76eb4 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 --- .../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 19533f9c7b..36de4a7b33 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 5154b71b0b..da493f261e 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 bb00da9cc2..b61702d615 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' %]