Bug 40524: [24.05.x] 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"

Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jesse Maseto <jesse@bywatersolutions.com>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
David Cook 2025-07-28 03:26:43 +00:00 committed by Paul Derscheid
parent d7a06b7947
commit e5d5b050e1
No known key found for this signature in database
GPG Key ID: C25F9FD44CED595B
1 changed files with 21 additions and 1 deletions

View File

@ -687,6 +687,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);
@ -726,7 +746,7 @@ function _dt_buttons(params){
extend: 'print',
exportOptions: {
columns: exportColumns,
format: export_format
format: export_format_print,
},
}
];