From 177f6a1e562430dd3178996b56a5113a3b577e40 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 18 Nov 2024 14:47:57 +0100 Subject: [PATCH] Bug 38436: (follow-up) Fix visibility when bKohaColumnsUseNames is not set Previous commit didn't adjust columns_settings.inc Signed-off-by: Owen Leonard Signed-off-by: Paul Derscheid --- .../prog/en/includes/columns_settings.inc | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 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 19fd2c7c719..4a5b2122482 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc @@ -170,13 +170,31 @@ function KohaTable(id_selector, dt_parameters, table_settings, add_filters, defa dt_parameters[ "buttons" ] = ['clear_filter']; - let included_columns = table_settings.columns.filter(c => !c.cannot_be_toggled); + // Retrieving bKohaColumnsUseNames from the options passed to the constructor, not DT settings + // But ideally should be retrieved using table.data() + let use_names = dt_parameters.bKohaColumnsUseNames; + let included_columns = []; + if (table_settings) { + 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 ){ dt_parameters[ "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