From 7120059745158af08890ba5881090d7337a41fea 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. Signed-off-by: Marcel de Rooy Included a rename to table_name(s). Signed-off-by: Fridolin Somers --- .../prog/en/modules/catalogue/detail.tt | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 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..957882603a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -1367,13 +1367,12 @@ Note that permanent location is a code, and location may be an authval. browser.show(); $(document).ready(function() { - var ids = ['holdings_table', 'otherholdings_table']; + var table_names = [ '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); + var has_images = [ "[% itemloop_has_images | html %]", "[% otheritemloop_has_images | html %]" ]; + table_names.forEach( function( table_name, 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( table_name, dt_parameters, table_settings[index], 'with_filters' ); + }); [% IF Koha.Preference('AcquisitionDetails') %] var table_settings = [% TablesSettings.GetTableSettings('catalogue', 'detail', 'acquisitiondetails-table', 'json') | $raw %]; -- 2.39.5