From 25c9354cab2ed809620300b5805eaa85e8733534 Mon Sep 17 00:00:00 2001 From: ptsuva Date: Thu, 23 May 2024 11:15:19 +0530 Subject: [PATCH] [MIG] web_chatter_position: Migration to 17.0 [IMP] web_chatter_position: improve function compile web_chatter_position: propose myself as maintainer --- web_chatter_position/README.rst | 27 ++- web_chatter_position/__manifest__.py | 8 +- web_chatter_position/i18n/hr.po | 4 +- .../i18n/web_chatter_position.pot | 2 +- web_chatter_position/readme/CONTRIBUTORS.md | 4 + .../static/description/index.html | 13 +- .../static/src/js/web_chatter_position.esm.js | 172 +++++------------- .../static/src/scss/form_controller.scss | 17 ++ .../static/src/scss/form_renderer.scss | 10 + .../static/src/scss/form_statusbar.scss | 3 + 10 files changed, 125 insertions(+), 135 deletions(-) create mode 100644 web_chatter_position/static/src/scss/form_controller.scss create mode 100644 web_chatter_position/static/src/scss/form_renderer.scss create mode 100644 web_chatter_position/static/src/scss/form_statusbar.scss diff --git a/web_chatter_position/README.rst b/web_chatter_position/README.rst index 2c95e9661..45eeb803f 100644 --- a/web_chatter_position/README.rst +++ b/web_chatter_position/README.rst @@ -7,7 +7,7 @@ Chatter Position !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:fbb006a9a99fbcf94cbb8823017ff08050ed9294fd3c81929e4a4b2e225ca61b + !! source digest: sha256:37fa43641cb746a03b8cb4f0492784abb34e5b511d0d318013dcee341b792da4 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png @@ -61,15 +61,24 @@ Authors * Hynsys Technologies * Camptocamp +* Alitec Pte Ltd Contributors ------------ -- Hynsys Technologies -- Juan Miguel Sánchez Arce -- `Camptocamp `__ +- Hynsys Technologies +- Juan Miguel Sánchez Arce +- `Camptocamp `__ - - Iván Todorovich + - Iván Todorovich + +- `Alitec Pte Ltd `__ + + - Jay Patel + +- Trobz + + - Tris Doan Maintainers ----------- @@ -84,6 +93,14 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. +.. |maintainer-trisdoan| image:: https://github.com/trisdoan.png?size=40px + :target: https://github.com/trisdoan + :alt: trisdoan + +Current `maintainer `__: + +|maintainer-trisdoan| + This module is part of the `OCA/web `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/web_chatter_position/__manifest__.py b/web_chatter_position/__manifest__.py index 4318d9da4..42069f638 100644 --- a/web_chatter_position/__manifest__.py +++ b/web_chatter_position/__manifest__.py @@ -1,11 +1,14 @@ # Copyright 2022 Hynsys Technologies +# Copyright 2024 Alitec Pte Ltd # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). { "name": "Chatter Position", "summary": "Add an option to change the chatter position", - "version": "16.0.1.0.2", - "author": "Hynsys Technologies, Camptocamp, Odoo Community Association (OCA)", + "version": "17.0.1.0.1", + "author": "Hynsys Technologies, Camptocamp, Alitec Pte Ltd, " + "Odoo Community Association (OCA)", + "maintainers": ["trisdoan"], "website": "https://github.com/OCA/web", "license": "LGPL-3", "category": "Extra Tools", @@ -14,6 +17,7 @@ "assets": { "web.assets_backend": [ "/web_chatter_position/static/src/**/*.js", + "/web_chatter_position/static/src/**/*.scss", ], }, } diff --git a/web_chatter_position/i18n/hr.po b/web_chatter_position/i18n/hr.po index 1cd041315..d1cf4969d 100644 --- a/web_chatter_position/i18n/hr.po +++ b/web_chatter_position/i18n/hr.po @@ -13,8 +13,8 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" -"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" +"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && " +"n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" "X-Generator: Weblate 4.14.1\n" #. module: web_chatter_position diff --git a/web_chatter_position/i18n/web_chatter_position.pot b/web_chatter_position/i18n/web_chatter_position.pot index 4937f1d73..e70958cd4 100644 --- a/web_chatter_position/i18n/web_chatter_position.pot +++ b/web_chatter_position/i18n/web_chatter_position.pot @@ -4,7 +4,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 16.0\n" +"Project-Id-Version: Odoo Server 17.0\n" "Report-Msgid-Bugs-To: \n" "Last-Translator: \n" "Language-Team: \n" diff --git a/web_chatter_position/readme/CONTRIBUTORS.md b/web_chatter_position/readme/CONTRIBUTORS.md index eb5449f77..4909dbc2a 100644 --- a/web_chatter_position/readme/CONTRIBUTORS.md +++ b/web_chatter_position/readme/CONTRIBUTORS.md @@ -2,3 +2,7 @@ - Juan Miguel Sánchez Arce \<\> - [Camptocamp](https://www.camptocamp.com) - Iván Todorovich \<\> +- [Alitec Pte Ltd](http://www.alitec.sg) + - Jay Patel \<\> +- Trobz + - Tris Doan \<\> diff --git a/web_chatter_position/static/description/index.html b/web_chatter_position/static/description/index.html index d83fb1714..dee54fa00 100644 --- a/web_chatter_position/static/description/index.html +++ b/web_chatter_position/static/description/index.html @@ -367,7 +367,7 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:fbb006a9a99fbcf94cbb8823017ff08050ed9294fd3c81929e4a4b2e225ca61b +!! source digest: sha256:37fa43641cb746a03b8cb4f0492784abb34e5b511d0d318013dcee341b792da4 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Beta License: LGPL-3 OCA/web Translate me on Weblate Try me on Runboat

Configurable chatter position from the user preferences.

@@ -405,6 +405,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
  • Hynsys Technologies
  • Camptocamp
  • +
  • Alitec Pte Ltd
@@ -416,6 +417,14 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
  • Iván Todorovich <ivan.todorovich@camptocamp.com>
  • +
  • Alitec Pte Ltd +
  • +
  • Trobz +
  • @@ -427,6 +436,8 @@ If you spotted it first, help us to smash it by providing a detailed and welcome

    OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

    +

    Current maintainer:

    +

    trisdoan

    This module is part of the OCA/web project on GitHub.

    You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

    diff --git a/web_chatter_position/static/src/js/web_chatter_position.esm.js b/web_chatter_position/static/src/js/web_chatter_position.esm.js index 43425c1d6..42582fc4b 100644 --- a/web_chatter_position/static/src/js/web_chatter_position.esm.js +++ b/web_chatter_position/static/src/js/web_chatter_position.esm.js @@ -5,161 +5,85 @@ */ import {FormCompiler} from "@web/views/form/form_compiler"; -import {FormController} from "@web/views/form/form_controller"; -import {MailFormCompiler} from "@mail/views/form/form_compiler"; -import {append} from "@web/core/utils/xml"; import {patch} from "@web/core/utils/patch"; +import {append, setAttributes} from "@web/core/utils/xml"; +import {SIZES} from "@web/core/ui/ui_service"; -/** - * So, you've landed here and you have no idea what this is about. Don't worry, you're - * not the only one. Here's a quick summary of what's going on: - * - * In core, the chatter position depends on the size of the screen and wether there is - * an attachment viewer or not. There are 3 possible positions, and for each position a - * different chatter instance is displayed. - * - * So, in fact, we have 3 chatter instances running, and we switch their visibility - * depending on the desired position. - * - * A) Bottom position - * https://github.com/odoo/odoo/blob/2ef010907/addons/mail/static/src/views/form/form_compiler.js#L160 - * Condition: `!this.props.hasAttachmentViewer and uiService.size < ${SIZES.XXL}` - * - * This is the bottom position you would except. However it can only be there until - * XXL screen sizes, because the container is a flexbox and changes from row to - * column display. It's hidden in the presence of an attachment viewer. - * - * B) Bottom In-sheet position - * https://github.com/odoo/odoo/blob/2ef010907/addons/mail/static/src/views/form/form_compiler.js#L181 - * Condition: `this.props.hasAttachmentViewer` - * - * This is the bottom position that's used when there's an attachment viewer in place. - * It's rendered within the form sheet, possibly to by-pass the flexbox issue - * beforementioned. It's only instanciated when there's an attachment viewer. - * - * C) Sided position - * https://github.com/odoo/odoo/blob/2ef010907/addons/mail/static/src/views/form/form_compiler.js#L83 - * Condition: `!hasAttachmentViewer() and uiService.size >= ${SIZES.XXL}` - * - * This is the sided position, hidden in the presence of an attachment viewer. - * It's the better half of `A`. - * - * The patches and overrides you see below are here to alter these conditions to force - * a specific position regardless of the screen size, depending on an user setting. - */ - -patch(MailFormCompiler.prototype, "web_chatter_position", { +patch(FormCompiler.prototype, { /** - * Patch the visibility of the Sided chatter (`C` above). - * - * @override - */ - compile() { - const res = this._super.apply(this, arguments); - const chatterContainerHookXml = res.querySelector( - ".o_FormRenderer_chatterContainer" - ); - if (!chatterContainerHookXml) { - return res; - } - // Don't patch anything if the setting is "auto": this is the core behaviour - if (odoo.web_chatter_position === "auto") { - return res; - } else if (odoo.web_chatter_position === "sided") { - chatterContainerHookXml.setAttribute("t-if", "!hasAttachmentViewer()"); - } else if (odoo.web_chatter_position === "bottom") { - chatterContainerHookXml.setAttribute("t-if", false); - } - return res; - }, -}); - -patch(FormCompiler.prototype, "web_chatter_position", { - /** - * Patch the css classes of the `Form`, to include an extra `h-100` class. - * Without it, the form sheet will not be full height in some situations, - * looking a bit weird. - * - * @override - */ - compileForm() { - const res = this._super.apply(this, arguments); - if (odoo.web_chatter_position === "sided") { - const classes = res.getAttribute("t-attf-class"); - res.setAttribute("t-attf-class", `${classes} h-100`); - } - return res; - }, - /** - * Patch the visibility of bottom chatters (`A` and `B` above). - * `B` may not exist in some situations, so we ensure it does by creating it. - * * @override */ compile(node, params) { - const res = this._super.apply(this, arguments); + const res = super.compile(node, params); + const webClientViewAttachmentViewHookXml = res.querySelector( + ".o_attachment_preview" + ); const chatterContainerHookXml = res.querySelector( - ".o_FormRenderer_chatterContainer:not(.o-isInFormSheetBg)" + ".o-mail-Form-chatter:not(.o-isInFormSheetBg)" ); if (!chatterContainerHookXml) { - return res; + return res; // No chatter, keep the result as it is } - if (chatterContainerHookXml.parentNode.classList.contains("o_form_sheet")) { - return res; + const chatterContainerXml = chatterContainerHookXml.querySelector( + "t[t-component='__comp__.mailComponents.Chatter']" + ); + const formSheetBgXml = res.querySelector(".o_form_sheet_bg"); + const parentXml = formSheetBgXml && formSheetBgXml.parentNode; + if (!parentXml) { + return res; // Miss-config: a sheet-bg is required for the rest } + // Don't patch anything if the setting is "auto": this is the core behaviour if (odoo.web_chatter_position === "auto") { return res; // For "sided", we have to remote the bottom chatter // (except if there is an attachment viewer, as we have to force bottom) } else if (odoo.web_chatter_position === "sided") { - const formSheetBgXml = res.querySelector(".o_form_sheet_bg"); - if (!formSheetBgXml) { - return res; - } - chatterContainerHookXml.setAttribute("t-if", false); + setAttributes(chatterContainerXml, { + isInFormSheetBg: `__comp__.uiService.size < ${SIZES.XXL}`, + isChatterAside: `__comp__.uiService.size >= ${SIZES.XXL}`, + }); + setAttributes(chatterContainerHookXml, { + "t-attf-class": `{{ __comp__.uiService.size >= ${SIZES.XXL} ? "o-aside" : "" }}`, + }); // For "bottom", we keep the chatter in the form sheet // (the one used for the attachment viewer case) // If it's not there, we create it. } else if (odoo.web_chatter_position === "bottom") { - if (params.hasAttachmentViewerInArch) { + if (webClientViewAttachmentViewHookXml) { const sheetBgChatterContainerHookXml = res.querySelector( - ".o_FormRenderer_chatterContainer.o-isInFormSheetBg" + ".o-mail-Form-chatter.o-isInFormSheetBg" ); - sheetBgChatterContainerHookXml.setAttribute("t-if", true); - chatterContainerHookXml.setAttribute("t-if", false); + setAttributes(sheetBgChatterContainerHookXml, { + "t-if": "true", + }); + setAttributes(chatterContainerHookXml, { + "t-if": "false", + }); } else { - const formSheetBgXml = res.querySelector(".o_form_sheet_bg"); - if (!formSheetBgXml) { - return res; - } const sheetBgChatterContainerHookXml = chatterContainerHookXml.cloneNode(true); sheetBgChatterContainerHookXml.classList.add("o-isInFormSheetBg"); - sheetBgChatterContainerHookXml.setAttribute("t-if", true); + setAttributes(sheetBgChatterContainerHookXml, { + "t-if": "true", + "t-attf-class": `{{ (__comp__.uiService.size >= ${SIZES.XXL} && ${ + odoo.web_chatter_position != "bottom" + }) ? "o-aside" : "mt-4 mt-md-0" }}`, + }); append(formSheetBgXml, sheetBgChatterContainerHookXml); const sheetBgChatterContainerXml = - sheetBgChatterContainerHookXml.querySelector("ChatterContainer"); - sheetBgChatterContainerXml.setAttribute("isInFormSheetBg", "true"); - chatterContainerHookXml.setAttribute("t-if", false); + sheetBgChatterContainerHookXml.querySelector( + "t[t-component='__comp__.mailComponents.Chatter']" + ); + + setAttributes(sheetBgChatterContainerXml, { + isInFormSheetBg: "true", + }); + setAttributes(chatterContainerHookXml, { + "t-if": "false", + }); } } return res; }, }); - -patch(FormController.prototype, "web_chatter_position", { - /** - * Patch the css classes of the form container, to include an extra `flex-row` class. - * Without it, it'd go for flex columns direction and it won't look good. - * - * @override - */ - get className() { - const result = this._super(); - if (odoo.web_chatter_position === "sided") { - result["flex-row"] = true; - } - return result; - }, -}); diff --git a/web_chatter_position/static/src/scss/form_controller.scss b/web_chatter_position/static/src/scss/form_controller.scss new file mode 100644 index 000000000..a2fadf4c2 --- /dev/null +++ b/web_chatter_position/static/src/scss/form_controller.scss @@ -0,0 +1,17 @@ +/* + Copyright 2024 Alitec Pte Ltd (https://www.alitec.sg). + License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). +*/ + +.o_form_view { + .o_form_sheet_bg { + max-width: none; + } + .o_form_sheet { + max-width: $o-form-view-sheet-max-width; + width: 100%; + @include media-breakpoint-up(md) { + margin: $o-sheet-vpadding * 0.2 auto; + } + } +} diff --git a/web_chatter_position/static/src/scss/form_renderer.scss b/web_chatter_position/static/src/scss/form_renderer.scss new file mode 100644 index 000000000..e0ef94edd --- /dev/null +++ b/web_chatter_position/static/src/scss/form_renderer.scss @@ -0,0 +1,10 @@ +/* + Copyright 2024 Alitec Pte Ltd (https://www.alitec.sg). + License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). +*/ + +.o-mail-Form-chatter { + &:not(.o-aside):not(.o-full-width) .o-mail-Chatter { + max-width: $o-form-view-sheet-max-width; + } +} diff --git a/web_chatter_position/static/src/scss/form_statusbar.scss b/web_chatter_position/static/src/scss/form_statusbar.scss new file mode 100644 index 000000000..8e28cb771 --- /dev/null +++ b/web_chatter_position/static/src/scss/form_statusbar.scss @@ -0,0 +1,3 @@ +.o_xxl_form_view .o_form_sheet_bg .o_form_sheet { + overflow: unset !important; +}