Add an option to request confirmation before cancelling changes on a Properties dialog. Fixes #4315

This commit is contained in:
Aditya Toshniwal 2019-10-29 14:31:43 +00:00 committed by Dave Page
parent 7408b8c8d9
commit c25034a86d
5 changed files with 49 additions and 0 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 168 KiB

After

Width:  |  Height:  |  Size: 164 KiB

View File

@ -34,6 +34,10 @@ Use the fields on the *Display* panel to specify general display preferences:
saving interval. A value of *-1* will disable the treeview state saving
functionality.
* When the *Confirm before closing properties with unsaved changes* switch is set to *True*,
pgAdmin will warn you before closing the properties dialog of an object if there
are any unsaved changes. On user confirmation, the properties dialog will close.
* When the *Confirm on close or refresh* switch is set to *True*, pgAdmin will
attempt to catch browser close or refresh events and prompt before allowing
them to continue.

View File

@ -10,6 +10,7 @@ New features
************
| `Issue #1974 <https://redmine.postgresql.org/issues/1974>`_ - Added encrypted password in reverse engineered SQL for roles.
| `Issue #4315 <https://redmine.postgresql.org/issues/4315>`_ - Add an option to request confirmation before cancelling changes on a Properties dialog.
Housekeeping
************

View File

@ -54,6 +54,17 @@ def register_browser_preferences(self):
)
)
self.preference.register(
'display', 'confirm_on_properties_close',
gettext("Confirm before closing properties with unsaved changes?"),
'boolean',
True, category_label=gettext('Display'),
help_str=gettext(
'Confirm before closure of the properties dialog for an object if '
'the changes are not saved.'
)
)
self.preference.register(
'display', 'auto_expand_sole_children',
gettext("Auto-expand sole children"), 'boolean', True,

View File

@ -1535,6 +1535,39 @@ define('pgadmin.browser.node', [
onEdit = editInNewPanel.bind(panel);
}
if (panel.closeable()) {
panel.on(wcDocker.EVENT.CLOSING, function() {
var j = this.$container.find('.obj_properties').first(),
view = j && j.data('obj-view'),
self = this;
let confirm_on_properties_close = pgBrowser.get_preferences_for_module('browser').confirm_on_properties_close;
if (view && view.model && confirm_on_properties_close) {
if(view.model.sessChanged()){
Alertify.confirm(
gettext('Warning'),
gettext('Changes will be lost. Are you sure you want to close the dialog?'),
function() {
setTimeout(function(){
self.off(wcDocker.EVENT.CLOSING);
self.close();
}, 50);
return true;
},
function() {
return true;
}
).set('labels', {
ok: gettext('Yes'),
cancel: gettext('No'),
}).show();
} else {
return true;
}
} else {
return true;
}
}.bind(panel));
var onCloseFunc = function() {
var j = this.$container.find('.obj_properties').first(),
view = j && j.data('obj-view');