From 5cf32b489f15f5124faa6ea4f09b42de4ab01ee9 Mon Sep 17 00:00:00 2001 From: "Robin Lejeune (role)" Date: Fri, 6 Oct 2023 16:00:29 +0200 Subject: [PATCH] [IMP] website: adapt website headers options and behavior Following the redesign of website template headers, this commit applies a few fixes and modifications to the behavior: - It separates some elements' options into their own option sections: brand logo, language picker, searchbar. - It disables interactive elements in the header (search modal, language dropdown, logout button) while in edit mode. - It solves the following bugs introduced by the headers redesign: - Displaying the language selector with an inline style and flags only is working. - Social links are now unmovable and unremovable (other than by clicking on the "Show/hide social links" expressly made for it), as their place in the templates is fixed, as allowing the snippet to be moved caused several tracebacks, and as removing it through the options and trying to show it again caused a server error. - The CTA button is made unremovable (other than clicking on the "show/hide button" expressly made for it) for the same reasons. - It was possible to write in spaces where it shouldn't have been (search icon, mobile menu closing icon): they are made not editable. task-3474743 Part-of: odoo/odoo#119650 --- addons/website/static/src/js/content/menu.js | 9 +++++ .../static/src/scss/website.edit_mode.scss | 6 ++++ addons/website/views/snippets/snippets.xml | 10 ++++++ addons/website/views/website_templates.xml | 35 +++++++++++++------ 4 files changed, 50 insertions(+), 10 deletions(-) diff --git a/addons/website/static/src/js/content/menu.js b/addons/website/static/src/js/content/menu.js index d90fe27025b..308e46db008 100644 --- a/addons/website/static/src/js/content/menu.js +++ b/addons/website/static/src/js/content/menu.js @@ -632,6 +632,7 @@ publicWidget.registry.HeaderGeneral = publicWidget.Widget.extend({ events: { 'show.bs.collapse #top_menu_collapse': '_onCollapseShow', 'hidden.bs.collapse #top_menu_collapse': '_onCollapseHidden', + "show.bs.modal #o_search_modal": "_onSearchModalShow", "shown.bs.modal #o_search_modal": "_onSearchModalShown", }, @@ -651,6 +652,14 @@ publicWidget.registry.HeaderGeneral = publicWidget.Widget.extend({ _onCollapseHidden() { this.el.classList.remove('o_top_menu_collapse_shown'); }, + /** + * @private + */ + _onSearchModalShow(ev) { + if (this.editableMode) { + ev.preventDefault(); + } + }, /** * @private */ diff --git a/addons/website/static/src/scss/website.edit_mode.scss b/addons/website/static/src/scss/website.edit_mode.scss index 409770e242a..7cb0dd5023f 100644 --- a/addons/website/static/src/scss/website.edit_mode.scss +++ b/addons/website/static/src/scss/website.edit_mode.scss @@ -276,6 +276,12 @@ body.editor_enable { pointer-events: none; } } + + // Some dropdown links are not deactivated in edit, so we prevent clicks. + #o_logout, + .js_change_lang { + pointer-events: none; + } } .o_homepage_editor_welcome_message { padding-top: 128px; diff --git a/addons/website/views/snippets/snippets.xml b/addons/website/views/snippets/snippets.xml index 9de540467f2..20f5e0da8f1 100644 --- a/addons/website/views/snippets/snippets.xml +++ b/addons/website/views/snippets/snippets.xml @@ -1061,6 +1061,11 @@ data-customize-website-views="website.header_hoverable_dropdown">On Hover On Click + + +
None @@ -1072,6 +1077,11 @@ Flag Flag and Text +
+ +
None Text diff --git a/addons/website/views/website_templates.xml b/addons/website/views/website_templates.xml index ea2eae58c39..e8786d4942c 100644 --- a/addons/website/views/website_templates.xml +++ b/addons/website/views/website_templates.xml @@ -323,7 +323,7 @@
-
+
@@ -1488,7 +1488,7 @@