mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2024-11-24 09:40:21 -06:00
Teach dialogues about Escape to cancel, Enter to Save/OK, and F1 for help. Fixes #1535
This commit is contained in:
parent
ec5bc23dfd
commit
af43ccfc07
@ -177,11 +177,11 @@ define('pgadmin.node.tablespace', [
|
||||
setup:function() {
|
||||
return {
|
||||
buttons: [{
|
||||
text: '', key: 27, className: 'btn btn-default pull-left fa fa-lg fa-question',
|
||||
text: '', key: 112, className: 'btn btn-default pull-left fa fa-lg fa-question',
|
||||
attrs:{name:'dialog_help', type:'button', label: gettext('Users'),
|
||||
url: url_for('help.static', {'filename': 'move_objects.html'})}
|
||||
},{
|
||||
text: gettext('OK'), key: 27, className: 'btn btn-primary fa fa-lg fa-save pg-alertify-button'
|
||||
text: gettext('OK'), key: 13, className: 'btn btn-primary fa fa-lg fa-save pg-alertify-button'
|
||||
},{
|
||||
text: gettext('Cancel'), key: 27, className: 'btn btn-danger fa fa-lg fa-times pg-alertify-button'
|
||||
}],
|
||||
|
@ -403,7 +403,7 @@ define('pgadmin.node.server', [
|
||||
setup:function() {
|
||||
return {
|
||||
buttons: [{
|
||||
text: gettext('Ok'), key: 27, className: 'btn btn-primary', attrs:{name:'submit'}
|
||||
text: gettext('Ok'), key: 13, className: 'btn btn-primary', attrs:{name:'submit'}
|
||||
},{
|
||||
text: gettext('Cancel'), key: 27, className: 'btn btn-danger', attrs:{name:'cancel'}
|
||||
}],
|
||||
|
@ -4,7 +4,12 @@ define([
|
||||
'backform', 'pgadmin.backform', 'wcdocker', 'pgadmin.alertifyjs'
|
||||
], function(gettext, $, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) {
|
||||
|
||||
var wcDocker = window.wcDocker;
|
||||
var wcDocker = window.wcDocker,
|
||||
keyCode = {
|
||||
ENTER: 13,
|
||||
ESCAPE: 27,
|
||||
F1: 112
|
||||
};
|
||||
|
||||
// It has already been defined.
|
||||
// Avoid running this script again.
|
||||
@ -869,10 +874,41 @@ define([
|
||||
j = panel.$container.find('.obj_properties').first(),
|
||||
view = j.data('obj-view'),
|
||||
content = $('<div tabindex="1"></div>')
|
||||
.addClass('pg-prop-content col-xs-12'),
|
||||
.addClass('pg-prop-content col-xs-12');
|
||||
|
||||
// Handle key press events for Cancel, save and help button
|
||||
var handleKeyDown = function(event, context) {
|
||||
// If called on panel other than node_props, return
|
||||
if (panel && panel['_type'] !== 'node_props') return;
|
||||
|
||||
switch (event.which) {
|
||||
case keyCode.ESCAPE:
|
||||
closePanel();
|
||||
break;
|
||||
case keyCode.ENTER:
|
||||
// Return if event is fired from child element
|
||||
if (event.target !== context) return;
|
||||
if (view && view.model && view.model.sessChanged()) {
|
||||
onSave.call(this, view);
|
||||
}
|
||||
break;
|
||||
case keyCode.F1:
|
||||
onDialogHelp();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}.bind(panel);
|
||||
|
||||
setTimeout(function() {
|
||||
// Register key press events with panel element
|
||||
panel.$container.find('.backform-tab').on("keydown", function(event) {
|
||||
handleKeyDown(event, this);
|
||||
});
|
||||
}, 200); // wait for panel tab to render
|
||||
|
||||
// Template function to create the status bar
|
||||
createStatusBar = function(location){
|
||||
var createStatusBar = function(location){
|
||||
var statusBar = $('<div></div>').addClass(
|
||||
'pg-prop-status-bar'
|
||||
).appendTo(j);
|
||||
@ -1077,6 +1113,61 @@ define([
|
||||
iframe.openURL(that.dialogHelp);
|
||||
}.bind(panel),
|
||||
|
||||
onSave = function(view) {
|
||||
var m = view.model,
|
||||
d = m.toJSON(true),
|
||||
|
||||
// Generate a timer for the request
|
||||
timer = setTimeout(function(){
|
||||
$('.obj_properties').addClass('show_progress');
|
||||
}, 1000);
|
||||
|
||||
if (d && !_.isEmpty(d)) {
|
||||
m.save({}, {
|
||||
attrs: d,
|
||||
validate: false,
|
||||
cache: false,
|
||||
success: function() {
|
||||
onSaveFunc.call();
|
||||
// Hide progress cursor
|
||||
$('.obj_properties').removeClass('show_progress');
|
||||
clearTimeout(timer);
|
||||
|
||||
// Removing the node-prop property of panel
|
||||
// so that we show updated data on panel
|
||||
var pnlProperties = pgBrowser.docker.findPanels('properties')[0],
|
||||
pnlSql = pgBrowser.docker.findPanels('sql')[0],
|
||||
pnlStats = pgBrowser.docker.findPanels('statistics')[0],
|
||||
pnlDependencies = pgBrowser.docker.findPanels('dependencies')[0],
|
||||
pnlDependents = pgBrowser.docker.findPanels('dependents')[0];
|
||||
|
||||
if(pnlProperties)
|
||||
$(pnlProperties).removeData('node-prop');
|
||||
if(pnlSql)
|
||||
$(pnlSql).removeData('node-prop');
|
||||
if(pnlStats)
|
||||
$(pnlStats).removeData('node-prop');
|
||||
if(pnlDependencies)
|
||||
$(pnlDependencies).removeData('node-prop');
|
||||
if(pnlDependents)
|
||||
$(pnlDependents).removeData('node-prop');
|
||||
},
|
||||
error: function(m, jqxhr) {
|
||||
Alertify.pgNotifier(
|
||||
"error", jqxhr,
|
||||
S(
|
||||
gettext("Error saving properties: %s")
|
||||
).sprintf(jqxhr.statusText).value()
|
||||
);
|
||||
|
||||
// Hide progress cursor
|
||||
$('.obj_properties').removeClass('show_progress');
|
||||
clearTimeout(timer);
|
||||
}
|
||||
});
|
||||
}
|
||||
}.bind(panel),
|
||||
|
||||
editFunc = function() {
|
||||
var panel = this;
|
||||
if (action && action == 'properties') {
|
||||
@ -1171,58 +1262,7 @@ define([
|
||||
register: function(btn) {
|
||||
// Save the changes
|
||||
btn.click(function() {
|
||||
var m = view.model,
|
||||
d = m.toJSON(true),
|
||||
|
||||
// Generate a timer for the request
|
||||
timer = setTimeout(function(){
|
||||
$('.obj_properties').addClass('show_progress');
|
||||
}, 1000);
|
||||
|
||||
if (d && !_.isEmpty(d)) {
|
||||
m.save({}, {
|
||||
attrs: d,
|
||||
validate: false,
|
||||
cache: false,
|
||||
success: function() {
|
||||
onSaveFunc.call();
|
||||
// Hide progress cursor
|
||||
$('.obj_properties').removeClass('show_progress');
|
||||
clearTimeout(timer);
|
||||
|
||||
// Removing the node-prop property of panel
|
||||
// so that we show updated data on panel
|
||||
var pnlProperties = pgBrowser.docker.findPanels('properties')[0],
|
||||
pnlSql = pgBrowser.docker.findPanels('sql')[0],
|
||||
pnlStats = pgBrowser.docker.findPanels('statistics')[0],
|
||||
pnlDependencies = pgBrowser.docker.findPanels('dependencies')[0],
|
||||
pnlDependents = pgBrowser.docker.findPanels('dependents')[0];
|
||||
|
||||
if(pnlProperties)
|
||||
$(pnlProperties).removeData('node-prop');
|
||||
if(pnlSql)
|
||||
$(pnlSql).removeData('node-prop');
|
||||
if(pnlStats)
|
||||
$(pnlStats).removeData('node-prop');
|
||||
if(pnlDependencies)
|
||||
$(pnlDependencies).removeData('node-prop');
|
||||
if(pnlDependents)
|
||||
$(pnlDependents).removeData('node-prop');
|
||||
},
|
||||
error: function(m, jqxhr) {
|
||||
Alertify.pgNotifier(
|
||||
"error", jqxhr,
|
||||
S(
|
||||
gettext("Error saving properties: %s")
|
||||
).sprintf(jqxhr.statusText).value()
|
||||
);
|
||||
|
||||
// Hide progress cursor
|
||||
$('.obj_properties').removeClass('show_progress');
|
||||
clearTimeout(timer);
|
||||
}
|
||||
});
|
||||
}
|
||||
onSave.call(this, view);
|
||||
});
|
||||
}
|
||||
},{
|
||||
|
@ -254,7 +254,7 @@ define([
|
||||
return {
|
||||
buttons:[
|
||||
{
|
||||
text: gettext("Select"), className: "btn btn-primary fa fa-file file_manager_ok pg-alertify-button disabled"
|
||||
text: gettext("Select"), key: 13, className: "btn btn-primary fa fa-file file_manager_ok pg-alertify-button disabled"
|
||||
},
|
||||
{
|
||||
text: gettext("Cancel"), key: 27, className: "btn btn-danger fa fa-times pg-alertify-button"
|
||||
@ -379,7 +379,7 @@ define([
|
||||
return {
|
||||
buttons:[
|
||||
{
|
||||
text: gettext("Select"), className: "btn btn-primary fa fa-file file_manager_ok pg-alertify-button disabled"
|
||||
text: gettext("Select"), key: 13, className: "btn btn-primary fa fa-file file_manager_ok pg-alertify-button disabled"
|
||||
},
|
||||
{
|
||||
text: gettext("Cancel"), key: 27, className: "btn btn-danger fa fa-times pg-alertify-button"
|
||||
@ -502,7 +502,7 @@ define([
|
||||
return {
|
||||
buttons:[
|
||||
{
|
||||
text: gettext("Create"), className: "btn btn-primary fa fa-file file_manager_create file_manager_ok pg-alertify-button disabled"
|
||||
text: gettext("Create"), key: 13, className: "btn btn-primary fa fa-file file_manager_create file_manager_ok pg-alertify-button disabled"
|
||||
},
|
||||
{
|
||||
text: gettext("Cancel"), key: 27, className: "btn btn-danger fa fa-times file_manager_create_cancel pg-alertify-button"
|
||||
|
@ -354,7 +354,7 @@ define([
|
||||
setup: function() {
|
||||
return {
|
||||
buttons:[{
|
||||
text: '', key: 27,
|
||||
text: '', key: 112,
|
||||
className: 'btn btn-default pull-left fa fa-lg fa-question',
|
||||
attrs:{
|
||||
name:'dialog_help', type:'button',
|
||||
@ -366,7 +366,7 @@ define([
|
||||
},{
|
||||
text: gettext('OK'), key: 13, className: "btn btn-primary fa fa-lg fa-save pg-alertify-button"
|
||||
},{
|
||||
text: gettext('Cancel'), className: "btn btn-danger fa fa-lg fa-times pg-alertify-button"
|
||||
text: gettext('Cancel'), key: 27, className: "btn btn-danger fa fa-lg fa-times pg-alertify-button"
|
||||
}],
|
||||
focus: { element: 0 },
|
||||
options: {
|
||||
|
@ -437,15 +437,15 @@ TODO LIST FOR BACKUP:
|
||||
setup:function() {
|
||||
return {
|
||||
buttons: [{
|
||||
text: '', key: 27, className: 'btn btn-default pull-left fa fa-lg fa-info',
|
||||
text: '', className: 'btn btn-default pull-left fa fa-lg fa-info',
|
||||
attrs:{name:'object_help', type:'button', url: 'backup.html', label: gettext('Backup')}
|
||||
},{
|
||||
text: '', key: 27, className: 'btn btn-default pull-left fa fa-lg fa-question',
|
||||
text: '', key: 112, className: 'btn btn-default pull-left fa fa-lg fa-question',
|
||||
attrs:{name:'dialog_help', type:'button', label: gettext('Backup'),
|
||||
url: '{{ url_for('help.static', filename='backup_dialog.html') }}'
|
||||
}
|
||||
},{
|
||||
text: gettext('Backup'), key: 27, className: 'btn btn-primary fa fa-lg fa-save pg-alertify-button',
|
||||
text: gettext('Backup'), key: 13, className: 'btn btn-primary fa fa-lg fa-save pg-alertify-button',
|
||||
'data-btn-name': 'backup'
|
||||
},{
|
||||
text: gettext('Cancel'), key: 27, className: 'btn btn-danger fa fa-lg fa-times pg-alertify-button',
|
||||
@ -653,14 +653,14 @@ TODO LIST FOR BACKUP:
|
||||
setup:function() {
|
||||
return {
|
||||
buttons: [{
|
||||
text: '', key: 27, className: 'btn btn-default pull-left fa fa-lg fa-info',
|
||||
text: '', className: 'btn btn-default pull-left fa fa-lg fa-info',
|
||||
attrs:{name:'object_help', type:'button', url: 'backup.html', label: gettext('Backup')}
|
||||
},{
|
||||
text: '', key: 27, className: 'btn btn-default pull-left fa fa-lg fa-question',
|
||||
text: '', key: 112, className: 'btn btn-default pull-left fa fa-lg fa-question',
|
||||
attrs:{name:'dialog_help', type:'button', label: gettext('Backup'),
|
||||
url: '{{ url_for('help.static', filename='backup_dialog.html') }}'}
|
||||
},{
|
||||
text: gettext('Backup'), key: 27, className: 'btn btn-primary fa fa-lg fa-save pg-alertify-button',
|
||||
text: gettext('Backup'), key: 13, className: 'btn btn-primary fa fa-lg fa-save pg-alertify-button',
|
||||
'data-btn-name': 'backup'
|
||||
},{
|
||||
text: gettext('Cancel'), key: 27, className: 'btn btn-danger fa fa-lg fa-times pg-alertify-button',
|
||||
|
@ -428,7 +428,7 @@ define([
|
||||
},
|
||||
setup:function() {
|
||||
return {
|
||||
buttons:[{ text: "Debug", key: 27, className: "btn btn-primary" },
|
||||
buttons:[{ text: "Debug", key: 13, className: "btn btn-primary" },
|
||||
{ text: "Cancel", key: 27, className: "btn btn-primary" }],
|
||||
options: { modal: 0, resizable: true }
|
||||
};
|
||||
|
@ -375,7 +375,7 @@ define([
|
||||
setup: function() {
|
||||
return {
|
||||
buttons:[{
|
||||
text: gettext("OK"), key: 27, disable: true,
|
||||
text: gettext("OK"), key: 13, disable: true,
|
||||
'data-btn-name': 'ok',
|
||||
className:
|
||||
"btn btn-primary fa fa-lg fa-save pg-alertify-button"
|
||||
|
@ -264,14 +264,14 @@ define([
|
||||
setup: function() {
|
||||
return {
|
||||
buttons:[{
|
||||
text: '', key: 27, className: 'btn btn-default pull-left fa fa-lg fa-info',
|
||||
text: '', className: 'btn btn-default pull-left fa fa-lg fa-info',
|
||||
attrs:{name:'object_help', type:'button', url: 'maintenance.html', label: gettext('Maintenance')}
|
||||
},{
|
||||
text: '', key: 27, className: 'btn btn-default pull-left fa fa-lg fa-question',
|
||||
text: '', key: 112, className: 'btn btn-default pull-left fa fa-lg fa-question',
|
||||
attrs:{name:'dialog_help', type:'button', label: gettext('Maintenance'),
|
||||
url: '{{ url_for('help.static', filename='maintenance_dialog.html') }}'}
|
||||
},{
|
||||
text: gettext("OK"), key: 27, className: "btn btn-primary fa fa-lg fa-save pg-alertify-button",
|
||||
text: gettext("OK"), key: 13, className: "btn btn-primary fa fa-lg fa-save pg-alertify-button",
|
||||
'data-btn-name': 'ok',
|
||||
},{
|
||||
text: gettext("Cancel"), key: 27, className: "btn btn-danger fa fa-lg fa-times pg-alertify-button",
|
||||
|
@ -366,14 +366,14 @@ define([
|
||||
setup:function() {
|
||||
return {
|
||||
buttons: [{
|
||||
text: '', key: 27, className: 'btn btn-default pull-left fa fa-lg fa-info',
|
||||
text: '', className: 'btn btn-default pull-left fa fa-lg fa-info',
|
||||
attrs:{name:'object_help', type:'button', url: 'backup.html', label: gettext('Restore')}
|
||||
},{
|
||||
text: '', key: 27, className: 'btn btn-default pull-left fa fa-lg fa-question',
|
||||
text: '', key: 112, className: 'btn btn-default pull-left fa fa-lg fa-question',
|
||||
attrs:{name:'dialog_help', type:'button', label: gettext('Restore'),
|
||||
url: '{{ url_for('help.static', filename='restore_dialog.html') }}'}
|
||||
},{
|
||||
text: gettext('Restore'), key: 27,
|
||||
text: gettext('Restore'), key: 13,
|
||||
className: 'btn btn-primary fa fa-upload pg-alertify-button', restore: true,
|
||||
'data-btn-name': 'restore'
|
||||
},{
|
||||
|
@ -380,7 +380,7 @@ define([
|
||||
setup:function() {
|
||||
return {
|
||||
buttons: [{
|
||||
text: '', key: 27, className: 'btn btn-default pull-left fa fa-lg fa-question',
|
||||
text: '', key: 112, className: 'btn btn-default pull-left fa fa-lg fa-question',
|
||||
attrs:{name:'dialog_help', type:'button', label: gettext('Users'),
|
||||
url: '{{ url_for('help.static', filename='pgadmin_user.html') }}'}
|
||||
},{
|
||||
|
Loading…
Reference in New Issue
Block a user