From a098b2f6590ca57321b19e2dbadaae923dba7497 Mon Sep 17 00:00:00 2001 From: Alejandro Gallardo Escobar Date: Wed, 17 Dec 2014 19:46:33 +0100 Subject: [PATCH] Fixes --- .../include/javascript/tree/TreeController.js | 45 ++++++++++--------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/pandora_console/include/javascript/tree/TreeController.js b/pandora_console/include/javascript/tree/TreeController.js index d0a6757273..07e92c1f7b 100644 --- a/pandora_console/include/javascript/tree/TreeController.js +++ b/pandora_console/include/javascript/tree/TreeController.js @@ -28,12 +28,13 @@ TreeController = { ajaxURL: "ajax.php", ajaxPage: "include/ajax/tree.ajax", detailRecipient: '', + filter: {}, reload: function () { // Bad recipient if (typeof this.recipient == 'undefined' || this.recipient.length == 0) { return; } - + // Load branch function _processGroup (container, detailContainer, elements, baseURL, rootGroup) { var $group = $(""); @@ -52,9 +53,9 @@ TreeController = { .addClass("tree-group") .hide(); } - + container.append($group); - + var lastNode; var firstNode; elements.forEach(function(element, index) { @@ -62,7 +63,7 @@ TreeController = { firstNode = rootGroup && index == 0 ? true : false; element.jqObject = _processNode($group, detailContainer, element, lastNode, firstNode); }, $group); - + return $group; } // Load leaf @@ -70,10 +71,10 @@ TreeController = { var $node = $("
  • "); var $leafIcon = $("
    "); var $content = $("
    "); - + // Leaf icon $leafIcon.addClass("leaf-icon"); - + // Content $content.addClass("node-content"); switch (element.type) { @@ -100,28 +101,28 @@ TreeController = { }); }); } - + $node .addClass("tree-node") .append($leafIcon) .append($content); - + if (typeof lastNode != 'undefinded' && lastNode == true) { $node.addClass("tree-last"); } if (typeof firstNode != 'undefinded' && firstNode == true) { $node.addClass("tree-first"); } - + container.append($node); - + if (typeof element.children != 'undefined' && element.children.length > 0) { $node.addClass("leaf-closed"); - + // Add children var $children = _processGroup($node, detailContainer, element.children, this.baseURL); $node.data('children', $children); - + $leafIcon.click(function () { if ($node.hasClass("leaf-open")) { $node @@ -141,7 +142,7 @@ TreeController = { } else if (typeof element.searchChildren != 'undefined' && element.searchChildren) { $node.addClass("leaf-closed"); - + $leafIcon.click(function (e) { e.preventDefault(); @@ -150,7 +151,7 @@ TreeController = { .removeClass("leaf-closed") .removeClass("leaf-error") .addClass("leaf-loading"); - + $.ajax({ url: controller.ajaxURL, type: 'POST', @@ -159,7 +160,8 @@ TreeController = { page: controller.ajaxPage, getChildren: 1, id: element.id, - type: element.type + type: element.type, + filter: controller.filter }, complete: function(xhr, textStatus) { $node.removeClass("leaf-loading"); @@ -171,7 +173,7 @@ TreeController = { var $children = _processGroup($node, detailContainer, data.tree, controller.baseURL); $children.slideDown(); - + $node.data('children', $children); } else { @@ -204,10 +206,10 @@ TreeController = { else { $node.addClass("leaf-empty"); } - + return $node; } - + if (this.recipient.length == 0) { return; } @@ -215,12 +217,12 @@ TreeController = { this.recipient.html("
    " + this.emptyMessage + "
    "); return; } - + this.recipient.empty(); var $children = _processGroup(this.recipient, this.detailContainer, this.tree, this.baseURL, true); $children.show(); - + this.recipient.data('children', $children); }, load: function () { @@ -255,6 +257,9 @@ TreeController = { if (typeof data.ajaxPage != 'undefined' && data.ajaxPage.length > 0) { this.ajaxPage = data.ajaxPage; } + if (typeof data.filter != 'undefined' && data.filter.length > 0) { + this.filter = data.filter; + } this.index = TreeController.controllers.push(this) - 1; this.load();