Bug 26098: Fix JS error on the fund list view when no fund displayed

TypeError: this.data(...) is undefined
in jquery.treetable.js

Test plan:
Go to the fund list view
Select a filter that will return no result
=> With this patch applied there is no JS error in the console

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Jonathan Druart 2020-07-30 10:51:26 +02:00
parent 1ae7efa3bb
commit b6cb3c2ba5

View file

@ -620,73 +620,75 @@
//<![CDATA[
//
$(document).ready(function() {
var oTable = $("#budgeth").dataTable($.extend(true, {}, dataTablesDefaults, {
"fnDrawCallback": function ( oSettings ) {
if ( oSettings.aiDisplay.length == 0 )
{
return;
}
var nTrs = $('#budgeth 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 )
[% IF budgets %]
var oTable = $("#budgeth").dataTable($.extend(true, {}, dataTablesDefaults, {
"fnDrawCallback": 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, [ 4, 6, 8, 10 ], 2 );
},
"aoColumnDefs": [
{ "bVisible": false, "aTargets": [ 0, 1 ] },
{ "bSortable": false, "aTargets": ["_all"] }
],
'dom': '<"top pager"ilpf>tr<"bottom pager"ip>',
'bSort': true,
'aaSortingFixed': [[ 1, 'asc' ]],
'bPaginate': false,
"bAutoWidth": false
}));
$(oTable).treetable({
expandable: true
});
$(oTable).treetable('expandAll');
$("#expand_all").click(function(e){
e.preventDefault();
var nTrs = $('#budgeth 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, [ 4, 6, 8, 10 ], 2 );
},
"aoColumnDefs": [
{ "bVisible": false, "aTargets": [ 0, 1 ] },
{ "bSortable": false, "aTargets": ["_all"] }
],
'dom': '<"top pager"ilpf>tr<"bottom pager"ip>',
'bSort': true,
'aaSortingFixed': [[ 1, 'asc' ]],
'bPaginate': false,
"bAutoWidth": false
}));
$(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');
});
[% UNLESS budget_period_id %]
$("#hide_inactive").click(function(e){
e.preventDefault();
oTable.fnFilter( 1, 0 ); // Show only active=1
});
$("#show_inactive").click(function(e){
e.preventDefault();
oTable.fnFilter( '', 0 );
});
$("#hide_inactive").click();
[% UNLESS budget_period_id %]
$("#hide_inactive").click(function(e){
e.preventDefault();
oTable.fnFilter( 1, 0 ); // Show only active=1
});
$("#show_inactive").click(function(e){
e.preventDefault();
oTable.fnFilter( '', 0 );
});
$("#hide_inactive").click();
[% END %]
oTable.fnAddFilters("filter", 750);
[% END %]
oTable.fnAddFilters("filter", 750);
$("#filterbutton").click(function() {
$("#fundfilters").slideToggle(0);