diff options
| author | qsm-odoo <qsm@odoo.com> | 2020-08-06 09:29:04 +0000 |
|---|---|---|
| committer | qsm-odoo <qsm@odoo.com> | 2020-08-06 09:46:48 +0000 |
| commit | 78ef2ec8134b09d9732849a11ff8d9e1ac886bb5 (patch) | |
| tree | 3492e0c3acedcd533ae9930d6b9825c1be66b022 /addons/website/static/src/js/editor | |
| parent | 6a258db1e96ec05d53744cebfb2a884ae712d69d (diff) | |
[FIX] website: restore sub-headings edition toggling
Since [1], the sub-headings edition was not possible anymore in the
'options' tab of the editor panel. This is because the visibility of
rows is now automatic, depending of the visibility of the inner widgets.
The custom code for that row visibility, controlled by the user, was
thus not working anymore.
Note: this fix solves the problem with big hacks. Better code will
handle foldable zones generically.
[1]: https://github.com/odoo/odoo/commit/8d57f21d7df2033f462ead60fcb5abba4546213e
Part of https://github.com/odoo/odoo/pull/55529
closes odoo/odoo#55529
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Diffstat (limited to 'addons/website/static/src/js/editor')
| -rw-r--r-- | addons/website/static/src/js/editor/snippets.options.js | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/addons/website/static/src/js/editor/snippets.options.js b/addons/website/static/src/js/editor/snippets.options.js index e91d9d88877..552c53ccd18 100644 --- a/addons/website/static/src/js/editor/snippets.options.js +++ b/addons/website/static/src/js/editor/snippets.options.js @@ -942,6 +942,13 @@ options.registry.ThemeColors = options.registry.OptionsTab.extend({ }), /** + * @constructor + */ + init() { + this._super(...arguments); + this._showCCSubHeadings = {}; + }, + /** * @override */ async start() { @@ -974,6 +981,15 @@ options.registry.ThemeColors = options.registry.OptionsTab.extend({ /** * @override */ + async _computeWidgetVisibility(widgetName, params) { + if (params.shUid) { + return !!this._showCCSubHeadings[params.shUid]; + } + return this._super(...arguments); + }, + /** + * @override + */ async _renderOriginalXML($xml) { const uiFragment = await this._super(...arguments); @@ -984,9 +1000,6 @@ options.registry.ThemeColors = options.registry.OptionsTab.extend({ const titleEl = headingsEl.querySelector('we-title'); titleEl.insertBefore(togglerEl, titleEl.firstChild); }); - uiFragment.querySelectorAll('.o_cc_subheadings_collapse').forEach(subheadingsEl => { - subheadingsEl.classList.add('d-none'); - }); return uiFragment; }, @@ -1056,7 +1069,16 @@ options.registry.ThemeColors = options.registry.OptionsTab.extend({ const show = togglerEl.classList.contains('fa-caret-down'); togglerEl.classList.toggle('fa-caret-down', !show); togglerEl.classList.toggle('fa-caret-up', show); - collapseEl.classList.toggle('d-none', !show); + this._showCCSubHeadings[collapseEl.dataset.uid] = show; + // FIXME big hack to rerender the interface (all the foldable code is + // a hack currently anyway, it needs to be generic) + this.trigger_up('snippet_edition_request', {exec: async () => { + return new Promise(resolve => setTimeout(() => { + this.trigger_up('snippet_option_update', { + onSuccess: () => resolve(), + }); + })); + }}); }, }); |
