Ensure that refreshing a node also updates the Property list. Fixes #3461

This commit is contained in:
Akshay Joshi 2018-08-13 13:47:07 +01:00 committed by Dave Page
parent ffd41009ea
commit 008359ad3a
6 changed files with 103 additions and 30 deletions

View File

@ -16,4 +16,5 @@ Bug fixes
********* *********
| `Bug #3407 <https://redmine.postgresql.org/issues/3407>`_ - Fix keyboard shortcuts layout in the preferences panel. | `Bug #3407 <https://redmine.postgresql.org/issues/3407>`_ - Fix keyboard shortcuts layout in the preferences panel.
| `Bug #3461 <https://redmine.postgresql.org/issues/3461>`_ - Ensure that refreshing a node also updates the Property list.
| `Bug #3528 <https://redmine.postgresql.org/issues/3528>`_ - Handle connection errors properly in the query tool. | `Bug #3528 <https://redmine.postgresql.org/issues/3528>`_ - Handle connection errors properly in the query tool.

View File

@ -1494,6 +1494,8 @@ define('pgadmin.browser', [
isOpen, isOpen,
idx = -1; idx = -1;
this.Events.trigger('pgadmin-browser:tree:refreshing', _i, d, n);
if (!n) { if (!n) {
_i = null; _i = null;
ctx.i = null; ctx.i = null;

View File

@ -903,34 +903,6 @@ define('pgadmin.browser.node', [
// is active). // is active).
this.showProperties(item, d, b.panels['properties'].panel); this.showProperties(item, d, b.panels['properties'].panel);
} }
if ('sql' in b.panels &&
b.panels['sql'] &&
b.panels['sql'].panel &&
b.panels['sql'].panel.isVisible()) {
// TODO:: Show reverse engineered query for this object (when 'sql'
// tab is active.)
}
if ('statistics' in b.panels &&
b.panels['statistics'] &&
b.panels['statistics'].panel &&
b.panels['statistics'].panel.isVisible()) {
// TODO:: Show statistics for this object (when the 'statistics'
// tab is active.)
}
if ('dependencies' in b.panels &&
b.panels['dependencies'] &&
b.panels['dependencies'].panel &&
b.panels['dependencies'].panel.isVisible()) {
// TODO:: Show dependencies for this object (when the
// 'dependencies' tab is active.)
}
if ('dependents' in b.panels &&
b.panels['dependents'] &&
b.panels['dependents'].panel &&
b.panels['dependents'].panel.isVisible()) {
// TODO:: Show dependents for this object (when the 'dependents'
// tab is active.)
}
} }
return true; return true;
@ -974,9 +946,17 @@ define('pgadmin.browser.node', [
} }
}, },
refresh: function(cmd, _item) { refresh: function(cmd, _item) {
var self = this,
t = pgBrowser.tree,
data = _item && t.itemData(_item);
$(pgBrowser.panels['properties'].panel).removeData('node-prop');
pgBrowser.Events.trigger( pgBrowser.Events.trigger(
'pgadmin:browser:tree:refresh', _item || pgBrowser.tree.selected() 'pgadmin:browser:tree:refresh', _item || pgBrowser.tree.selected(), {
); success: function() {
self.callbacks.selected.apply(self, [_item, data, pgBrowser]);
},
});
}, },
}, },
/********************************************************************** /**********************************************************************

View File

@ -152,6 +152,7 @@ define('misc.depends', [
// If Dependencies panel exists and is focused then we need to listen the browser tree selection events. // If Dependencies panel exists and is focused then we need to listen the browser tree selection events.
if ((dependenciesPanels[0].isVisible()) || dependenciesPanels.length != 1) { if ((dependenciesPanels[0].isVisible()) || dependenciesPanels.length != 1) {
pgBrowser.Events.on('pgadmin-browser:tree:selected', this.showDependencies); pgBrowser.Events.on('pgadmin-browser:tree:selected', this.showDependencies);
pgBrowser.Events.on('pgadmin-browser:tree:refreshing', this.refreshDependencies, this);
} }
}.bind(this) }.bind(this)
); );
@ -161,6 +162,7 @@ define('misc.depends', [
// If Dependencies panel exists and is focused then we need to listen the browser tree selection events. // If Dependencies panel exists and is focused then we need to listen the browser tree selection events.
if ((dependenciesPanels[0].isVisible()) || dependenciesPanels.length != 1) { if ((dependenciesPanels[0].isVisible()) || dependenciesPanels.length != 1) {
pgBrowser.Events.on('pgadmin-browser:tree:selected', this.showDependencies); pgBrowser.Events.on('pgadmin-browser:tree:selected', this.showDependencies);
pgBrowser.Events.on('pgadmin-browser:tree:refreshing', this.refreshDependencies, this);
} }
} }
@ -174,6 +176,7 @@ define('misc.depends', [
// If Dependents panel exists and is focused then we need to listen the browser tree selection events. // If Dependents panel exists and is focused then we need to listen the browser tree selection events.
if ((dependentsPanels[0].isVisible()) || dependentsPanels.length != 1) { if ((dependentsPanels[0].isVisible()) || dependentsPanels.length != 1) {
pgBrowser.Events.on('pgadmin-browser:tree:selected', this.showDependents); pgBrowser.Events.on('pgadmin-browser:tree:selected', this.showDependents);
pgBrowser.Events.on('pgadmin-browser:tree:refreshing', this.refreshDependents, this);
} }
}.bind(this) }.bind(this)
); );
@ -183,6 +186,7 @@ define('misc.depends', [
// If Dependents panel exists and is focused then we need to listen the browser tree selection events. // If Dependents panel exists and is focused then we need to listen the browser tree selection events.
if ((dependentsPanels[0].isVisible()) || dependentsPanels.length != 1) { if ((dependentsPanels[0].isVisible()) || dependentsPanels.length != 1) {
pgBrowser.Events.on('pgadmin-browser:tree:selected', this.showDependents); pgBrowser.Events.on('pgadmin-browser:tree:selected', this.showDependents);
pgBrowser.Events.on('pgadmin-browser:tree:refreshing', this.refreshDependents, this);
} }
} }
}, },
@ -297,6 +301,19 @@ define('misc.depends', [
$msgContainer.text(msg); $msgContainer.text(msg);
} }
}, },
refreshDependents: function(item, data, node) {
var that = this,
cache_flag = {
node_type: data._type,
url: node.generate_url(item, 'dependent', data, true),
};
if (_.isEqual($(that.dependentsPanels[0]).data('node-prop'), cache_flag)) {
// Reset the current item selection
$(that.dependentsPanels[0]).data('node-prop', '');
that.showDependents(item, data, node);
}
},
showDependents: function(item, data, node) { showDependents: function(item, data, node) {
/** /**
* We can't start fetching the Dependents immediately, it is possible the user * We can't start fetching the Dependents immediately, it is possible the user
@ -333,10 +350,25 @@ define('misc.depends', [
// We will start listening the tree selection event. // We will start listening the tree selection event.
pgBrowser.Events.on('pgadmin-browser:tree:selected', pgBrowser.ShowNodeDepends.showDependents); pgBrowser.Events.on('pgadmin-browser:tree:selected', pgBrowser.ShowNodeDepends.showDependents);
pgBrowser.Events.on('pgadmin-browser:tree:refreshing', pgBrowser.ShowNodeDepends.refreshDependents, this);
} else { } else {
// We don't need to listen the tree item selection event. // We don't need to listen the tree item selection event.
pgBrowser.Events.off('pgadmin-browser:tree:selected', pgBrowser.ShowNodeDepends.showDependents); pgBrowser.Events.off('pgadmin-browser:tree:selected', pgBrowser.ShowNodeDepends.showDependents);
pgBrowser.Events.off('pgadmin-browser:tree:refreshing', pgBrowser.ShowNodeDepends.refreshDependents, this);
}
},
refreshDependencies: function(item, data, node) {
var that = this,
cache_flag = {
node_type: data._type,
url: node.generate_url(item, 'dependency', data, true),
};
if (_.isEqual($(that.dependenciesPanels[0]).data('node-prop'), cache_flag)) {
// Reset the current item selection
$(that.dependenciesPanels[0]).data('node-prop', '');
that.showDependencies(item, data, node);
} }
}, },
showDependencies: function(item, data, node) { showDependencies: function(item, data, node) {
@ -377,9 +409,11 @@ define('misc.depends', [
// We will start listening the tree selection event. // We will start listening the tree selection event.
pgBrowser.Events.on('pgadmin-browser:tree:selected', pgBrowser.ShowNodeDepends.showDependencies); pgBrowser.Events.on('pgadmin-browser:tree:selected', pgBrowser.ShowNodeDepends.showDependencies);
pgBrowser.Events.on('pgadmin-browser:tree:refreshing', pgBrowser.ShowNodeDepends.refreshDependencies, this);
} else { } else {
// We don't need to listen the tree item selection event. // We don't need to listen the tree item selection event.
pgBrowser.Events.off('pgadmin-browser:tree:selected', pgBrowser.ShowNodeDepends.showDependencies); pgBrowser.Events.off('pgadmin-browser:tree:selected', pgBrowser.ShowNodeDepends.showDependencies);
pgBrowser.Events.off('pgadmin-browser:tree:refreshing', pgBrowser.ShowNodeDepends.refreshDependencies, this);
} }
}, },
}); });

View File

@ -48,15 +48,34 @@ define('misc.sql', [
pgBrowser.Events.on( pgBrowser.Events.on(
'pgadmin-browser:tree:selected', this.showSQL 'pgadmin-browser:tree:selected', this.showSQL
); );
pgBrowser.Events.on(
'pgadmin-browser:tree:refreshing', this.refreshSQL, this
);
} }
}.bind(this) }.bind(this)
); );
} else { } else {
if ((sqlPanels[0].isVisible()) || sqlPanels.length != 1) { if ((sqlPanels[0].isVisible()) || sqlPanels.length != 1) {
pgBrowser.Events.on('pgadmin-browser:tree:selected', this.showSQL); pgBrowser.Events.on('pgadmin-browser:tree:selected', this.showSQL);
pgBrowser.Events.on(
'pgadmin-browser:tree:refreshing', this.refreshSQL, this
);
} }
} }
}, },
refreshSQL: function(item, data, node) {
var that = this,
cache_flag = {
node_type: data._type,
url: node.generate_url(item, 'sql', data, true),
};
if (_.isEqual($(that.sqlPanels[0]).data('node-prop'), cache_flag)) {
// Reset the current item selection
$(that.sqlPanels[0]).data('node-prop', '');
that.showSQL(item, data, node);
}
},
showSQL: function(item, data, node) { showSQL: function(item, data, node) {
/** /**
* We can't start fetching the SQL immediately, it is possible - the user * We can't start fetching the SQL immediately, it is possible - the user
@ -149,9 +168,15 @@ define('misc.sql', [
// We will start listening the tree selection event. // We will start listening the tree selection event.
pgBrowser.Events.on('pgadmin-browser:tree:selected', pgBrowser.ShowNodeSQL.showSQL); pgBrowser.Events.on('pgadmin-browser:tree:selected', pgBrowser.ShowNodeSQL.showSQL);
pgBrowser.Events.on(
'pgadmin-browser:tree:refreshing', pgBrowser.ShowNodeSQL.refreshSQL, this
);
} else { } else {
// We don't need to listen the tree item selection event. // We don't need to listen the tree item selection event.
pgBrowser.Events.off('pgadmin-browser:tree:selected', pgBrowser.ShowNodeSQL.showSQL); pgBrowser.Events.off('pgadmin-browser:tree:selected', pgBrowser.ShowNodeSQL.showSQL);
pgBrowser.Events.off(
'pgadmin-browser:tree:refreshing', pgBrowser.ShowNodeSQL.refreshSQL, this
);
} }
}, },
}); });

View File

@ -164,6 +164,9 @@ define('misc.statistics', [
pgBrowser.Events.on( pgBrowser.Events.on(
'pgadmin-browser:tree:selected', this.showStatistics 'pgadmin-browser:tree:selected', this.showStatistics
); );
pgBrowser.Events.on(
'pgadmin-browser:tree:refreshing', this.refreshStatistics, this
);
} }
}.bind(this) }.bind(this)
); );
@ -173,12 +176,18 @@ define('misc.statistics', [
pgBrowser.Events.on( pgBrowser.Events.on(
'pgadmin-browser:tree:selected', this.showStatistics 'pgadmin-browser:tree:selected', this.showStatistics
); );
pgBrowser.Events.on(
'pgadmin-browser:tree:refreshing', this.refreshStatistics, this
);
} }
} }
if (self.panel.length > 0 && self.panel[0].isVisible()) { if (self.panel.length > 0 && self.panel[0].isVisible()) {
pgBrowser.Events.on( pgBrowser.Events.on(
'pgadmin-browser:tree:selected', this.showStatistics 'pgadmin-browser:tree:selected', this.showStatistics
); );
pgBrowser.Events.on(
'pgadmin-browser:tree:refreshing', this.refreshStatistics, this
);
} }
}, },
@ -300,7 +309,19 @@ define('misc.statistics', [
$msgContainer.text(msg); $msgContainer.text(msg);
} }
}, },
refreshStatistics: function(item, data, node) {
var that = this,
cache_flag = {
node_type: data._type,
url: node.generate_url(item, 'stats', data, true),
};
if (_.isEqual($(that.panel[0]).data('node-prop'), cache_flag)) {
// Reset the current item selection
$(that.panel[0]).data('node-prop', '');
that.showStatistics(item, data, node);
}
},
showStatistics: function(item, data, node) { showStatistics: function(item, data, node) {
var self = this; var self = this;
if (!node) { if (!node) {
@ -395,12 +416,22 @@ define('misc.statistics', [
'pgadmin-browser:tree:selected', 'pgadmin-browser:tree:selected',
pgBrowser.NodeStatistics.showStatistics pgBrowser.NodeStatistics.showStatistics
); );
pgBrowser.Events.on(
'pgadmin-browser:tree:refreshing',
pgBrowser.NodeStatistics.refreshStatistics,
this
);
} else { } else {
// We don't need to listen the tree item selection event. // We don't need to listen the tree item selection event.
pgBrowser.Events.off( pgBrowser.Events.off(
'pgadmin-browser:tree:selected', 'pgadmin-browser:tree:selected',
pgBrowser.NodeStatistics.showStatistics pgBrowser.NodeStatistics.showStatistics
); );
pgBrowser.Events.off(
'pgadmin-browser:tree:refreshing',
pgBrowser.NodeStatistics.refreshStatistics,
this
);
} }
}, },
}); });