diff --git a/addons/mail/static/src/views/form/form_compiler.js b/addons/mail/static/src/views/form/form_compiler.js index d6503c8741d..7e750ab1a1f 100644 --- a/addons/mail/static/src/views/form/form_compiler.js +++ b/addons/mail/static/src/views/form/form_compiler.js @@ -82,13 +82,19 @@ export class MailFormCompiler extends ViewCompiler { if (chatterContainerHookXml) { setAttributes(chatterContainerHookXml, { "t-if": `!hasAttachmentViewer() and uiService.size >= ${SIZES.XXL}`, - "t-attf-class": `{{ uiService.size >= ${SIZES.XXL} ? "o-aside" : "" }}`, + "t-attf-class": "o-aside", + }); + const chatterContainerXml = chatterContainerHookXml.querySelector('ChatterContainer'); + setAttributes(chatterContainerXml, { + "hasExternalBorder": "false", + "hasMessageListScrollAdjust": "true", + "isInFormSheetBg": "false", }); } const attachmentViewHookXml = res.querySelector(".o_attachment_preview"); if (attachmentViewHookXml) { setAttributes(attachmentViewHookXml, { - "t-if": `hasAttachmentViewer() and uiService.size >= ${SIZES.XXL}`, + "t-if": `hasAttachmentViewer()`, }); } return res; @@ -152,11 +158,12 @@ patch(FormCompiler.prototype, 'mail', { return res; // no chatter, keep the result as it is } const chatterContainerXml = chatterContainerHookXml.querySelector('ChatterContainer'); + setAttributes(chatterContainerXml, { + "hasExternalBorder": "true", + "hasMessageListScrollAdjust": "false", + "isInFormSheetBg": "false", + }); if (chatterContainerHookXml.parentNode.classList.contains('o_form_sheet')) { - setAttributes(chatterContainerXml, { - "hasExternalBorder": 'true', - "hasMessageListScrollAdjust": 'false', - }); return res; // if chatter is inside sheet, keep it there } const formSheetBgXml = res.querySelector('.o_form_sheet_bg'); @@ -164,33 +171,24 @@ patch(FormCompiler.prototype, 'mail', { if (!parentXml) { return res; // miss-config: a sheet-bg is required for the rest } - if (params.hasAttachmentViewer) { + if (params.hasAttachmentViewerInArch) { // in sheet bg (attachment viewer present) - const sheetBgChatterContainerHookXml = chatterContainerHookXml; + const sheetBgChatterContainerHookXml = chatterContainerHookXml.cloneNode(true); sheetBgChatterContainerHookXml.classList.add('o-isInFormSheetBg'); setAttributes(sheetBgChatterContainerHookXml, { - 't-if': `uiService.size < ${SIZES.XXL} or hasAttachmentViewer()`, + 't-if': `this.props.hasAttachmentViewer`, }); append(formSheetBgXml, sheetBgChatterContainerHookXml); const sheetBgChatterContainerXml = sheetBgChatterContainerHookXml.querySelector('ChatterContainer'); setAttributes(sheetBgChatterContainerXml, { "isInFormSheetBg": "true", - "hasExternalBorder": "true", - "hasMessageListScrollAdjust": "false", }); - } else { - // after sheet bg (standard position, either aside or below) - setAttributes(chatterContainerXml, { - "isInFormSheetBg": "false", - "hasExternalBorder": `uiService.size < ${SIZES.XXL}`, - "hasMessageListScrollAdjust": `uiService.size >= ${SIZES.XXL}`, - }); - setAttributes(chatterContainerHookXml, { - 't-if': `uiService.size < ${SIZES.XXL}`, - 't-attf-class': `{{ uiService.size >= ${SIZES.XXL} ? "o-aside" : "" }}`, - }); - append(parentXml, chatterContainerHookXml); } + // after sheet bg (standard position, below form) + setAttributes(chatterContainerHookXml, { + 't-if': `!this.props.hasAttachmentViewer and uiService.size < ${SIZES.XXL}`, + }); + append(parentXml, chatterContainerHookXml); return res; }, }); diff --git a/addons/mail/static/src/views/form/form_controller.js b/addons/mail/static/src/views/form/form_controller.js index 0920be0f0af..69525a5d54c 100644 --- a/addons/mail/static/src/views/form/form_controller.js +++ b/addons/mail/static/src/views/form/form_controller.js @@ -6,6 +6,7 @@ import { WebClientViewAttachmentViewContainer } from "@mail/components/web_clien import { browser } from "@web/core/browser/browser"; import { useService } from "@web/core/utils/hooks"; +import { SIZES } from "@web/core/ui/ui_service"; import { patch } from "@web/core/utils/patch"; import { useDebounced } from "@web/core/utils/timing"; import { FormController } from "@web/views/form/form_controller"; @@ -59,7 +60,12 @@ patch(FormController.prototype, "mail", { * @returns {boolean} */ hasAttachmentViewer() { - if (!this.getMessaging() || !this.model.root.resId) { + if ( + this.uiService.size < SIZES.XXL || + !this.hasAttachmentViewerInArch || + !this.getMessaging() || + !this.model.root.resId + ) { return false; } const thread = this.getMessaging().models['Thread'].insert({ diff --git a/addons/mail/static/src/views/form/form_controller.xml b/addons/mail/static/src/views/form/form_controller.xml index b15f4d7e4fd..2e30944ce92 100644 --- a/addons/mail/static/src/views/form/form_controller.xml +++ b/addons/mail/static/src/views/form/form_controller.xml @@ -8,7 +8,8 @@ - hasAttachmentViewerInArch + hasAttachmentViewerInArch + hasAttachmentViewer() diff --git a/addons/mail/static/src/views/form/form_renderer.js b/addons/mail/static/src/views/form/form_renderer.js index 82d84e74721..ef8c51f76fa 100644 --- a/addons/mail/static/src/views/form/form_renderer.js +++ b/addons/mail/static/src/views/form/form_renderer.js @@ -1,55 +1,19 @@ /** @odoo-module */ -import { useModels } from '@mail/component_hooks/use_models'; import { ChatterContainer } from "@mail/components/chatter_container/chatter_container"; -import { WebClientViewAttachmentViewContainer } from '@mail/components/web_client_view_attachment_view_container/web_client_view_attachment_view_container'; import { patch } from "@web/core/utils/patch"; import { FormRenderer } from "@web/views/form/form_renderer"; patch(FormRenderer.prototype, 'mail', { - setup() { - this._super(); - if (this.env.services.messaging) { - useModels(); - } - }, - get compileParams() { return { ...this._super(), - hasAttachmentViewer: this.props.hasAttachmentViewer, + hasAttachmentViewerInArch: this.props.hasAttachmentViewerInArch, }; }, - - //-------------------------------------------------------------------------- - // Mail Methods - //-------------------------------------------------------------------------- - - /** - * @returns {Messaging|undefined} - */ - getMessaging() { - return this.env.services.messaging && this.env.services.messaging.modelManager.messaging; - }, - /** - * @returns {boolean} - */ - hasAttachmentViewer() { - if (!this.getMessaging() || !this.props.record.resId) { - return false; - } - const thread = this.getMessaging().models['Thread'].insert({ - id: this.props.record.resId, - model: this.props.record.resModel, - }); - return ( - thread.attachmentsInWebClientView.length > 0 - ); - }, }); Object.assign(FormRenderer.components, { ChatterContainer, - WebClientViewAttachmentViewContainer, }); diff --git a/addons/mail/static/src/widgets/form_renderer/form_renderer.scss b/addons/mail/static/src/widgets/form_renderer/form_renderer.scss index aef5bcd2c61..e6ce0ae41a2 100644 --- a/addons/mail/static/src/widgets/form_renderer/form_renderer.scss +++ b/addons/mail/static/src/widgets/form_renderer/form_renderer.scss @@ -17,7 +17,8 @@ &.o-isInFormSheetBg { max-width: none; background-color: $white; - @include o-form-sheet-negative-margin; + margin-left: -$o-horizontal-padding; + margin-right: -$o-horizontal-padding; width: auto; border-top: 1px solid $border-color; }