Bug 21216: (follow-up) Exclude some columns from export

This patch adds a custom buttons configuration to the Notices table so
that columns with form controls are not included in copy/print/export
operations.

The DataTables columns settings include file has been modified
to check for an existing buttons export columns configuration before
applying the default.

To test, apply the patch and clear your browser cache if necessary.

Go to Tools -> Notices & slips. The table of notices should have a
DataTables toolbar with a filter form, column visibility, and export
buttons. Test the functionality of all these tools. Only the first four
columns of the table should be included in printouts and exported files.

Signed-off-by: Michal Denar <black23@gmail.com>

Signed-off-by: Michal Denar <black23@gmail.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
Owen Leonard 2018-09-24 13:37:16 +00:00 committed by Nick Clemens
parent 8960cee9ab
commit 023ab5845a
2 changed files with 15 additions and 7 deletions

View file

@ -1,6 +1,6 @@
[% USE ColumnsSettings %]
<script type="text/javascript">
<script>
function KohaTable(id_selector, dt_parameters, columns_settings, add_filters) {
var counter = 0;
var hidden_ids = [];
@ -20,41 +20,48 @@ function KohaTable(id_selector, dt_parameters, columns_settings, add_filters) {
}
counter++;
});
var exportColumns = ":visible";
if( dt_parameters.hasOwnProperty("exportColumns") ){
// A custom buttons configuration has been passed from the page
exportColumns = dt_parameters["exportColumns"];
}
dt_parameters[ "buttons" ] = [
{
extend: 'colvis',
columns: included_ids,
text: _("Column visibility"),
exportOptions: {
columns: ':visible'
columns: exportColumns
},
},
{
extend: 'excelHtml5',
text: _("Excel"),
exportOptions: {
columns: ':visible'
columns: exportColumns
},
},
{
extend: 'csvHtml5',
text: _("CSV"),
exportOptions: {
columns: ':visible'
columns: exportColumns
},
},
{
extend: 'copyHtml5',
text: _("Copy"),
exportOptions: {
columns: ':visible'
columns: exportColumns
},
},
{
extend: 'print',
text: _("Print"),
exportOptions: {
columns: ':visible'
columns: exportColumns
},
},
];

View file

@ -1,5 +1,5 @@
/* Variables defined in letter.tt: */
/* global _ module add_form copy_form no_op_set MSG_EMPTY_TITLE_AND_CONTENT MSG_EMPTY_TEMPLATES code MSG_CODE_EXISTS MSG_CODE_EXISTS_FOR_LIBRARY MSG_DT_LOADING_RECORDS interface theme KohaTable columns_settings */
/* global _ module add_form copy_form no_op_set MSG_EMPTY_TITLE_AND_CONTENT MSG_EMPTY_TEMPLATES code MSG_CODE_EXISTS MSG_CODE_EXISTS_FOR_LIBRARY MSG_DT_LOADING_RECORDS MSG_NO_NOTICE_FOUND interface theme KohaTable columns_settings */
var modal_loading = "<div id=\"loading\"><img src=\"" + interface + "/" + theme + "/img/spinner-small.gif\" alt=\"\" /> "+ MSG_DT_LOADING_RECORDS +"</div>";
@ -46,6 +46,7 @@ $(document).ready(function() {
"oLanguage": {
"sZeroRecords": MSG_NO_NOTICE_FOUND
},
"exportColumns": [0,1,2,3],
}, columns_settings);
if( no_op_set ){