Minor changes
This commit is contained in:
parent
76cc5d8a96
commit
a045faeb6d
|
@ -13,23 +13,33 @@
|
||||||
// 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.
|
||||||
|
|
||||||
require_once("include/class/Tree.class.php");
|
// Only accesible by ajax
|
||||||
|
if (is_ajax ()) {
|
||||||
|
global $config;
|
||||||
|
|
||||||
$getChildren = (bool)get_parameter('getChildren', 0);
|
// Login check
|
||||||
|
check_login ();
|
||||||
if ($getChildren) {
|
|
||||||
$type = get_parameter('type', 'group');
|
|
||||||
$filter = get_parameter('filter',
|
|
||||||
array('search' => '',
|
|
||||||
'status' => AGENT_STATUS_ALL));
|
|
||||||
$id = (int)get_parameter('id', 0);
|
|
||||||
$method = get_parameter('method', 'on_demand');
|
|
||||||
|
|
||||||
$tree = new Tree($type, $method, $id);
|
require_once("include/class/Tree.class.php");
|
||||||
$tree->setFilter(array(
|
|
||||||
'status' => $filter['status'],
|
$getChildren = (bool)get_parameter('getChildren', 0);
|
||||||
'search' => $filter['search']));
|
|
||||||
echo json_encode(array('success' => 1, 'tree' => $tree->getArray()));
|
if ($getChildren) {
|
||||||
|
$type = get_parameter('type', 'group');
|
||||||
|
$filter = get_parameter('filter',
|
||||||
|
array('search' => '',
|
||||||
|
'status' => AGENT_STATUS_ALL));
|
||||||
|
$id = (int)get_parameter('id', 0);
|
||||||
|
$method = get_parameter('method', 'on_demand');
|
||||||
|
|
||||||
|
$tree = new Tree($type, $method, $id);
|
||||||
|
$tree->setFilter(array(
|
||||||
|
'status' => $filter['status'],
|
||||||
|
'search' => $filter['search']));
|
||||||
|
echo json_encode(array('success' => 1, 'tree' => $tree->getArray()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -116,11 +116,11 @@ TreeController = {
|
||||||
|
|
||||||
container.append($node);
|
container.append($node);
|
||||||
|
|
||||||
if (typeof element.children != 'undefined' && element.children.length > 0) {
|
if (typeof element.tree != 'undefined' && element.tree.length > 0) {
|
||||||
$node.addClass("leaf-closed");
|
$node.addClass("leaf-closed");
|
||||||
|
|
||||||
// Add children
|
// Add children
|
||||||
var $children = _processGroup($node, element.children);
|
var $children = _processGroup($node, element.tree);
|
||||||
$node.data('children', $children);
|
$node.data('children', $children);
|
||||||
|
|
||||||
$leafIcon.click(function () {
|
$leafIcon.click(function () {
|
||||||
|
@ -146,7 +146,7 @@ TreeController = {
|
||||||
$leafIcon.click(function (e) {
|
$leafIcon.click(function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
if (! $node.hasClass("children-loaded")) {
|
if (! $node.hasClass("children-loaded") && ! $node.hasClass("leaf-empty")) {
|
||||||
$node
|
$node
|
||||||
.removeClass("leaf-closed")
|
.removeClass("leaf-closed")
|
||||||
.removeClass("leaf-error")
|
.removeClass("leaf-error")
|
||||||
|
@ -169,12 +169,18 @@ TreeController = {
|
||||||
},
|
},
|
||||||
success: function(data, textStatus, xhr) {
|
success: function(data, textStatus, xhr) {
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
$node.addClass("leaf-open");
|
|
||||||
|
|
||||||
var $children = _processGroup($node, data.tree);
|
if (typeof element.tree != 'undefined' && element.tree.length > 0) {
|
||||||
$children.slideDown();
|
$node.addClass("leaf-open");
|
||||||
|
|
||||||
$node.data('children', $children);
|
var $children = _processGroup($node, data.tree);
|
||||||
|
$children.slideDown();
|
||||||
|
|
||||||
|
$node.data('children', $children);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$node.addClass("leaf-empty");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$node.addClass("leaf-error");
|
$node.addClass("leaf-error");
|
||||||
|
@ -185,7 +191,7 @@ TreeController = {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else if (! $node.hasClass("leaf-empty")) {
|
||||||
if ($node.hasClass("leaf-open")) {
|
if ($node.hasClass("leaf-open")) {
|
||||||
$node
|
$node
|
||||||
.removeClass("leaf-open")
|
.removeClass("leaf-open")
|
||||||
|
|
Loading…
Reference in New Issue