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>
This commit is contained in:
parent
49732435e2
commit
efc39ed8ef
|
|
@ -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;
|
||||
}
|
||||
|
||||
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 )
|
||||
$(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 )
|
||||
{
|
||||
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;
|
||||
return;
|
||||
}
|
||||
}
|
||||
},
|
||||
"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();
|
||||
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 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();
|
||||
|
||||
$(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' %]
|
||||
|
|
|
|||
Loading…
Reference in New Issue