From 4a2ed8a289994620296124a3540706e0d4b61dec Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Mon, 28 Mar 2022 13:28:43 +0000 Subject: [PATCH] [IMP] web_editor: allow the `onBuilt` method to be async This became more and more needed. Of course, it should be avoided most of the time as you do not want to rely on async operations to build the initial rendering of a snippet (best to do server side during the rendering of the editor panel). This can however make sense and it is needed as a fix for the social media snippet (see next commit). task-2739937 X-original-commit: 3fb1718ce494ccf48959e6e4fe9f640621c4a3a9 Part-of: odoo/odoo#87933 --- addons/web_editor/static/src/js/editor/snippets.editor.js | 2 +- addons/web_editor/static/src/js/editor/snippets.options.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/web_editor/static/src/js/editor/snippets.editor.js b/addons/web_editor/static/src/js/editor/snippets.editor.js index 276a86d1ab3..53a50888327 100644 --- a/addons/web_editor/static/src/js/editor/snippets.editor.js +++ b/addons/web_editor/static/src/js/editor/snippets.editor.js @@ -296,7 +296,7 @@ var SnippetEditor = Widget.extend({ */ buildSnippet: async function () { for (var i in this.styles) { - this.styles[i].onBuilt(); + await this.styles[i].onBuilt(); } await this.toggleTargetVisibility(true); }, diff --git a/addons/web_editor/static/src/js/editor/snippets.options.js b/addons/web_editor/static/src/js/editor/snippets.options.js index ec1d6854850..cf851d67904 100644 --- a/addons/web_editor/static/src/js/editor/snippets.options.js +++ b/addons/web_editor/static/src/js/editor/snippets.options.js @@ -2999,8 +2999,9 @@ const SnippetOptionWidget = Widget.extend({ * menu. Note: this is called after the start and onFocus methods. * * @abstract + * @returns {Promise|undefined} */ - onBuilt: function () {}, + async onBuilt() {}, /** * Called when the parent edition overlay is removed from the associated * snippet (another snippet enters edition for example).