[FIX] mail: fix and clean display of chatter in new form views
Fix display conditions, clean duplicate code. Follow up of https://github.com/odoo/odoo/pull/100570 And follow up of https://github.com/odoo/odoo/pull/98101/ (for the SCSS part) task-3003947 closes odoo/odoo#102165 X-original-commit: 6c6d7ce06ed4b18162db893a0afb65e0479ee11f Related: odoo/enterprise#32290 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
@@ -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;
|
||||
},
|
||||
});
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
</t>
|
||||
</xpath>
|
||||
<xpath expr="//Layout/t[@t-component='props.Renderer']" position="attributes">
|
||||
<attribute name="hasAttachmentViewer">hasAttachmentViewerInArch</attribute>
|
||||
<attribute name="hasAttachmentViewerInArch">hasAttachmentViewerInArch</attribute>
|
||||
<attribute name="hasAttachmentViewer">hasAttachmentViewer()</attribute>
|
||||
</xpath>
|
||||
</t>
|
||||
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user