From d8fc0e07b90de4f17a7777545d41098f2864cb8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Theys?= Date: Tue, 5 Jul 2022 11:20:48 +0000 Subject: [PATCH] [IMP] mail: simplify conditions that control chatter position This better highlights the different cases that need to be handled. Part of task-2871070 Part-of: odoo/odoo#95323 --- .../widgets/form_renderer/form_renderer.js | 42 ++++++++----------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/addons/mail/static/src/widgets/form_renderer/form_renderer.js b/addons/mail/static/src/widgets/form_renderer/form_renderer.js index 34586864a1c..2c4929eee9c 100644 --- a/addons/mail/static/src/widgets/form_renderer/form_renderer.js +++ b/addons/mail/static/src/widgets/form_renderer/form_renderer.js @@ -156,31 +156,25 @@ FormRenderer.include({ */ _interchangeChatter() { const $sheetBg = this.$('.o_form_sheet_bg'); - if (this._isChatterAside()) { - this._chatterContainerTarget.classList.add('o-aside'); - this._chatterContainerTarget.classList.remove('o-isInFormSheetBg'); - $(this._chatterContainerTarget).insertAfter($sheetBg); - } else { - this._chatterContainerTarget.classList.remove('o-aside'); - if (this.isChatterInSheet) { - this._chatterContainerTarget.classList.remove('o-isInFormSheetBg'); - const $sheet = this.$('.o_form_sheet'); - dom.append($sheet, $(this._chatterContainerTarget), { - callbacks: [], - in_DOM: this._isInDom, - }); - } else { - if (this.hasAttachmentViewer()) { - this._chatterContainerTarget.classList.add('o-isInFormSheetBg'); - dom.append($sheetBg, $(this._chatterContainerTarget), { - callbacks: [], - in_DOM: this._isInDom, - }); - } else { - this._chatterContainerTarget.classList.remove('o-isInFormSheetBg'); - $(this._chatterContainerTarget).insertAfter($sheetBg); - } + this._chatterContainerTarget.classList.remove('o-aside'); + this._chatterContainerTarget.classList.remove('o-isInFormSheetBg'); + if (this.isChatterInSheet) { // in sheet + const $sheet = this.$('.o_form_sheet'); + dom.append($sheet, $(this._chatterContainerTarget), { + callbacks: [], + in_DOM: this._isInDom, + }); + } else if (this.hasAttachmentViewer()) { // in sheet-bg + this._chatterContainerTarget.classList.add('o-isInFormSheetBg'); + dom.append($sheetBg, $(this._chatterContainerTarget), { + callbacks: [], + in_DOM: this._isInDom, + }); + } else { // after sheet-bg + if (this._isChatterAside()) { + this._chatterContainerTarget.classList.add('o-aside'); } + $(this._chatterContainerTarget).insertAfter($sheetBg); } if (this.hasAttachmentViewer()) { $(this.attachmentViewerTarget).insertAfter($sheetBg);