diff options
| author | Sébastien Theys <seb@odoo.com> | 2019-05-23 14:47:46 +0000 |
|---|---|---|
| committer | Sébastien Theys <seb@odoo.com> | 2019-05-27 16:32:52 +0000 |
| commit | 3924abb71bcbd1cc50a38063c1c4f7cff6e6256a (patch) | |
| tree | 718eee2fd6f73bef71275552f14a61eb27498014 /addons/web_editor/static/src | |
| parent | d4b09c11460c280864d64d73598903bc6235e3b4 (diff) | |
[IMP] web_editor: make media widget save always return a Promise
Before this commit, the return value would be mixed. For consistency, make it
always return a Promise.
PR: #33509
Diffstat (limited to 'addons/web_editor/static/src')
| -rw-r--r-- | addons/web_editor/static/src/js/wysiwyg/widgets/media.js | 14 | ||||
| -rw-r--r-- | addons/web_editor/static/src/js/wysiwyg/widgets/media_dialog.js | 2 |
2 files changed, 10 insertions, 6 deletions
diff --git a/addons/web_editor/static/src/js/wysiwyg/widgets/media.js b/addons/web_editor/static/src/js/wysiwyg/widgets/media.js index 6da33d42bd7..0d255e3ee82 100644 --- a/addons/web_editor/static/src/js/wysiwyg/widgets/media.js +++ b/addons/web_editor/static/src/js/wysiwyg/widgets/media.js @@ -43,7 +43,7 @@ var MediaWidget = Widget.extend({ * Saves the currently configured media on the target media. * * @abstract - * @returns {*} + * @returns {Promise} */ save: function () {}, @@ -183,6 +183,9 @@ var FileWidget = SearchableMediaWidget.extend({ //-------------------------------------------------------------------------- /** + * Saves the currently selected image on the target media. If new files are + * currently being added, delays the save until all files have been added. + * * @override */ save: function () { @@ -398,17 +401,18 @@ var FileWidget = SearchableMediaWidget.extend({ }, /** * @private + * @returns {Promise} */ _save: function () { var self = this; if (this.options.multiImages) { - return this.images; + return Promise.resolve(this.images); } var img = this.images[0]; if (!img) { - return this.media; + return Promise.resolve(this.media); } var prom; @@ -818,7 +822,7 @@ var IconWidget = SearchableMediaWidget.extend({ class: _.compact(finalClasses).join(' '), style: style || null, }); - return this.media; + return Promise.resolve(this.media); }, /** * @override @@ -976,7 +980,7 @@ var VideoWidget = MediaWidget.extend({ ); this.media = this.$media[0]; } - return this.media; + return Promise.resolve(this.media); }, //-------------------------------------------------------------------------- diff --git a/addons/web_editor/static/src/js/wysiwyg/widgets/media_dialog.js b/addons/web_editor/static/src/js/wysiwyg/widgets/media_dialog.js index 0158dd7e49c..92c2f53099e 100644 --- a/addons/web_editor/static/src/js/wysiwyg/widgets/media_dialog.js +++ b/addons/web_editor/static/src/js/wysiwyg/widgets/media_dialog.js @@ -167,7 +167,7 @@ var MediaDialog = Dialog.extend({ var self = this; var _super = this._super; var args = arguments; - return Promise.resolve(this.activeWidget.save()).then(function (data) { + return this.activeWidget.save().then(function (data) { self.final_data = data; return _super.apply(self, args); }); |
