Bug 38436: (follow-up) Fix visibility when bKohaColumnsUseNames is not set

Previous commit didn't adjust columns_settings.inc

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Jonathan Druart 2024-11-18 14:47:57 +01:00 committed by Katrin Fischer
parent 57f01d5b6e
commit f346a2e0de
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
1 changed files with 20 additions and 2 deletions

View File

@ -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: '<i class="fa fa-lg fa-gear"></i> <span class="dt-button-text">' + _("Columns") + '</span>',