Resolved an issue found generating the URL for some other node from some

other.

i.e.
While fetching the database nodes from the role nodes, it was generating
the wrong URL.

Used the parent_type in each node to identify maximum node URL level
using the priority set in the tree node hearachy information, and
generate URL up to that level only.
pull/3/head
Ashesh Vashi 2016-01-09 19:54:50 +05:30
parent 8f733aabd0
commit 429f585a62
4 changed files with 45 additions and 28 deletions

View File

@ -215,6 +215,7 @@
id: 'name', label:'', type:'text', id: 'name', label:'', type:'text',
url: self.field.get('variable_opts') || 'vopts', url: self.field.get('variable_opts') || 'vopts',
control: Backform.NodeAjaxOptionsControl, control: Backform.NodeAjaxOptionsControl,
cache_level: 'server',
select2: { select2: {
allowClear: false, width: 'style' allowClear: false, width: 'style'
}, },
@ -248,8 +249,8 @@
if (self.hasDatabase) { if (self.hasDatabase) {
headerSchema.push({ headerSchema.push({
id: 'database', label:'', type: 'text', id: 'database', label:'', type: 'text', cache_level: 'server',
control: Backform.NodeListByNameControl, node: 'database' control: Backform.NodeListByNameControl, node: 'database',
}); });
headerDefaults['database'] = null; headerDefaults['database'] = null;
gridCols.push('database'); gridCols.push('database');
@ -257,7 +258,7 @@
if (self.hasRole) { if (self.hasRole) {
headerSchema.push({ headerSchema.push({
id: 'role', label:'', type: 'text', id: 'role', label:'', type: 'text', cache_level: 'server',
control: Backform.NodeListByNameControl, node: 'role' control: Backform.NodeListByNameControl, node: 'role'
}); });
headerDefaults['role'] = null; headerDefaults['role'] = null;

View File

@ -81,7 +81,7 @@ function($, _, pgAdmin, Backbone, Backform, Alertify, Node) {
null, url, this.field.get('node_data'), null, url, this.field.get('node_data'),
this.field.get('url_with_id') || false, node_info this.field.get('url_with_id') || false, node_info
]), ]),
cache_level = this.field.get('cache_level'), cache_level = this.field.get('cache_level') || node.type,
cache_node = this.field.get('cache_node'); cache_node = this.field.get('cache_node');
cache_node = (cache_node && pgAdmin.Browser.Nodes['cache_node']) || node; cache_node = (cache_node && pgAdmin.Browser.Nodes['cache_node']) || node;

View File

@ -972,20 +972,36 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, Backform) {
'create': 'obj', 'drop': 'obj', 'edit': 'obj', 'create': 'obj', 'drop': 'obj', 'edit': 'obj',
'properties': 'obj', 'statistics': 'stats' 'properties': 'obj', 'statistics': 'stats'
}, },
ref = '', self = this; ref = '', self = this,
priority = -Infinity;
info = (_.isUndefined(item) || _.isNull(item)) ?
info || {} : this.getTreeNodeHierarchy(item);
if (self.parent_type) {
if (_.isString(self.parent_type)) {
var p = info[self.parent_type];
if (p) {
priority = p.priority;
}
} else {
_.each(self.parent_type, function(o) {
var p = info[o];
if (p) {
if (priority < p.priority) {
priority = p.priority;
}
}
});
}
}
_.each( _.each(
_.sortBy( _.sortBy(
_.values( _.values(
_.pick( _.pick(info,
((_.isUndefined(item) || _.isNull(item)) ? info || {} :
this.getTreeNodeHierarchy(item)),
function(v, k, o) { function(v, k, o) {
// If you want to make sure, it generates the correct url path, return (v.priority <= priority);
// please define 'parents' properties for this node, which will
// be an list of name of the parents, and grand parents type.
return (k != self.type ||
(self.parents && _.isArray(self.parents) && k in self.parents));
}) })
), ),
function(o) { return o.priority; } function(o) { return o.priority; }
@ -1455,9 +1471,8 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, Backform) {
* transformed to JSON data. * transformed to JSON data.
*/ */
if (session) { if (session) {
res[k] = obj && obj.toJSON( if ((obj.sessChanged && obj.sessChanged()) || isNew) {
!isNew && obj.sessChanged && obj.sessChanged() res[k] = obj && obj.toJSON(!isNew);
);
/* /*
* We will run JSON.stringify(..) only from the main object, * We will run JSON.stringify(..) only from the main object,
* not for the JSON object within the objects, that only when * not for the JSON object within the objects, that only when
@ -1469,6 +1484,7 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, Backform) {
if (obj && method && method == 'GET') { if (obj && method && method == 'GET') {
res[k] = JSON.stringify(res[k]); res[k] = JSON.stringify(res[k]);
} }
}
} else { } else {
res[k] = (obj && obj.toJSON()); res[k] = (obj && obj.toJSON());
} }

View File

@ -191,11 +191,11 @@
} }
.wcInput, input { .wcInput, input {
background-color: #A44; background-color: transparent;
} }
.wcSelect, select { .wcSelect, select {
background-color: #A44; background-color: transparent;
} }
.wcButton, button { .wcButton, button {