Merge branch 'ent-6968-Ordenar-servicios-por-descripcion-tree-view' into 'develop'

Fixed sorting by description

Closes pandora_enterprise#6968

See merge request artica/pandorafms!3825
This commit is contained in:
Daniel Rodriguez 2021-03-09 16:33:12 +00:00
commit 868694ba24
1 changed files with 19 additions and 1 deletions

View File

@ -1073,7 +1073,25 @@ var TreeController = {
$node.append($group);
}
_.each(data.tree, function(element) {
// Get the main values of the tree.
var rawTree = Object.values(data.tree);
// Sorting tree by description (services.treeview_services.php).
rawTree.sort(function(a, b) {
// Only the services are ordered since only they have the elementDescription property.
if (a.elementDescription && b.elementDescription) {
var x = a.elementDescription.toLowerCase();
var y = b.elementDescription.toLowerCase();
if (x < y) {
return -1;
}
if (x > y) {
return 1;
}
}
return 0;
});
_.each(rawTree, function(element) {
element.jqObject = _processNode($group, element);
});