From 9a5dee7d7404cce6a3be9d0921f4fbbc20ea7d83 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 28 Jan 2025 14:14:20 +0100 Subject: [PATCH] Bug 26553: Split Export and restore "clear filters" - OPAC "Clear filters" is not in main but should be (I don't really understand why it is not displayed). The Export options were not grouped within an "Export" button in main, this patch restores that. --- .../opac-tmpl/bootstrap/js/datatables.js | 62 +++++++++---------- 1 file changed, 28 insertions(+), 34 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/js/datatables.js b/koha-tmpl/opac-tmpl/bootstrap/js/datatables.js index 0e8db747564..3e9354c2557 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/js/datatables.js +++ b/koha-tmpl/opac-tmpl/bootstrap/js/datatables.js @@ -40,23 +40,6 @@ var dataTablesDefaults = { 'clearFilter', 'copy', 'csv', 'print' ], "paging": false, - "buttons": [{ - fade: 100, - className: "dt_button_clear_filter", - titleAttr: __('Clear filter'), - enabled: false, - text: ' ' + __('Clear filter') + '', - available: function ( dt ) { - // The "clear filter" button is made available if this test returns true - if( dt.settings()[0].aanFeatures.f ){ // aanFeatures.f is null if there is no search form - return true; - } - }, - action: function ( e, dt, node ) { - dt.search( "" ).draw("page"); - node.addClass("disabled"); - } - }], initComplete: function( settings) { var tableId = settings.nTable.id; state = settings.oLoadedState; @@ -173,20 +156,43 @@ function _dt_buttons(params){ } ]; - let buttons = []; - buttons.push( + let buttons = [ { fade: 100, className: "dt_button_clear_filter", - titleAttr: __("Clear filter"), + titleAttr: _("Clear filter"), enabled: false, - text: ' ' + __("Clear filter") + '', + text: ' ' + _("Clear filter") + '', action: function ( e, dt, node, config ) { dt.search( "" ).draw("page"); node.addClass("disabled"); } + }, + { + extend: 'csvHtml5', + text: _("CSV"), + exportOptions: { + columns: exportColumns, + format: export_format + }, + }, + { + extend: 'copyHtml5', + text: _("Copy"), + exportOptions: { + columns: exportColumns, + format: export_format + }, + }, + { + extend: 'print', + text: _("Print"), + exportOptions: { + columns: exportColumns, + format: export_format + }, } - ); + ]; // Retrieving bKohaColumnsUseNames from the options passed to the constructor, not DT's settings // But ideally should be retrieved using table.data() @@ -222,18 +228,6 @@ function _dt_buttons(params){ ); } - buttons.push( - { - extend: 'collection', - autoClose: true, - fade: 100, - className: "export_controls", - titleAttr: __("Export or print"), - text: ' ' + __("Export") + '', - buttons: export_buttons - } - ); - return buttons; } -- 2.34.1