mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-27 07:44:35 +02:00
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:
commit
0a3c001127
@ -12,6 +12,8 @@
|
|||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
/*global $, _*/
|
||||||
|
|
||||||
var TreeController = {
|
var TreeController = {
|
||||||
controllers: [],
|
controllers: [],
|
||||||
getController: function() {
|
getController: function() {
|
||||||
@ -38,12 +40,35 @@ var TreeController = {
|
|||||||
return;
|
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
|
// Load branch
|
||||||
function _processGroup(container, elements, rootGroup) {
|
function _processGroup(container, elements, rootGroup) {
|
||||||
var $group = $("<ul></ul>");
|
var $group = $("<ul></ul>");
|
||||||
|
var childGroupsLength = _recursiveGroupsCount(elements);
|
||||||
|
|
||||||
// First group
|
// First group.
|
||||||
if (typeof rootGroup != "undefined" && rootGroup == true) {
|
if (typeof rootGroup != "undefined" && rootGroup == true) {
|
||||||
|
var messageLength = controller.tree.length;
|
||||||
|
if (childGroupsLength > 0) {
|
||||||
|
messageLength = childGroupsLength + controller.tree.length;
|
||||||
|
}
|
||||||
|
|
||||||
$group
|
$group
|
||||||
.addClass("tree-root")
|
.addClass("tree-root")
|
||||||
.hide()
|
.hide()
|
||||||
@ -54,13 +79,12 @@ var TreeController = {
|
|||||||
'images/pandora.png" />' +
|
'images/pandora.png" />' +
|
||||||
"<span class='margin-left-1'>" +
|
"<span class='margin-left-1'>" +
|
||||||
(controller.tree.length > 0
|
(controller.tree.length > 0
|
||||||
? controller.foundMessage + ": " + controller.tree.length
|
? controller.foundMessage + ": " + messageLength
|
||||||
: "") +
|
: "") +
|
||||||
"</div>"
|
"</div>"
|
||||||
);
|
);
|
||||||
}
|
} else {
|
||||||
// Normal group
|
// Normal group.
|
||||||
else {
|
|
||||||
$group.addClass("tree-group").hide();
|
$group.addClass("tree-group").hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user