Bugzilla – Attachment 183185 Details for
Bug 40127
JS error on biblio detail page when there are no items
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40127: Move build_items_table outside of document.ready
Bug-40127-Move-builditemstable-outside-of-document.patch (text/plain), 5.94 KB, created by
Jonathan Druart
on 2025-06-12 08:07:22 UTC
(
hide
)
Description:
Bug 40127: Move build_items_table outside of document.ready
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2025-06-12 08:07:22 UTC
Size:
5.94 KB
patch
obsolete
>From fbf2cbd92792277a7bd4a1705c5bedde19f46e93 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 12 Jun 2025 09:54:16 +0200 >Subject: [PATCH] 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 >--- > .../prog/en/modules/catalogue/detail.tt | 85 ++++++++++--------- > 1 file changed, 43 insertions(+), 42 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 9135e7ef7d6..398b41d0f2a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >@@ -1260,6 +1260,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 */ >@@ -1723,6 +1728,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 ) { >@@ -2034,44 +2077,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( >@@ -2358,10 +2363,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' %] >-- >2.34.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 40127
:
183185
|
183186
|
183187
|
183188
|
183189
|
183190
|
183228
|
183229
|
183230
|
183283