Bug 40127: Move build_items_table outside of document.ready

So it's not delayed and we catch have the error in the Cypress test.
Otherwise the error appear too late (in the after each) and the test
does not fail

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 2d1c6b8666)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
(cherry picked from commit 7c33240af2)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Jonathan Druart 2025-06-12 09:54:16 +02:00 committed by Fridolin Somers
parent 39aa9c13ce
commit 80da7586dc
No known key found for this signature in database
GPG Key ID: 9A8E73E2A8B96537
1 changed files with 43 additions and 42 deletions

View File

@ -1218,6 +1218,11 @@
[% Asset.js("js/recalls.js") | $raw %]
[% Asset.js("js/coce.js") | $raw %]
[% Asset.js("lib/Chocolat/js/chocolat.js") | $raw %]
[%# The following PROCESS needs: %]
[%# can_edit_items_from item_type_image_locations %]
[% PROCESS build_items_table_js biblio => biblio %]
[% IF ( Koha.Preference('CatalogConcerns') ) %]
<script>
/* Set a variable needed by add_catalog_concern.js */
@ -1677,6 +1682,44 @@
var bundle_lost_value = [% Koha.Preference('BundleLostValue') | html %];
[% END %]
let items_tab_ids = [ 'holdings', 'otherholdings' ];
items_tab_ids.forEach( function( tab_id, index ) {
// Early return if the tab is not shown (ie. no table)
if (!$("#%s-tab".format(tab_id)).length) return;
[% IF Koha.Preference('AlwaysShowHoldingsTableFilters') %]
build_items_table(tab_id, true, {}, build_items_table_drawncallback);
[% ELSE %]
build_items_table(tab_id, false, {}, build_items_table_drawncallback);
[% END %]
[% IF bundlesEnabled %]
// Add event listener for opening and closing bundle details
$('#' + tab_id + '_table tbody').on('click', 'button.details-control', function () {
var button = $(this);
var tr = button.closest('tr');
var dTable = button.closest('table').DataTable({ 'retrieve': true });
let row = dTable.row( tr );
let data = row.data();
let itemnumber = data.item_id;
let duedate = (data.checkout&&data.checkout.due_date) || null;
if ( row.child.isShown() ) {
// This row is already open - close it
row.child.hide();
tr.removeClass('shown');
button.removeClass('active');
} else {
// Open this row
createChild(row, itemnumber, duedate);
tr.addClass('shown');
button.addClass('active');
}
});
[% END # /IF bundlesEnabled %]
});
$(document).ready(function() {
[% IF bundlesEnabled %] // Bundle handling
function createChild ( row, itemnumber, duedate ) {
@ -1982,44 +2025,6 @@
// End bundle handling
[% END # /IF bundlesEnabled %]
let items_tab_ids = [ 'holdings', 'otherholdings' ];
items_tab_ids.forEach( function( tab_id, index ) {
// Early return if the tab is not shown (ie. no table)
if (!$("#%s-tab".format(tab_id)).length) return;
[% IF Koha.Preference('AlwaysShowHoldingsTableFilters') %]
build_items_table(tab_id, true, {}, build_items_table_drawncallback);
[% ELSE %]
build_items_table(tab_id, false, {}, build_items_table_drawncallback);
[% END %]
[% IF bundlesEnabled %]
// Add event listener for opening and closing bundle details
$('#' + tab_id + '_table tbody').on('click', 'button.details-control', function () {
var button = $(this);
var tr = button.closest('tr');
var dTable = button.closest('table').DataTable({ 'retrieve': true });
let row = dTable.row( tr );
let data = row.data();
let itemnumber = data.item_id;
let duedate = (data.checkout&&data.checkout.due_date) || null;
if ( row.child.isShown() ) {
// This row is already open - close it
row.child.hide();
tr.removeClass('shown');
button.removeClass('active');
} else {
// Open this row
createChild(row, itemnumber, duedate);
tr.addClass('shown');
button.addClass('active');
}
});
[% END # /IF bundlesEnabled %]
});
[% IF Koha.Preference('AcquisitionDetails') %]
var table_settings = [% TablesSettings.GetTableSettings('catalogue', 'detail', 'acquisitiondetails-table', 'json') | $raw %];
var acquisitiondetails_table = KohaTable("orders", {
@ -2306,10 +2311,6 @@
</script>
[%# The following PROCESS needs: %]
[%# can_edit_items_from item_type_image_locations %]
[% PROCESS build_items_table_js biblio => biblio %]
[% CoverImagePlugins | $raw %]
[% END # /jsinclude %]
[% INCLUDE 'intranet-bottom.inc' %]