Don't append new objects to the wrong parent, if the correct one isn't loaded. Fixes #1838

This commit is contained in:
Murtuza Zabuawala 2016-10-18 12:37:44 +01:00 committed by Dave Page
parent e31ba5873b
commit b9571df4de
2 changed files with 25 additions and 6 deletions

View File

@ -936,13 +936,25 @@ function(require, $, _, S, Bootstrap, pgAdmin, Alertify, CodeMirror) {
});
} else {
var _append = function() {
var ctx = this;
var ctx = this,
is_parent_loaded_before = ctx.t.wasLoad(ctx.i),
_parent_data = ctx.t.itemData(ctx.i);
ctx.t.append(ctx.i, {
itemData: _data,
success: function(item, options) {
var i = $(options.items[0]);
ctx.t.openPath(i);
ctx.t.select(i);
// Open the item path only if its parent is loaded
// or parent type is same as nodes
if(_parent_data._type.search(_data._type) > -1 ||
is_parent_loaded_before) {
ctx.t.openPath(i);
ctx.t.select(i);
} else {
// Unload the parent node so that we'll get
// latest data when we try to expand it
ctx.t.unload(ctx.i);
}
if (
ctx.o && ctx.o.success &&
typeof(ctx.o.success) == 'function'

View File

@ -170,9 +170,16 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) {
if (itemData.type == 'role' &&
parentData.server.user.can_create_role) {
return true;
} else if (parentData.server.user.is_superuser ||
parentData.server.user.can_create_db ||
(parentData.schema && parentData.schema.can_create)) {
} else if (
(
parentData.server && (
parentData.server.user.is_superuser ||
parentData.server.user.can_create_db)
) ||
(
parentData.schema && parentData.schema.can_create
)
) {
return true;
} else {
return false;