From 401fc0272099ea3a821a854f097266854604c6bc Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 15 Nov 2024 22:07:55 +0100 Subject: [PATCH] Bug 38436: Fix visibility when bKohaColumnsUseNames is not set Typically the patrons search. --- koha-tmpl/intranet-tmpl/prog/js/datatables.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js index cf99773dde5..f7d1ebb4a31 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js +++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js @@ -664,13 +664,23 @@ function _dt_buttons(params){ } ); - let included_columns = table_settings.columns.filter(c => !c.cannot_be_toggled); + // Retrieving bKohaColumnsUseNames from the options passed to the constructor, not DT's settings + // But ideally should be retrieved using table.data() + let use_names = settings.bKohaColumnsUseNames; + let included_columns = []; + if ( use_names ) { + // bKohaColumnsUseNames is set, identify columns by their data-colname + included_columns = table_settings.columns.filter(c => !c.cannot_be_toggled).map(c => "[data-colname='%s']".format(c.columnname)).join(','); + } else { + // Not set, columns are ordered the same than in the columns settings + included_columns = table_settings.columns.map((c, i) => !c.cannot_be_toggled ? i : null).filter(i => i !== null); + } if( included_columns.length > 0 ){ buttons.push( { extend: 'colvis', fade: 100, - columns: included_columns.map(c => "[data-colname='%s']".format(c.columnname)).join(','), + columns: included_columns, className: "columns_controls", titleAttr: __("Columns settings"), text: ' ' + __("Columns") + '', -- 2.34.1