Keep all the information in the tree node data in the

getTreeNodeHierarchy(..) function, and make changes to make the
generate_url function to work with it.
This commit is contained in:
Ashesh Vashi
2015-12-26 14:22:19 +05:30
parent 15daf44e19
commit 402e89e535
2 changed files with 19 additions and 7 deletions

View File

@@ -118,7 +118,7 @@ function($, _, S, pgAdmin, Backbone, Alertify, Backform) {
function(o) { return o.priority; } function(o) { return o.priority; }
), ),
function(o) { function(o) {
ref = S('%s/%s').sprintf(ref, o.id).value(); ref = S('%s/%s').sprintf(ref, encodeURI(o._id)).value();
}); });
var args = { var args = {

View File

@@ -784,7 +784,7 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, Backform) {
* Supports url generation for create, drop, edit, properties, sql, * Supports url generation for create, drop, edit, properties, sql,
* depends, statistics * depends, statistics
*/ */
generate_url: function(item, type, d, with_id) { generate_url: function(item, type, d, with_id, info) {
var url = pgAdmin.Browser.URL + '{TYPE}/{REDIRECT}{REF}', var url = pgAdmin.Browser.URL + '{TYPE}/{REDIRECT}{REF}',
opURL = { opURL = {
'create': 'obj', 'drop': 'obj', 'edit': 'obj', 'create': 'obj', 'drop': 'obj', 'edit': 'obj',
@@ -796,14 +796,16 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, Backform) {
_.sortBy( _.sortBy(
_.values( _.values(
_.pick( _.pick(
this.getTreeNodeHierarchy(item), function(v, k, o) { ((_.isUndefined(item) || _.isNull(item)) ? info || {} :
this.getTreeNodeHierarchy(item)),
function(v, k, o) {
return (k != self.type); return (k != self.type);
}) })
), ),
function(o) { return o.priority; } function(o) { return o.priority; }
), ),
function(o) { function(o) {
ref = S('%s/%s').sprintf(ref, o.id).value(); ref = S('%s/%s').sprintf(ref, encodeURI(o._id)).value();
}); });
ref = S('%s/%s').sprintf( ref = S('%s/%s').sprintf(
@@ -1262,16 +1264,26 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, Backform) {
do { do {
d = t.itemData(i); d = t.itemData(i);
if (d._type in pgBrowser.Nodes && pgBrowser.Nodes[d._type].hasId) { if (d._type in pgBrowser.Nodes && pgBrowser.Nodes[d._type].hasId) {
res[d._type] = { res[d._type] = _.extend({}, d, {
'id': d._id,
'priority': idx 'priority': idx
}; });
idx -= 1; idx -= 1;
} }
i = t.hasParent(i) ? t.parent(i) : null; i = t.hasParent(i) ? t.parent(i) : null;
} while (i); } while (i);
return res; return res;
},
cache: function(url, data) {
var cached = this.cached = this.cached || {};
if (_.isUndefined(data)) {
return cached[url];
}
cached[url] = {data: data, at: Date()};
return data;
} }
}); });