From 87244ab9bfc351a68238012c9c781e81081df3bc Mon Sep 17 00:00:00 2001 From: David Cook Date: Mon, 28 Jul 2025 03:26:43 +0000 Subject: [PATCH] Bug 40524: Update print format to use built-in formatter This change updates the print format to use the built-in formatter for operations like trim, strip HTML, strip newlines, and not decoding entities. Test plan: 0. Apply the patch 1. Go to http://localhost:8081/cgi-bin/koha/acqui/basket.pl?basketno=1 2. Click "add to basket" 3. Type "test" next to "From an existing record" and click "Submit" 4. On the "Gairm" row, click "Add order" 5. Fill in the required fields 6. In the "Internal note" put the following: abc123 7. Click "Save" 8. In the Orders table, click "Export" and then "Print" 9. Note that the print page loads correctly, you can see the internal note, and you cannot see lines for "Add internal note", "Edit internal note", or "Add vendor note" --- koha-tmpl/intranet-tmpl/prog/js/datatables.js | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js index bdfe317dda..ec67b6d647 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js +++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js @@ -816,6 +816,26 @@ function _dt_buttons(params) { }, }; + const export_format_print = { + body: function (data, row, column, node) { + const newnode = node.cloneNode(true); + const no_export_nodes = newnode.querySelectorAll(".no-export"); + no_export_nodes.forEach(child => { + child.parentNode.removeChild(child); + }); + //Note: innerHTML is the same thing as the data variable, + //minus the ".no-export" nodes that we've removed + //Note: See dataTables.buttons.js for original function usage + const str = DataTable.Buttons.stripData(newnode.innerHTML, { + decodeEntities: false, + stripHtml: true, + stripNewlines: true, + trim: true, + }); + return str; + }, + }; + var export_format = { body: function (data, row, column, node) { var newnode = $(node); @@ -855,7 +875,7 @@ function _dt_buttons(params) { extend: "print", exportOptions: { columns: exportColumns, - format: export_format, + format: export_format_print, }, }, ]; -- 2.39.5