[IMP] website, web_editor: add customize_show views to editor panel

After this commit, the customize_show views are automatically added in
the editor panel as page options in the "customize" tab.

Most of the customize_show views have been replaced by snippets options
but for some it was better to keep an auto population system so as not
to have to create too many bridge modules when it's not worth it
(e.g. My Portal page).

See merge commit for more information.

task-2710582
This commit is contained in:
Benjamin Vray
2022-06-24 10:28:05 +02:00
committed by qsm-odoo
parent 22bc9e142d
commit 84d867dbac
2 changed files with 40 additions and 0 deletions
@@ -405,6 +405,9 @@ var SnippetEditor = Widget.extend({
if (this.$target.parent('.row').length) {
return _t("Column");
}
if (this.$target.is('#wrapwrap > main')) {
return _t("Page Options");
}
return _t("Block");
},
/**
@@ -53,6 +53,43 @@ weSnippetEditor.SnippetsMenu.include({
document.body.classList.remove('o_animated_text_highlighted');
},
//--------------------------------------------------------------------------
// Public
//--------------------------------------------------------------------------
/**
* Adds the "customize_show" templates to the options page of the editor
* panel.
*
* @override
*/
async loadSnippets() {
const viewName = $(this.options.wysiwyg.odooEditor.document.documentElement).data('view-xmlid');
const snippets = await this._super(...arguments);
if (!viewName) {
return snippets;
}
const $snippets = $(snippets);
return this._rpc({
route: '/website/get_switchable_related_views',
params: {
key: viewName,
},
}).then(function (result) {
_.each(result, view => {
$snippets.siblings('#snippet_options').append($(`
<div data-selector="#wrapwrap > main" data-page-options="true" data-no-check="true">
<we-checkbox string="${view.name}"
data-customize-website-views="${view.key}"
data-no-preview="true"
data-reload="/"/>
</div>
`));
});
return $('<div>').append($snippets).html();
});
},
//--------------------------------------------------------------------------
// Private
//--------------------------------------------------------------------------