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

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');