Merge branch 'ent-6629-Tree-view-contador-de-grupos' into 'develop'

fix counter groups child

See merge request artica/pandorafms!3578
This commit is contained in:
Daniel Rodriguez 2020-10-30 13:23:47 +01:00
commit 0a3c001127
1 changed files with 29 additions and 5 deletions

View File

@ -12,6 +12,8 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
/*global $, _*/
var TreeController = {
controllers: [],
getController: function() {
@ -38,12 +40,35 @@ var TreeController = {
return;
}
function _recursiveGroupsCount(elements, childGroupsLength) {
if (typeof childGroupsLength === "undefined") {
childGroupsLength = 0;
}
_.each(elements, function(element) {
if (typeof element.children !== "undefined") {
childGroupsLength = _recursiveGroupsCount(
element.children,
childGroupsLength
);
childGroupsLength += element.children.length;
}
});
return childGroupsLength;
}
// Load branch
function _processGroup(container, elements, rootGroup) {
var $group = $("<ul></ul>");
var childGroupsLength = _recursiveGroupsCount(elements);
// First group
// First group.
if (typeof rootGroup != "undefined" && rootGroup == true) {
var messageLength = controller.tree.length;
if (childGroupsLength > 0) {
messageLength = childGroupsLength + controller.tree.length;
}
$group
.addClass("tree-root")
.hide()
@ -54,13 +79,12 @@ var TreeController = {
'images/pandora.png" />' +
"<span class='margin-left-1'>" +
(controller.tree.length > 0
? controller.foundMessage + ": " + controller.tree.length
? controller.foundMessage + ": " + messageLength
: "") +
"</div>"
);
}
// Normal group
else {
} else {
// Normal group.
$group.addClass("tree-group").hide();
}