Bugzilla – Attachment 182353 Details for
Bug 39888
Error on acquisitions home when no budgets are defined
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39888: Prevent load of superflous JS when table is not present
Bug-39888-Prevent-load-of-superflous-JS-when-table.patch (text/plain), 7.83 KB, created by
Jonathan Druart
on 2025-05-13 11:03:25 UTC
(
hide
)
Description:
Bug 39888: Prevent load of superflous JS when table is not present
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2025-05-13 11:03:25 UTC
Size:
7.83 KB
patch
obsolete
>From a9b551a5cdb6b85a1ca62b0fbbae4f3d41ace0f6 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@openfifth.co.uk> >Date: Tue, 13 May 2025 11:36:12 +0100 >Subject: [PATCH] Bug 39888: Prevent load of superflous JS when table is not > present > >We shouldn't attempt to load the JS block for dealing with the budgets >table if there is no budgets defined and thus no budgets table. > >Test plan >1) Remove all budgets >2) Load acqui-home.pl and note an error in the browser console >3) Apply the patch >4) Reload acqui-home.pl and note the errors have gone > >Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> > >Amended-by: Jonathan Druart >Tidy > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > .../prog/en/modules/acqui/acqui-home.tt | 136 +++++++++--------- > 1 file changed, 69 insertions(+), 67 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt >index ecdefbb0a4c..1951395a132 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt >@@ -206,81 +206,83 @@ > [% INCLUDE 'datatables.inc' %] > [% Asset.js("lib/jquery/plugins/treetable/jquery.treetable.js") | $raw %] > [% Asset.js("js/acquisitions-menu.js") | $raw %] >- <script> >- dt_overwrite_html_sorting_localeCompare(); >+ [% IF loop_budget %] >+ <script> >+ dt_overwrite_html_sorting_localeCompare(); > >- $(document).ready(function() { >- var table_settings = [% TablesSettings.GetTableSettings( 'acqui', 'acq_acqui-home', 'accounts', 'json' ) | $raw %]; >- var oTable = $("#accounts").kohaTable({ >- "drawCallback": function ( oSettings ) { >- if ( oSettings.aiDisplay.length == 0 ) >- { >- return; >- } >+ $(document).ready(function() { >+ var table_settings = [% TablesSettings.GetTableSettings( 'acqui', 'acq_acqui-home', 'accounts', 'json' ) | $raw %]; >+ var oTable = $("#accounts").kohaTable({ >+ "drawCallback": function ( oSettings ) { >+ if ( oSettings.aiDisplay.length == 0 ) >+ { >+ return; >+ } > >- var nTrs = $('#accounts tbody tr'); >- var iColspan = nTrs[0].getElementsByTagName('td').length; >- var sLastGroup = ""; >- for ( var i=0 ; i<nTrs.length ; i++ ) >- { >- var iDisplayIndex = oSettings._iDisplayStart + i; >- var sGroup = oSettings.aoData[ oSettings.aiDisplay[iDisplayIndex] ]._aData[1]; >- if ( sGroup != sLastGroup ) >+ var nTrs = $('#accounts tbody tr'); >+ var iColspan = nTrs[0].getElementsByTagName('td').length; >+ var sLastGroup = ""; >+ for ( var i=0 ; i<nTrs.length ; i++ ) > { >- var nGroup = document.createElement( 'tr' ); >- var nCell = document.createElement( 'td' ); >- nCell.colSpan = iColspan; >- nCell.className = "group"; >- nCell.innerHTML = sGroup; >- nGroup.appendChild( nCell ); >- nTrs[i].parentNode.insertBefore( nGroup, nTrs[i] ); >- sLastGroup = sGroup; >+ var iDisplayIndex = oSettings._iDisplayStart + i; >+ var sGroup = oSettings.aoData[ oSettings.aiDisplay[iDisplayIndex] ]._aData[1]; >+ if ( sGroup != sLastGroup ) >+ { >+ var nGroup = document.createElement( 'tr' ); >+ var nCell = document.createElement( 'td' ); >+ nCell.colSpan = iColspan; >+ nCell.className = "group"; >+ nCell.innerHTML = sGroup; >+ nGroup.appendChild( nCell ); >+ nTrs[i].parentNode.insertBefore( nGroup, nTrs[i] ); >+ sLastGroup = sGroup; >+ } > } >- } >- }, >- "footerCallback": function ( row, data, start, end, display ) { >- var api = this.api(), data; >- footer_column_sum( api, [ 6, 7, 8, 9 ] ); >- }, >- "columnDefs": [ >- { "orderable": false, "targets": ["_all"] } >- ], >- "ordering": true, >- "orderFixed": [[ 1, 'asc' ]], >- "paginate": false, >- "autoWidth": false >- }, table_settings ); >- let table_dt = oTable.DataTable(); >+ }, >+ "footerCallback": function ( row, data, start, end, display ) { >+ var api = this.api(), data; >+ footer_column_sum( api, [ 6, 7, 8, 9 ] ); >+ }, >+ "columnDefs": [ >+ { "orderable": false, "targets": ["_all"] } >+ ], >+ "ordering": true, >+ "orderFixed": [[ 1, 'asc' ]], >+ "paginate": false, >+ "autoWidth": false >+ }, table_settings ); >+ let table_dt = oTable.DataTable(); > >- $(oTable).treetable({ >- expandable: true >- }); >- $(oTable).treetable('expandAll'); >- $("#expand_all").click(function(e){ >- e.preventDefault(); >+ $(oTable).treetable({ >+ expandable: true >+ }); > $(oTable).treetable('expandAll'); >- }); >- $("#collapse_all").click(function(e){ >- e.preventDefault(); >- $(oTable).treetable('collapseAll'); >- }); >+ $("#expand_all").click(function(e){ >+ e.preventDefault(); >+ $(oTable).treetable('expandAll'); >+ }); >+ $("#collapse_all").click(function(e){ >+ e.preventDefault(); >+ $(oTable).treetable('collapseAll'); >+ }); > >- $("#hide_inactive").click(function(e){ >- e.preventDefault(); >- table_dt.columns(0).search(1).draw(); // Show only active=1 >- }); >- $("#show_inactive").click(function(e){ >- e.preventDefault(); >- table_dt.columns(0).search("").draw(); >- }); >- $("#hide_inactive").click(); >+ $("#hide_inactive").click(function(e){ >+ e.preventDefault(); >+ table_dt.columns(0).search(1).draw(); // Show only active=1 >+ }); >+ $("#show_inactive").click(function(e){ >+ e.preventDefault(); >+ table_dt.columns(0).search("").draw(); >+ }); >+ $("#hide_inactive").click(); > >- $("#library-filter").change(function(){ >- $("#accounts").DataTable().search(this.value); >- $("#accounts").DataTable().draw(); >- }); >+ $("#library-filter").change(function(){ >+ $("#accounts").DataTable().search(this.value); >+ $("#accounts").DataTable().draw(); >+ }); > >- }); >- </script> >+ }); >+ </script> >+ [% END %] > [% END %] > [% 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 39888
:
182352
| 182353