From ded7f4252b30c2f940d88fd6eedb783b566059e3 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Wed, 18 May 2022 14:12:11 +0000 Subject: [PATCH] Bug 30747: Make column settings work for otherholdings table using forEach loop To test: 1. Turn on SeparateHoldings and find a record that has some items at different home libraries. 2. Look at the Other holdings(x) tab. Notice there is no Columns tool (gear icon). 3. Go to Table Settings, try hiding columns from the otherholdings table. You cannot. 4. Apply patch. 5. Now under the Other holdings(x) tab you should see the Columns button, it should work. 6. Go back to Table settings and try hiding columns, it should work. 7. Now try uploading an item level cover image, make sure all columns are still properly hidden and the Columns tool works 8. Try steps 6 & 7 but with the regular holdings table. Confirm that all colums can properly hide. --- .../intranet-tmpl/prog/en/modules/catalogue/detail.tt | 11 +++++------ 1 file changed, 5 insertions(+), 6 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 cb6b22e709..ac65310afe 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -1370,10 +1370,9 @@ Note that permanent location is a code, and location may be an authval. var ids = ['holdings_table', 'otherholdings_table']; var table_settings = [ [% TablesSettings.GetTableSettings('catalogue', 'detail','holdings_table','json') | $raw %], [% TablesSettings.GetTableSettings('catalogue', 'detail','otherholdings_table','json') | $raw %] ]; var has_images = ["[% itemloop_has_images | html %]", "[% otheritemloop_has_images | html %]"]; - for (var i in ids) { - var id = ids[i]; - if ( !has_images[i] ) { // remove the cover_image column - table_settings.splice(1,1); + ids.forEach( function(item, index) { + if ( !has_images[index] ) { + table_settings[index].columns.splice(1,1); } var dt_parameters = { 'sDom': 't', @@ -1382,8 +1381,8 @@ Note that permanent location is a code, and location may be an authval. "bKohaColumnsUseNames": true, "sDom": 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>', }; - var table = KohaTable(id, dt_parameters, table_settings[i], 'with_filters'); - } + var table = KohaTable(item, dt_parameters, table_settings[index], 'with_filters'); + }); [% IF Koha.Preference('AcquisitionDetails') %] var table_settings = [% TablesSettings.GetTableSettings('catalogue', 'detail', 'acquisitiondetails-table', 'json') | $raw %]; -- 2.30.2