[FIX] web_editor: need to build the snippet before commit it into vDom

Issue: Add dynamic carousel in the page, then change the footer template,
then reply "Yes, I want to save & reload", then the page is broken because
the new class and data attributes are not saved.

closes odoo/odoo#60077

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
This commit is contained in:
Gorash
2020-10-16 14:09:49 +00:00
parent f1df077ac9
commit 5418f93903
2 changed files with 7 additions and 11 deletions
@@ -2068,19 +2068,18 @@ var SnippetsMenu = Widget.extend({
_.defer(async () => {
self.trigger_up('snippet_dropped', {$target: $snippetToInsert});
await self._callForEachChildSnippet($snippetToInsert, function (editor) {
return editor.buildSnippet();
});
const jwEditor = self.wysiwyg.editor;
const vNodes = await self._insertSnippet($snippetToInsert);
const layout = jwEditor.plugins.get(self.JWEditorLib.Layout);
const domLayout = layout.engines.dom;
const domNode = domLayout.getDomNodes(vNodes[0])[0];
self._disableUndroppableSnippets();
self.dragAndDropResolve();
await self._callForEachChildSnippet($(domNode), function (editor) {
return editor.buildSnippet();
});
$snippetToInsert.trigger('content_changed');
await self._updateInvisibleDOM();
@@ -359,10 +359,7 @@ snippetOptions.registry.WebsiteFormEditor = FormEditor.extend({
// If the form has no model it means a new snippet has been dropped.
// Apply the default model selected in willStart on it.
if (!this.$target[0].dataset.model_name) {
proms.push((async () => {
await this._applyFormModel();
await this.updateChangesInWysiwyg();
})());
proms.push(this._applyFormModel());
}
await Promise.all(proms);