Add an object in an parent properly, which was expanded earlier, and do

not have any child withing it.

Fixes #1481, #1627.
pull/3/head
Ashesh Vashi 2016-09-06 23:18:58 +05:30
parent 679ad6fca8
commit aeaa4bcad1
1 changed files with 33 additions and 24 deletions

View File

@ -40,7 +40,6 @@ function(require, $, _, S, Bootstrap, pgAdmin, Alertify, CodeMirror) {
_.each(data, function(d){ _.each(data, function(d){
d._label = d.label; d._label = d.label;
d.label = _.escape(d.label); d.label = _.escape(d.label);
data._inode = data.inode;
}) })
return data; return data;
}; };
@ -932,25 +931,38 @@ function(require, $, _, S, Bootstrap, pgAdmin, Alertify, CodeMirror) {
} }
}); });
} else { } else {
var _append = function() {
var ctx = this;
ctx.t.append(ctx.i, { ctx.t.append(ctx.i, {
itemData: _data, itemData: _data,
success: function() { success: function(item, options) {
console.log('Appended'); var i = $(options.items[0]);
ctx.t.openPath(i);
ctx.t.select(i);
if ( if (
ctx.o && ctx.o.success && typeof(ctx.o.success) == 'function' ctx.o && ctx.o.success &&
typeof(ctx.o.success) == 'function'
) { ) {
ctx.o.success.apply(ctx.t, [ctx.i, _data]); ctx.o.success.apply(ctx.t, [i, _data]);
} }
}, },
fail: function() { fail: function() {
console.log('Failed to append'); console.log('Failed to append');
if ( if (
ctx.o && ctx.o.fail && typeof(ctx.o.fail) == 'function' ctx.o && ctx.o.fail &&
typeof(ctx.o.fail) == 'function'
) { ) {
ctx.o.fail.apply(ctx.t, [ctx.i, _data]); ctx.o.fail.apply(ctx.t, [ctx.i, _data]);
} }
} }
}); });
}.bind(ctx);
if (!ctx.t.isInode(ctx.i) && ctx.d.inode) {
ctx.t.setInode(ctx.i, {success: _append});
} else {
_append();
}
} }
}.bind(ctx); }.bind(ctx);
@ -992,7 +1004,6 @@ function(require, $, _, S, Bootstrap, pgAdmin, Alertify, CodeMirror) {
} }
_data._label = _data.label; _data._label = _data.label;
_data.label = _.escape(_data.label); _data.label = _.escape(_data.label);
_data._inode = _data.inode;
traversePath(); traversePath();
}, },
@ -1323,7 +1334,6 @@ function(require, $, _, S, Bootstrap, pgAdmin, Alertify, CodeMirror) {
ctx.pI.push(_old); ctx.pI.push(_old);
_new._label = _new.label; _new._label = _new.label;
_new.label = _.escape(_new.label); _new.label = _.escape(_new.label);
_new._inode = _new.inode;
if (_old._pid != _new._pid) { if (_old._pid != _new._pid) {
ctx.op = 'RECREATE'; ctx.op = 'RECREATE';
@ -1400,7 +1410,6 @@ function(require, $, _, S, Bootstrap, pgAdmin, Alertify, CodeMirror) {
data._label = data.label; data._label = data.label;
data.label = _.escape(data.label); data.label = _.escape(data.label);
data._inode = data.inode;
var d = ctx.t.itemData(ctx.i); var d = ctx.t.itemData(ctx.i);
_.extend(d, data); _.extend(d, data);
ctx.t.setLabel(ctx.i, {label: _d.label}); ctx.t.setLabel(ctx.i, {label: _d.label});
@ -1494,7 +1503,7 @@ function(require, $, _, S, Bootstrap, pgAdmin, Alertify, CodeMirror) {
console.log(arguments); console.log(arguments);
} }
}); });
} else if (!this.tree.isInode(_i) && d._inode) { } else if (!this.tree.isInode(_i) && d.inode) {
this.tree.setInode(_i, { this.tree.setInode(_i, {
success: fetchNodeInfo.bind(this, _i, d, n), success: fetchNodeInfo.bind(this, _i, d, n),
fail: function() { fail: function() {