[FIX] web_editor: fix closing optimize image modal

The optimize modal was adding images to the modal even when closing
without optimizing the image.
Now when we close the modal, no images is append to it, same if we
click on "Keep Original" while optimizing an already existing image.

Part of #33983

Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
This commit is contained in:
fja-odoo
2019-06-19 14:55:30 +00:00
parent 195b71e4f2
commit 514ecd7563
2 changed files with 8 additions and 2 deletions
@@ -216,7 +216,9 @@ var ImageOptimizeDialog = Dialog.extend({
* @private
*/
_onKeepOriginalClick: function () {
this.trigger_up('attachment_updated', this.attachment);
if (!this.isExisting) {
this.trigger_up('attachment_updated', this.attachment);
}
this.close();
},
/**
@@ -390,7 +390,11 @@ var FileWidget = SearchableMediaWidget.extend({
});
optimizeDialog.on('closed', self, function () {
self.noSave = true;
resolve(attachment);
if (isExisting) {
reject();
} else {
resolve(attachment);
}
});
});
var always = function () {