mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Add an option to request confirmation before cancelling/resetting changes on a Properties dialog. Fixes #4351
This commit is contained in:
parent
e10b58e4ca
commit
570ee58f53
Binary file not shown.
Before Width: | Height: | Size: 164 KiB After Width: | Height: | Size: 172 KiB |
@ -10,7 +10,7 @@ New features
|
||||
************
|
||||
|
||||
| `Issue #1974 <https://redmine.postgresql.org/issues/1974>`_ - Added encrypted password in reverse engineered SQL for roles.
|
||||
| `Issue #4351 <https://redmine.postgresql.org/issues/4351>`_ - Add an option to request confirmation before cancelling changes on a Properties dialog.
|
||||
| `Issue #4351 <https://redmine.postgresql.org/issues/4351>`_ - Add an option to request confirmation before cancelling/resetting changes on a Properties dialog.
|
||||
| `Issue #4006 <https://redmine.postgresql.org/issues/4006>`_ - Support Enable Always and Enable Replica on triggers.
|
||||
|
||||
Housekeeping
|
||||
|
@ -56,12 +56,12 @@ def register_browser_preferences(self):
|
||||
|
||||
self.preference.register(
|
||||
'display', 'confirm_on_properties_close',
|
||||
gettext("Confirm before closing properties with unsaved changes?"),
|
||||
gettext("Confirm before Close/Reset in object properties dialog ?"),
|
||||
'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.'
|
||||
'Confirm before closing or resetting the changes in the '
|
||||
'properties dialog for an object if the changes are not saved.'
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -1241,6 +1241,39 @@ define('pgadmin.browser.node', [
|
||||
window.open(that.dialogHelp, 'pgadmin_help');
|
||||
}.bind(panel),
|
||||
|
||||
warnBeforeChangesLost = function(warn_text, yes_callback) {
|
||||
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 (confirm_on_properties_close && confirm_close && view && view.model) {
|
||||
if(view.model.sessChanged()){
|
||||
Alertify.confirm(
|
||||
gettext('Warning'),
|
||||
warn_text,
|
||||
function() {
|
||||
setTimeout(function(){
|
||||
yes_callback();
|
||||
}.bind(self), 50);
|
||||
return true;
|
||||
},
|
||||
function() {
|
||||
return true;
|
||||
}
|
||||
).set('labels', {
|
||||
ok: gettext('Yes'),
|
||||
cancel: gettext('No'),
|
||||
}).show();
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
yes_callback();
|
||||
return true;
|
||||
}
|
||||
}.bind(panel),
|
||||
|
||||
onSave = function(view, saveBtn) {
|
||||
var m = view.model,
|
||||
d = m.toJSON(true),
|
||||
@ -1413,9 +1446,15 @@ define('pgadmin.browser.node', [
|
||||
disabled: true,
|
||||
register: function(btn) {
|
||||
btn.on('click',() => {
|
||||
setTimeout(function() {
|
||||
editFunc.call();
|
||||
}, 0);
|
||||
warnBeforeChangesLost.call(
|
||||
panel,
|
||||
gettext('Changes will be lost. Are you sure you want to reset?'),
|
||||
function() {
|
||||
setTimeout(function() {
|
||||
editFunc.call();
|
||||
}, 0);
|
||||
}
|
||||
);
|
||||
});
|
||||
},
|
||||
}, {
|
||||
@ -1539,38 +1578,14 @@ 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 (confirm_on_properties_close && confirm_close && view && view.model) {
|
||||
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;
|
||||
panel.on(wcDocker.EVENT.CLOSING, warnBeforeChangesLost.bind(
|
||||
panel,
|
||||
gettext('Changes will be lost. Are you sure you want to close the dialog?'),
|
||||
function() {
|
||||
panel.off(wcDocker.EVENT.CLOSING);
|
||||
panel.close();
|
||||
}
|
||||
}.bind(panel));
|
||||
));
|
||||
|
||||
var onCloseFunc = function() {
|
||||
var j = this.$container.find('.obj_properties').first(),
|
||||
|
Loading…
Reference in New Issue
Block a user