[FIX] mail: discard changes confirm dialog
This change is required for new design compatibility because when toggling the app switcher, the whole content is detached. The app switcher is toggled once the deferred def is resolved. If def is resolved before the dialog is closed, the dialog is detached as well, and re-attached when clicking on another apps. With this rev., def is resolved once the dialog is closed. Also fixes the on_cancel() call which wasn't done at the right place.
This commit is contained in:
@@ -1051,13 +1051,17 @@ var ComposeMessage = Attachment.extend ({
|
||||
|
||||
core.bus.on('clear_uncommitted_changes', this, function (chain_callbacks) {
|
||||
if (this.show_composer) {
|
||||
var self = this;
|
||||
chain_callbacks(function() {
|
||||
var def = $.Deferred();
|
||||
var message = _t("You are currently composing a message, your message will be discarded. Are you sure you want to leave this page ?");
|
||||
var options = {
|
||||
title: _t("Warning"),
|
||||
confirm_callback: function() {
|
||||
def.resolve();
|
||||
self.on_cancel();
|
||||
this.on('closed', null, function() { // 'this' is the dialog widget
|
||||
def.resolve();
|
||||
});
|
||||
},
|
||||
cancel_callback: function() {
|
||||
def.reject();
|
||||
@@ -1066,8 +1070,6 @@ var ComposeMessage = Attachment.extend ({
|
||||
Dialog.confirm(this, message, options);
|
||||
return def;
|
||||
});
|
||||
} else {
|
||||
this.on_cancel();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user