From c0e2912ee6e16c1236688f10b60454689d9405e5 Mon Sep 17 00:00:00 2001 From: Maryse Simard Date: Thu, 14 Nov 2019 08:50:30 -0500 Subject: [PATCH] Bug 12502: (follow-up) Adds formatting for datatables export MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Add a format option to the datatables export that remove .noExport elements present in a data cell, just as .noExport columns are not exported. To test: 1. For late orders (which uses .noExport elements in data cells) : Export data in any format using the export button at the top of the datatable. => data should exclude "Add/Edit note" label, but otherwise look the same as before the patch. 2. Try exporting data in other datatables in Koha and make sure exported data is the same before and after applying the patch. Signed-off-by: Séverine QUEUNE Signed-off-by: Katrin Fischer Signed-off-by: Martin Renvoize --- .../prog/en/includes/columns_settings.inc | 25 ++++++++++++++++--- .../prog/en/modules/acqui/lateorders.tt | 8 +++--- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc index f02ad89151..1117050110 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc @@ -27,33 +27,50 @@ function KohaTable(id_selector, dt_parameters, columns_settings, add_filters) { exportColumns = dt_parameters["exportColumns"]; } + var export_format = { + body: function ( data, row, column, node ) { + var newnode = $(node); + + if ( newnode.find(".noExport").length > 0 ) { + newnode = newnode.clone(); + newnode.find(".noExport").remove(); + } + + return newnode.text().replace( /\n/g, ' ' ).trim(); + } + } + var export_buttons = [ { extend: 'excelHtml5', text: _("Excel"), exportOptions: { - columns: exportColumns + columns: exportColumns, + format: export_format }, }, { extend: 'csvHtml5', text: _("CSV"), exportOptions: { - columns: exportColumns + columns: exportColumns, + format: export_format }, }, { extend: 'copyHtml5', text: _("Copy"), exportOptions: { - columns: exportColumns + columns: exportColumns, + format: export_format }, }, { extend: 'print', text: _("Print"), exportOptions: { - columns: exportColumns + columns: exportColumns, + format: export_format }, } ]; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt index 31fc3ab2c3..5096922cc4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt @@ -142,12 +142,12 @@ [% IF ( lateorder.internalnote ) %]

[% lateorder.internalnote | html %] - + Edit internal note

[% ELSE %] - + Add internal note [% END %] @@ -156,12 +156,12 @@ [% IF ( lateorder.vendornote ) %]

[% lateorder.vendornote | html %] - + Edit vendor note

[% ELSE %] - + Add vendor note [% END %] -- 2.39.5