[IMP] web_editor: allow onRemove to be async

Now, a snippet option can do async operations in its onRemove
implementation.

task-2636545

X-original-commit: ef2e55d7f407dedfbf724f2cae32a0fcaede6890
Part-of: odoo/odoo#77256
This commit is contained in:
qsm-odoo
2021-09-28 09:29:09 +00:00
parent e91beddac0
commit 9d8803f6ba
2 changed files with 4 additions and 3 deletions
@@ -451,9 +451,9 @@ var SnippetEditor = Widget.extend({
await new Promise(resolve => {
this.trigger_up('call_for_each_child_snippet', {
$snippet: this.$target,
callback: function (editor, $snippet) {
callback: async function (editor, $snippet) {
for (var i in editor.styles) {
editor.styles[i].onRemove();
await editor.styles[i].onRemove();
}
},
onSuccess: resolve,
@@ -2950,8 +2950,9 @@ const SnippetOptionWidget = Widget.extend({
* Called when the associated snippet is about to be removed from the DOM.
*
* @abstract
* @returns {Promise|undefined}
*/
onRemove: function () {},
onRemove: async function () {},
/**
* Called when the target is shown, only meaningful if the target was hidden
* at some point (typically used for 'invisible' snippets).