From 3d89d2288784fafcc51cf4277047f61d6e108a68 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Mon, 27 Jan 2025 21:22:15 +0000 Subject: [PATCH] Bug 38978: [24.05.x] Fix update_columns_visibility to check table settings To test: 1. In 24.05.x, hide some columns via Table settings. 2. The columns do not hide properly, you cannot hide any columns via Table settings on this table. 3. APPLY PATCH 4. Check hiding columns now, it should work. 5. Make sure that columns with no data at all are still hidden. 6. Enable 'SeparateHoldings' and make sure you can also properly hide columns in the Other holdings table. --- .../tables/items/catalogue_detail.inc | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc index 714e60282d1..2835918271a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc @@ -120,10 +120,11 @@ } } - function update_columns_visibility(settings){ - let table = settings.oInstance.api(); - table.columns().visible(true); - table.columns().every(function(i){ + function update_columns_visibility(table_dt, table_settings) { + table_dt.columns().visible(true); + const hidden_ids = _dt_visibility(table_settings, table_dt); + + table_dt.columns().every(function(i){ let is_empty = true; let nodes = this.nodes(); nodes.each((td, ii) => { @@ -132,8 +133,13 @@ return; } }); + if (hidden_ids && Array.isArray(hidden_ids) && hidden_ids[0]) { + hidden_ids[0].forEach((colIndex) => { + table_dt.columns(colIndex).visible(false); + }); + } if ( is_empty ) { - table.columns(i).visible(false); + table_dt.columns(i).visible(false); } }); } @@ -836,7 +842,7 @@ [% END %] if ( api.data().length ) { - update_columns_visibility(settings); + update_columns_visibility(api, items_table_settings[tab_id]); } if ( drawcallback ) { drawcallback(this); } -- 2.39.5