mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Updated the misc module javascripts to work with latest wcDocker.
This commit is contained in:
parent
18d767b107
commit
000c76871f
@ -25,26 +25,12 @@ define(
|
||||
'showDependencies', 'dependenciesPanelVisibilityChanged', '__updateCollection'
|
||||
);
|
||||
|
||||
// Find the panels to render the grid.
|
||||
var dependenciesPanels = this.dependenciesPanels = pgBrowser.docker.findPanels('dependencies');
|
||||
var dependentsPanels = this.dependentsPanels = pgBrowser.docker.findPanels('dependents');
|
||||
|
||||
// We will listened to the visibility change of the Dependencies and Dependents panel
|
||||
pgBrowser.Events.on('pgadmin-browser:panel-dependencies:' + wcDocker.EVENT.VISIBILITY_CHANGED,
|
||||
this.dependenciesPanelVisibilityChanged);
|
||||
pgBrowser.Events.on('pgadmin-browser:panel-dependents:' + wcDocker.EVENT.VISIBILITY_CHANGED,
|
||||
this.dependentsPanelVisibilityChanged);
|
||||
|
||||
// If Dependencies panel exists and is focused then we need to listen the browser tree selection events.
|
||||
if ((dependenciesPanels.length == 1 && dependenciesPanels[0].isVisible()) || dependenciesPanels.length != 1) {
|
||||
pgBrowser.Events.on('pgadmin-browser:tree:selected', this.showDependencies);
|
||||
}
|
||||
|
||||
// If Dependents panel exists and is focused then we need to listen the browser tree selection events.
|
||||
if ((dependentsPanels.length == 1 && dependentsPanels[0].isVisible()) || dependentsPanels.length != 1) {
|
||||
pgBrowser.Events.on('pgadmin-browser:tree:selected', this.showDependents);
|
||||
}
|
||||
|
||||
// Defining Backbone Model for Dependencies and Dependents.
|
||||
var Model = Backbone.Model.extend({
|
||||
defaults: {
|
||||
@ -85,7 +71,7 @@ define(
|
||||
* panel only once.
|
||||
*/
|
||||
var appendGridToPanel = function(collection, panel, is_dependent) {
|
||||
var $container = panel[0].layout().$table.find('.pg-panel-content'),
|
||||
var $container = panel[0].layout().scene().find('.pg-panel-content'),
|
||||
$gridContainer = $container.find('.pg-panel-depends-container'),
|
||||
grid = new Backgrid.Grid({
|
||||
columns: [
|
||||
@ -127,16 +113,71 @@ define(
|
||||
self.dependenciesGrid = grid;
|
||||
|
||||
$gridContainer.append(grid.render().el);
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
appendGridToPanel(this.dependentCollection, this.dependentsPanels, true);
|
||||
appendGridToPanel(this.dependenciesCollection, this.dependenciesPanels, false);
|
||||
// We will listened to the visibility change of the Dependencies and Dependents panel
|
||||
pgBrowser.Events.on('pgadmin-browser:panel-dependencies:' + wcDocker.EVENT.VISIBILITY_CHANGED,
|
||||
this.dependenciesPanelVisibilityChanged);
|
||||
pgBrowser.Events.on('pgadmin-browser:panel-dependents:' + wcDocker.EVENT.VISIBILITY_CHANGED,
|
||||
this.dependentsPanelVisibilityChanged);
|
||||
|
||||
// We will render the grid objects in the panel after some time, because -
|
||||
// it is possible, it is not yet available.
|
||||
// Find the panels to render the grid.
|
||||
var dependenciesPanels = this.dependenciesPanels = pgBrowser.docker.findPanels('dependencies');
|
||||
var dependentsPanels = this.dependentsPanels = pgBrowser.docker.findPanels('dependents');
|
||||
|
||||
if (dependenciesPanels.length == 0) {
|
||||
pgBrowser.Events.on(
|
||||
'pgadmin-browser:panel-dependencies:' + wcDocker.EVENT.INIT,
|
||||
function() {
|
||||
this.dependenciesPanels = pgBrowser.docker.findPanels('dependencies');
|
||||
appendGridToPanel(this.dependenciesCollection, this.dependenciesPanels, false);
|
||||
|
||||
// If Dependencies panel exists and is focused then we need to listen the browser tree selection events.
|
||||
if ((dependenciesPanels[0].isVisible()) || dependenciesPanels.length != 1) {
|
||||
pgBrowser.Events.on('pgadmin-browser:tree:selected', this.showDependencies);
|
||||
}
|
||||
}.bind(this)
|
||||
);
|
||||
} else {
|
||||
appendGridToPanel(this.dependenciesCollection, this.dependenciesPanels, false);
|
||||
|
||||
// If Dependencies panel exists and is focused then we need to listen the browser tree selection events.
|
||||
if ((dependenciesPanels[0].isVisible()) || dependenciesPanels.length != 1) {
|
||||
pgBrowser.Events.on('pgadmin-browser:tree:selected', this.showDependencies);
|
||||
}
|
||||
}
|
||||
|
||||
if (dependentsPanels.length == 0) {
|
||||
pgBrowser.Events.on(
|
||||
'pgadmin-browser:panel-dependents:' + wcDocker.EVENT.INIT,
|
||||
function() {
|
||||
this.dependentsPanels = pgBrowser.docker.findPanels('dependents');
|
||||
appendGridToPanel(this.dependentCollection, this.dependentsPanels, true);
|
||||
|
||||
// If Dependents panel exists and is focused then we need to listen the browser tree selection events.
|
||||
if ((dependentsPanels[0].isVisible()) || dependentsPanels.length != 1) {
|
||||
pgBrowser.Events.on('pgadmin-browser:tree:selected', this.showDependents);
|
||||
}
|
||||
}.bind(this)
|
||||
);
|
||||
} else {
|
||||
appendGridToPanel(this.dependentCollection, this.dependentsPanels, true);
|
||||
|
||||
// If Dependents panel exists and is focused then we need to listen the browser tree selection events.
|
||||
if ((dependentsPanels[0].isVisible()) || dependentsPanels.length != 1) {
|
||||
pgBrowser.Events.on('pgadmin-browser:tree:selected', this.showDependents);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// Fetch the actual data and update the collection
|
||||
__updateCollection: function(collection, panel, url, messages, node) {
|
||||
var msg = messages[0],
|
||||
$container = panel[0].layout().$table.find('.pg-panel-content'),
|
||||
$container = panel[0].layout().scene().find('.pg-panel-content'),
|
||||
$msgContainer = $container.find('.pg-panel-depends-message'),
|
||||
$gridContainer = $container.find('.pg-panel-depends-container');
|
||||
|
||||
|
@ -19,13 +19,30 @@ function(_, $, pgBrowser) {
|
||||
var sqlPanels = pgBrowser.docker.findPanels('sql');
|
||||
|
||||
// We will listend to the visibility change of the SQL panel
|
||||
pgBrowser.Events.on('pgadmin-browser:panel-sql:' + wcDocker.EVENT.VISIBILITY_CHANGED, this.sqlPanelVisibilityChanged);
|
||||
pgBrowser.Events.on(
|
||||
'pgadmin-browser:panel-sql:' + wcDocker.EVENT.VISIBILITY_CHANGED,
|
||||
this.sqlPanelVisibilityChanged
|
||||
);
|
||||
|
||||
// Hmm.. Did we find the SQL panel, and is it visible (openned)?
|
||||
// If that is the case - we need to listen the browser tree selection
|
||||
// events.
|
||||
if ((sqlPanels.length == 1 && sqlPanels[0].isVisible()) || sqlPanels.length != 1) {
|
||||
pgBrowser.Events.on('pgadmin-browser:tree:selected', this.showSQL);
|
||||
if (sqlPanels.length == 0) {
|
||||
pgBrowser.Events.on(
|
||||
'pgadmin-browser:panel-sql:' + wcDocker.EVENT.INIT,
|
||||
function() {
|
||||
if ((sqlPanels[0].isVisible()) || sqlPanels.length != 1) {
|
||||
pgBrowser.Events.on(
|
||||
'pgadmin-browser:tree:selected', this.showSQL
|
||||
);
|
||||
}
|
||||
}.bind(this)
|
||||
);
|
||||
}
|
||||
else {
|
||||
if ((sqlPanels[0].isVisible()) || sqlPanels.length != 1) {
|
||||
pgBrowser.Events.on('pgadmin-browser:tree:selected', this.showSQL);
|
||||
}
|
||||
}
|
||||
},
|
||||
showSQL: function(item, data, node) {
|
||||
|
Loading…
Reference in New Issue
Block a user