Fixed error with sorting

This commit is contained in:
Jose Gonzalez 2021-03-08 11:20:50 +01:00
parent 0860b6e647
commit 34b7c1003b

View File

@ -1077,13 +1077,16 @@ var TreeController = {
var rawTree = Object.values(data.tree); var rawTree = Object.values(data.tree);
// Sorting tree by description (services.treeview_services.php). // Sorting tree by description (services.treeview_services.php).
rawTree.sort(function(a, b) { rawTree.sort(function(a, b) {
var x = a.elementDescription.toLowerCase(); // Only the services are ordered since only they have the elementDescription property.
var y = b.elementDescription.toLowerCase(); if (a.elementDescription && b.elementDescription) {
if (x < y) { var x = a.elementDescription.toLowerCase();
return -1; var y = b.elementDescription.toLowerCase();
} if (x < y) {
if (x > y) { return -1;
return 1; }
if (x > y) {
return 1;
}
} }
return 0; return 0;
}); });