Initialize and parse the neseted schema too.

Renamed the type of the nested schema type to 'nested' from 'uiLayout'
to be more relatevant.
This commit is contained in:
Ashesh Vashi
2016-01-19 17:53:33 +05:30
parent 7c9347873f
commit 0cea682e88
2 changed files with 136 additions and 111 deletions

View File

@@ -13,8 +13,9 @@ function(_, pgAdmin, $, Backbone) {
self.tnode = _.extend({}, res.node);
delete res.node;
}
if (self.schema && _.isArray(self.schema)) {
_.each(self.schema, function(s) {
var objectOp = function(schema) {
if (schema && _.isArray(schema)) {
_.each(schema, function(s) {
var obj, val;
switch(s.type) {
case 'collection':
@@ -72,12 +73,20 @@ function(_, pgAdmin, $, Backbone) {
obj = null;
}
res[s.id] = obj;
break;
case 'nested':
objectOp(s.schema);
break;
default:
break;
}
});
}
};
objectOp(self.schema);
return res;
},
primary_key: function() {
@@ -113,11 +122,14 @@ function(_, pgAdmin, $, Backbone) {
self.errorModel = new Backbone.Model();
self.node_info = options.node_info;
if (self.schema && _.isArray(self.schema)) {
_.each(self.schema, function(s) {
var obj = self.get(s.id);
var obj;
var objectOp = function(schema) {
if (schema && _.isArray(schema)) {
_.each(schema, function(s) {
switch(s.type) {
case 'collection':
obj = self.get(s.id)
if (!obj || !(obj instanceof pgBrowser.Node.Collection)) {
if (_.isString(s.model) &&
s.model in pgBrowser.Nodes) {
@@ -137,8 +149,14 @@ function(_, pgAdmin, $, Backbone) {
});
}
}
obj.name = s.id;
self.objects.push(s.id);
self.set(s.id, obj, {silent: true});
break;
case 'model':
obj = self.get(s.id)
if (!obj || !(obj instanceof Backbone.Model)) {
if (_.isString(s.model) &&
s.model in pgBrowser.Nodes[s.model]) {
@@ -154,15 +172,22 @@ function(_, pgAdmin, $, Backbone) {
});
}
}
obj.name = s.id;
self.objects.push(s.id);
self.set(s.id, obj, {silent: true});
break;
case 'nested':
objectOp(s.schema);
break;
default:
return;
}
obj.name = s.id;
self.objects.push(s.id);
self.set(s.id, obj, {silent: true});
});
}
};
objectOp(self.schema);
if (self.handler && self.handler.trackChanges) {
self.startNewSession();

View File

@@ -1315,7 +1315,7 @@
// utilizing it later.
groups[group].push(o);
if (s.type == 'uiLayout') {
if (s.type == 'nested') {
delete o.name;
delete o.cell;