Bug 30747: Make column settings work for otherholdings table using forEach loop
[koha-ffzg.git] / koha-tmpl / intranet-tmpl / prog / en / modules / catalogue / detail.tt
index 3204085..9578826 100644 (file)
@@ -708,7 +708,8 @@ Note that permanent location is a code, and location may be an authval.
         [% IF ComponentParts.size == Koha.Preference('MaxComponentRecords')%]
         <p>Only [% ComponentParts.size | html %] results are shown: <a href="/cgi-bin/koha/catalogue/search.pl?q=[% ComponentPartsQuery | uri %]"/>show all component parts</a></p>
         [% END %]
-</div>
+    </div> <!-- /.content_set -->
+</div> <!-- /#components -->
 
 [% END %]
 
@@ -1366,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 columns_settings = [ [% TablesSettings.GetColumns('catalogue', 'detail','holdings_table','json') | $raw %], [% TablesSettings.GetColumns('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
-                    columns_settings.splice(1,1);
+            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 %]" ];
+            table_names.forEach( function( table_name, index ) {
+                if ( !has_images[index] ) {
+                    table_settings[index].columns.splice(1,1);
                 }
                 var dt_parameters = {
                     'sDom': 't',
@@ -1381,17 +1381,17 @@ 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, columns_settings[i], 'with_filters');
-            }
+                var table = KohaTable( table_name, dt_parameters, table_settings[index], 'with_filters' );
+            });
 
             [% IF Koha.Preference('AcquisitionDetails') %]
-                var columns_settings = [% TablesSettings.GetColumns('catalogue', 'detail', 'acquisitiondetails-table', 'json') %];
+                var table_settings = [% TablesSettings.GetTableSettings('catalogue', 'detail', 'acquisitiondetails-table', 'json') | $raw %];
                 var acquisitiondetails_table = KohaTable("orders", {
                     "sDom": 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>',
                     'bPaginate': false,
                     'bAutoWidth': false,
                     "aaSorting": [[ 4, "desc" ]],
-                }, columns_settings);
+                }, table_settings);
             [% END %]
 
             [% IF suggestions.count %]