[FIX] web_editor: properly await all async parts for onRemove/onClone

Even though onRemove and onClone cannot be async themselves (yet?), it
is called via a trigger_up of `call_for_each_child_snippet` so that each
part of the snippet being removed / cloned has their onRemove / onClone
called. Doing that way, some SnippetEditor instances may have to be
created and it can be an async operation... the problem is that our code
was only awaiting the first of those instanciations instead of all of
them.

closes odoo/odoo#76881

X-original-commit: ea2a40afb96147e83c897a0376e187d8c957e66a
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
This commit is contained in:
qsm-odoo
2021-09-21 09:38:21 +00:00
parent 3b598dbdf8
commit c276545de7
@@ -455,8 +455,8 @@ var SnippetEditor = Widget.extend({
for (var i in editor.styles) {
editor.styles[i].onRemove();
}
resolve();
},
onSuccess: resolve,
});
});
@@ -669,8 +669,8 @@ var SnippetEditor = Widget.extend({
isCurrent: ($snippet.is($clone)),
});
}
resolve();
},
onSuccess: resolve,
});
});
this.trigger_up('snippet_cloned', {$target: $clone, $origin: this.$target});
@@ -2656,7 +2656,8 @@ var SnippetsMenu = Widget.extend({
* @param {OdooEvent} ev
*/
_onCallForEachChildSnippet: function (ev) {
this._callForEachChildSnippet(ev.data.$snippet, ev.data.callback);
this._callForEachChildSnippet(ev.data.$snippet, ev.data.callback)
.then(() => ev.data.onSuccess());
},
/**
* Called when the overlay dimensions/positions should be recomputed.