Help buttons for various dialogues.

This commit is contained in:
Dave Page
2016-06-13 16:17:36 +01:00
parent 702609517f
commit 970d3aafbf
7 changed files with 166 additions and 32 deletions

View File

@@ -485,6 +485,15 @@ def index():
def browser_js():
layout = get_setting('Browser/Layout', default='')
snippets = []
prefs = Preferences.module('paths')
pg_help_path_pref = prefs.preference('pg_help_path')
pg_help_path = pg_help_path_pref.get()
edbas_help_path_pref = prefs.preference('edbas_help_path')
edbas_help_path = edbas_help_path_pref.get()
for submodule in current_blueprint.submodules:
snippets.extend(submodule.jssnippets)
return make_response(
@@ -492,6 +501,8 @@ def browser_js():
'browser/js/browser.js',
layout=layout,
jssnippets=snippets,
pg_help_path=pg_help_path,
edbas_help_path=edbas_help_path,
_=gettext
),
200, {'Content-Type': 'application/x-javascript'})

View File

@@ -681,10 +681,60 @@ function(require, $, _, S, Bootstrap, pgAdmin, alertify, CodeMirror) {
// Do nothing as user cancel the operation
}
);
},
// General function to handle callbacks for object or dialog help.
showHelp: function(type, url, node, item, label) {
if (type == "object_help") {
// See if we can find an existing panel, if not, create one
pnlSqlHelp = this.docker.findPanels('pnl_sql_help')[0];
if (pnlSqlHelp == null) {
pnlProperties = this.docker.findPanels('properties')[0];
this.docker.addPanel('pnl_sql_help', wcDocker.DOCK.STACKED, pnlProperties);
pnlSqlHelp = this.docker.findPanels('pnl_sql_help')[0];
}
// Construct the URL
server = node.getTreeNodeHierarchy(item).server;
baseUrl = '{{ pg_help_path }}'
if (server.server_type == 'ppas') {
baseUrl = '{{ edbas_help_path }}'
}
major = Math.floor(server.version / 10000)
minor = Math.floor(server.version / 100) - (major * 100)
baseUrl = baseUrl.replace('$VERSION$', major + '.' + minor)
if (!S(baseUrl).endsWith('/')) {
baseUrl = baseUrl + '/'
}
fullUrl = baseUrl+ url;
// Update the panel
iframe = $(pnlSqlHelp).data('embeddedFrame');
pnlSqlHelp.title('Help: '+ label);
pnlSqlHelp.focus();
iframe.openURL(fullUrl);
} else if(type == "dialog_help") {
// See if we can find an existing panel, if not, create one
pnlDialogHelp = this.docker.findPanels('pnl_online_help')[0];
if (pnlDialogHelp == null) {
pnlProperties = this.docker.findPanels('properties')[0];
this.docker.addPanel('pnl_online_help', wcDocker.DOCK.STACKED, pnlProperties);
pnlDialogHelp = this.docker.findPanels('pnl_online_help')[0];
}
// Update the panel
iframe = $(pnlDialogHelp).data('embeddedFrame');
pnlDialogHelp.focus();
iframe.openURL(url);
}
}
});
window.onbeforeunload = function(ev) {
var e = ev || window.event;
if(onbeforeunload_flag) {