From 781fdb09af2774d924e7da8f9657f6d540b25dea Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 13 Apr 2023 15:26:35 +0200 Subject: [PATCH] Bug 33568: Hide empty columns MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Instead of relying on the existence of data in at least one item we are going to hide empty columns. That could be confusing: it does not mean items on another page do not have data for this column. The user can still display the column using the "Columns" visibility button, and filter on the column. I think this is an acceptable behaviour. Signed-off-by: Owen Leonard Signed-off-by: Laurence Rault Signed-off-by: Emily Lamancusa Signed-off-by: Tomás Cohen Arazi Signed-off-by: Katrin Fischer --- .../prog/en/modules/catalogue/detail.tt | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt index e605c8e12b..4724493e0b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -707,7 +707,7 @@ [% IF ( item_level_itypes ) %]Item type[% END %] Current library Home library - [% IF ( itemdata_ccode ) %]Collection[% END %] + Collection [% IF Koha.Preference('EnableItemGroups') %] Item group [% END %] @@ -2238,10 +2238,6 @@ }); - function columnsInit(table) { - activate_filters(table.id, false); - } - [% IF found1 && Koha.Preference('RetainCatalogSearchTerms') %] $(document).ready(function() { var search_index = localStorage.getItem("cat_search_pulldown_selection"); @@ -2499,6 +2495,7 @@ [% IF Koha.Preference('LocalCoverImages') %] embed.push('cover_image_ids'); [% END %] + let table_settings = [% TablesSettings.GetTableSettings('catalogue', 'detail','holdings_table','json') | $raw %]; var items_table = $("#table_items").kohaTable({ ajax: { url: table_url }, order: [[ 0, "asc" ]], @@ -2583,7 +2580,6 @@ } // FIXME Display the shelving location }, - [% IF ( itemdata_ccode ) %] { data: "me.collection_code", searchable: true, @@ -2592,7 +2588,6 @@ return row._strings.collection_code.str; } }, - [% END %] [% IF Koha.Preference('EnableItemGroups') %] { data: "", @@ -2806,6 +2801,22 @@ } [% END %] ], + initComplete: function( settings, json ){ + let table = settings.oInstance.api(); + table.columns().every(function(i){ + let is_empty = true; + let nodes = this.nodes(); + nodes.each((td, ii) => { + if ( $(td).html() !== '' ) { + is_empty = false; + return; + } + }); + if ( is_empty ) { + table.columns(i).visible(false); + } + }); + }, }); [% CoverImagePlugins | $raw %] -- 2.39.5