Append the new node under the collection, when it should be.

pull/3/head
Ashesh Vashi 2016-01-05 02:15:22 +05:30
parent 8cd0fda406
commit faa984debc
1 changed files with 41 additions and 6 deletions

View File

@ -798,6 +798,12 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, Backform) {
if (that.parent_type) {
if (tree.wasLoad(item)) {
var first = tree.first(item, false),
data = first && first.length && tree.itemData(first);
// We found the same type of object here, we can append it
// here.
if (data && data._type == that.type) {
tree.append(item, {
itemData: d,
success: function(i, o) {
@ -805,6 +811,35 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, Backform) {
}
});
} else {
var children = tree.children(item, false, false);
if (children) {
var check = true;
_.each(children, function(child) {
if (!check)
return;
var j = $(child);
data = tree.itemData(j);
if (data && data._type && data._type in pgBrowser.Nodes) {
node = pgBrowser.Nodes[data._type];
if (node && node.node && node.node == that.type) {
check = false;
if (tree.wasLoad(j)) {
tree.append(j, {
itemData: d,
success: function(i, o) {
func(o.items.eq(0));
}
});
}
}
}
});
}
}
/* When no children found, it was loaded.
* It sets the item to non-inode.
*/