Fix on-click handling of treeview nodes that wasn't refreshing SQL/Dependencies/Dependents in some circumstances. Fixes #3058

pull/7/head
Murtuza Zabuawala 2018-02-01 14:44:12 +01:00 committed by Dave Page
parent e0da9c5a0c
commit 6ad44cb51e
3 changed files with 20 additions and 11 deletions

View File

@ -400,6 +400,7 @@ define('pgadmin.browser', [
});
setTimeout(function() {
obj.editor.setValue('-- ' + select_object_msg);
obj.editor.refresh();
}, 10);

View File

@ -194,15 +194,19 @@ define('misc.depends', [
$msgContainer = $container.find('.pg-panel-depends-message'),
$gridContainer = $container.find('.pg-panel-depends-container'),
treeHierarchy = node.getTreeNodeHierarchy(item),
n_type = type;
n_type = type,
cache_flag = {
node_type: n_type,
url: url,
};
// Avoid unnecessary reloads
if (_.isEqual($(panel[0]).data('node-prop'), treeHierarchy)) {
if (_.isEqual($(panel[0]).data('node-prop'), cache_flag)) {
return;
}
// Cache the current IDs for next time
$(panel[0]).data('node-prop', treeHierarchy);
$(panel[0]).data('node-prop', cache_flag);
// Hide the grid container and show the default message container
if (!$gridContainer.hasClass('hidden'))
@ -381,4 +385,4 @@ define('misc.depends', [
});
return pgBrowser.ShowNodeDepends;
});
});

View File

@ -69,24 +69,28 @@ define('misc.sql', [
var that = this;
this.timeout = setTimeout(
function() {
var sql = '';
var sql = '-- ' + gettext('Please select an object in the tree view.');
if (node) {
sql = '-- ' + gettext('No SQL could be generated for the selected object.');
var n_type = data._type,
treeHierarchy = node.getTreeNodeHierarchy(item);
url = node.generate_url(item, 'sql', data, true),
treeHierarchy = node.getTreeNodeHierarchy(item),
cache_flag = {
node_type: n_type,
url: url,
};
// Avoid unnecessary reloads
if (_.isEqual($(that.sqlPanels[0]).data('node-prop'), treeHierarchy)) {
if (_.isEqual($(that.sqlPanels[0]).data('node-prop'), cache_flag)) {
return;
}
// Cache the current IDs for next time
$(that.sqlPanels[0]).data('node-prop', treeHierarchy);
$(that.sqlPanels[0]).data('node-prop', cache_flag);
if (node.hasSQL) {
sql = '';
var url = node.generate_url(item, 'sql', data, true),
timer;
var timer;
$.ajax({
url: url,
@ -153,4 +157,4 @@ define('misc.sql', [
});
return pgBrowser.ShowNodeSQL;
});
});