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>
This commit is contained in:
Jonathan Druart 2025-06-12 09:54:16 +02:00 committed by Paul Derscheid
parent 5df53a1ac9
commit 7c33240af2
No known key found for this signature in database
GPG Key ID: C25F9FD44CED595B
1 changed files with 43 additions and 42 deletions

View File

@ -1262,6 +1262,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 */
@ -1725,6 +1730,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 ) {
@ -2036,44 +2079,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 = $("#orders").kohaTable(
@ -2360,10 +2365,6 @@
return confirm( _("Are you sure you want to delete this comment?") );
});
</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' %]