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

This commit is contained in:
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() { setTimeout(function() {
obj.editor.setValue('-- ' + select_object_msg);
obj.editor.refresh(); obj.editor.refresh();
}, 10); }, 10);

View File

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

View File

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