From f6175adf0c42af95c720eb3b997ff43962c91787 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 8 Oct 2024 15:38:18 +0200 Subject: [PATCH] Bug 38118: Display columns if not empty in drawCallback Instead of updating only when DT init is complete we are going to update the visibility when the table will be redrawn. Test plan: 1 - Find/Add a bib record with no items 2 - Add 20 items from Centerville Edit ->Edit items -> enter CENTER1 into barcode ->'Add multiple copies' -> 20 3 - Add 20 items from Fairview as above but enter 'FAIR1' for barcode and 'FAIR ITEM' as callnumber 4 - Add 1 item from Midway with barcode MIDWAY1 5 - Edit a midway patron to grant 'catalogue' and 'edit_items' permission - NOT edit_any_item 6 - Sign in as the patron above 7 - Find the record 8 - Note there is callnumber and actions/edit columns 9 - Go to page 2 of items - callnumber visible 10 - Go to page 3 - edit column Signed-off-by: Victor Grousset/tuxayo Signed-off-by: Nick Clemens Signed-off-by: Katrin Fischer --- .../tables/items/catalogue_detail.inc | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 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 f0672e86ce..42357360a6 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 @@ -122,6 +122,25 @@ } } + function update_columns_visibility(settings){ + let table = settings.oInstance.api(); + table.columns().visible(true); + 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); + } + }); + } + + $(document).ready(function() { $(".SelectAll").on("click",function(e){ @@ -769,20 +788,6 @@ [% 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); - } - }); itemSelectionBuildActionLinks(tab_id); }, drawCallback: function(settings){ @@ -822,6 +827,8 @@ }); [% END %] + update_columns_visibility(settings); + if ( drawcallback ) { drawcallback(this); } }, ...dt_options, -- 2.39.5