[FIX] website: prevent saving multiple times in a row

While waiting for a better and more robust fix in the editor itself,
this prevents to hit the save button of the website editor while a save
is in progress.

closes odoo/odoo#52540

Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
This commit is contained in:
qsm-odoo
2020-06-05 16:34:23 +00:00
parent 1c5771a412
commit 4f64fa3e78
@@ -108,10 +108,14 @@ var EditorMenu = Widget.extend({
*
* @param {boolean} [reload=true]
* true if the page has to be reloaded after the save
* @returns {Deferred}
* @returns {Promise}
*/
save: function (reload) {
save: async function (reload) {
if (this._saving) {
return false;
}
var self = this;
this._saving = true;
this.trigger_up('edition_will_stopped');
return this.wysiwyg.save(false).then(function (result) {
var $wrapwrap = $('#wrapwrap');
@@ -125,6 +129,9 @@ var EditorMenu = Widget.extend({
self.trigger_up('edition_was_stopped');
self.destroy();
}
return true;
}).guardedCatch(() => {
this._saving = false;
});
},
/**