[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
This commit is contained in:
@@ -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);
|
||||
},
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user