Fix the properties toolbar at the top of the panel so it's always

visible.

This patch also introduce a callback 'onCreate' for each panel, and
frame, which will be called whenever a panel/frame is being created.
This commit is contained in:
Ashesh Vashi 2016-04-18 12:38:53 +05:30
parent 7522d89890
commit 9aee9794c1
5 changed files with 35 additions and 11 deletions

View File

@ -7,7 +7,7 @@ function(_, pgAdmin) {
pgAdmin.Browser.Frame = function(options) { pgAdmin.Browser.Frame = function(options) {
var defaults = [ var defaults = [
'name', 'title', 'width', 'height', 'showTitle', 'isCloseable', 'name', 'title', 'width', 'height', 'showTitle', 'isCloseable',
'isPrivate', 'url', 'icon']; 'isPrivate', 'url', 'icon', 'onCreate'];
_.extend(this, _.pick(options, defaults)); _.extend(this, _.pick(options, defaults));
} }
@ -23,6 +23,7 @@ function(_, pgAdmin) {
icon: '', icon: '',
panel: null, panel: null,
frame: null, frame: null,
onCreate: null,
load: function(docker) { load: function(docker) {
var that = this; var that = this;
if (!that.panel) { if (!that.panel) {
@ -85,6 +86,10 @@ function(_, pgAdmin) {
wcDocker.EVENT.SCROLLED], function(ev) { wcDocker.EVENT.SCROLLED], function(ev) {
myPanel.on(ev, that.eventFunc.bind(myPanel, ev)); myPanel.on(ev, that.eventFunc.bind(myPanel, ev));
}); });
if (that.onCreate && _.isFunction(that.onCreate)) {
that.onCreate.apply(that, [myPanel, frame, $container]);
}
} }
}); });
} }

View File

@ -7,7 +7,7 @@ function(_, pgAdmin) {
pgAdmin.Browser.Panel = function(options) { pgAdmin.Browser.Panel = function(options) {
var defaults = [ var defaults = [
'name', 'title', 'width', 'height', 'showTitle', 'isCloseable', 'name', 'title', 'width', 'height', 'showTitle', 'isCloseable',
'isPrivate', 'content', 'icon', 'events']; 'isPrivate', 'content', 'icon', 'events', 'onCreate'];
_.extend(this, _.pick(options, defaults)); _.extend(this, _.pick(options, defaults));
} }
@ -22,6 +22,7 @@ function(_, pgAdmin) {
content: '', content: '',
icon: '', icon: '',
panel: null, panel: null,
onCreate: null,
load: function(docker, title) { load: function(docker, title) {
var that = this; var that = this;
if (!that.panel) { if (!that.panel) {
@ -40,13 +41,12 @@ function(_, pgAdmin) {
myPanel.icon(that.icon) myPanel.icon(that.icon)
} }
myPanel.closeable(!!that.isCloseable); var $container = $('<div>', {
myPanel.layout().addItem(
$('<div>', {
'class': 'pg-panel-content' 'class': 'pg-panel-content'
}) }).append($(that.content));
.append($(that.content))
); myPanel.closeable(!!that.isCloseable);
myPanel.layout().addItem($container);
that.panel = myPanel; that.panel = myPanel;
if (that.events && _.isObject(that.events)) { if (that.events && _.isObject(that.events)) {
_.each(that.events, function(v, k) { _.each(that.events, function(v, k) {
@ -67,6 +67,10 @@ function(_, pgAdmin) {
wcDocker.EVENT.SCROLLED], function(ev) { wcDocker.EVENT.SCROLLED], function(ev) {
myPanel.on(ev, that.eventFunc.bind(myPanel, ev)); myPanel.on(ev, that.eventFunc.bind(myPanel, ev));
}); });
if (that.onCreate && _.isFunction(that.onCreate)) {
that.onCreate.apply(that, [myPanel, $container]);
}
} }
}); });
} }

View File

@ -69,7 +69,10 @@ function(require, $, _, S, Bootstrap, pgAdmin, alertify, CodeMirror) {
isCloseable: false, isCloseable: false,
isPrivate: true, isPrivate: true,
content: '<div class="obj_properties"><div class="alert alert-info pg-panel-message">{{ _('Please select an object in the tree view.') }}</div></div>', content: '<div class="obj_properties"><div class="alert alert-info pg-panel-message">{{ _('Please select an object in the tree view.') }}</div></div>',
events: panelEvents events: panelEvents,
onCreate: function(myPanel, $container) {
$container.addClass('pg-no-overflow');
}
}), }),
// Statistics of the object // Statistics of the object
'statistics': new pgAdmin.Browser.Panel({ 'statistics': new pgAdmin.Browser.Panel({

View File

@ -241,7 +241,10 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) {
showTitle: true, showTitle: true,
isCloseable: true, isCloseable: true,
isPrivate: true, isPrivate: true,
content: '<div class="obj_properties"><div class="alert alert-info pg-panel-message">{{ _('Please select an object in the tree view.') }}</div></div>' content: '<div class="obj_properties"><div class="alert alert-info pg-panel-message">{{ _('Please wait while we fetch information about the node from the server!') }}</div></div>',
onCreate: function(myPanel, $container) {
$container.addClass('pg-no-overflow');
}
}); });
p.load(pgBrowser.docker); p.load(pgBrowser.docker);
}, },

View File

@ -375,14 +375,23 @@ iframe {
padding-top: 0; padding-top: 0;
padding-right: 0; padding-right: 0;
padding-left: 0; padding-left: 0;
height: 100%;
} }
/* A generic class to make the overflow hidden of a DOM element */
.pg-no-overflow {
overflow: hidden;
}
.pg-prop-has-btn-group-below { .pg-prop-has-btn-group-below {
margin-bottom: 33px; margin-bottom: 33px;
} }
.has-pg-prop-btn-group { .has-pg-prop-btn-group {
top: 48px; top: 39px;
padding-top: 8px;
height: calc(100% - 39px);
} }
.pg-prop-content > div { .pg-prop-content > div {