diff --git a/web/pgadmin/browser/templates/browser/js/browser.js b/web/pgadmin/browser/templates/browser/js/browser.js index d2e5dd7..e0abc35 100644 --- a/web/pgadmin/browser/templates/browser/js/browser.js +++ b/web/pgadmin/browser/templates/browser/js/browser.js @@ -60,7 +60,7 @@ function(require, $, _, S, Bootstrap, pgAdmin, Alertify, CodeMirror) { ajaxHook: function(item, settings) { if (item != null) { var d = this.itemData(item); - n = b.Nodes[d._type]; + n = b.Nodes[d._type] || pgAdmin.Browser.Node; if (n) settings.url = n.generate_url(item, 'children', d, true); } diff --git a/web/pgadmin/browser/templates/browser/js/node.js b/web/pgadmin/browser/templates/browser/js/node.js index af016b5..38fa2f8 100644 --- a/web/pgadmin/browser/templates/browser/js/node.js +++ b/web/pgadmin/browser/templates/browser/js/node.js @@ -1386,7 +1386,7 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) { 'properties': 'obj', 'statistics': 'stats' }, ref = '', self = this, - priority = -Infinity; + priority = -Infinity, node_type, node_url_func; info = (_.isUndefined(item) || _.isNull(item)) ? info || {} : this.getTreeNodeHierarchy(item); @@ -1407,8 +1407,21 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) { } }); } + node_type = self.type; + node_url_func = function(o) { + ref = S('%s/%s').sprintf(ref, encodeURIComponent(o._id)).value(); + }; + } else { + priority = 999; + node_type = encodeURI(d._type); + node_url_func = function(o) { + if (o._type != node_type) { + ref = S('%s/%s').sprintf(ref, encodeURIComponent(o._id)).value(); + } + }; } + _.each( _.sortBy( _.values( @@ -1418,17 +1431,15 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) { }) ), function(o) { return o.priority; } - ), - function(o) { - ref = S('%s/%s').sprintf(ref, encodeURIComponent(o._id)).value(); - }); + ), node_url_func + ); ref = S('%s/%s').sprintf( - ref, with_id && d._type == self.type ? encodeURIComponent(d._id) : '' + ref, with_id && d._type == node_type ? encodeURIComponent(d._id) : '' ).value(); var args = { - 'TYPE': self.type, + 'TYPE': node_type, 'REDIRECT': (type in opURL ? opURL[type] : type), 'REF': ref }; @@ -1446,7 +1457,7 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) { res = {}, t = pgBrowser.tree; do { - d = t.itemData(i); + var d = t.itemData(i); if (d._type in pgBrowser.Nodes && pgBrowser.Nodes[d._type].hasId) { res[d._type] = _.extend({}, d, { 'priority': idx