mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-01-04 13:17:22 -06:00
Add an option to request confirmation before cancelling changes on a Properties dialog. Fixes #4315
This commit is contained in:
parent
7408b8c8d9
commit
c25034a86d
Binary file not shown.
Before Width: | Height: | Size: 168 KiB After Width: | Height: | Size: 164 KiB |
@ -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.
|
||||
|
@ -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
|
||||
************
|
||||
|
@ -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,
|
||||
|
@ -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');
|
||||
|
Loading…
Reference in New Issue
Block a user