From 84709089646e271888e284f1a389e0e9660ab9db Mon Sep 17 00:00:00 2001 From: Anjeel Haria Date: Thu, 11 Dec 2025 10:01:41 +0530 Subject: [PATCH] Updates --- attachment_preview/__manifest__.py | 3 ++- .../static/src/js/attachmentPreviewWidget.esm.js | 8 +++----- .../src/js/web_views/form/form_controller.esm.js | 14 ++++++++++++++ .../static/src/scss/attachment_preview.scss | 2 +- .../static/src/xml/attachment_preview.xml | 2 +- 5 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 attachment_preview/static/src/js/web_views/form/form_controller.esm.js diff --git a/attachment_preview/__manifest__.py b/attachment_preview/__manifest__.py index 5d7d128d..ba3a98aa 100644 --- a/attachment_preview/__manifest__.py +++ b/attachment_preview/__manifest__.py @@ -19,8 +19,9 @@ "attachment_preview/static/src/js/utils.esm.js", "attachment_preview/static/src/js/mail_core/attachment_list.esm.js", "attachment_preview/static/src/js/web_views/fields/binary_field.esm.js", - "attachment_preview/static/src/js/web_views/form/form_renderer.esm.js", "attachment_preview/static/src/js/web_views/form/form_compiler.esm.js", + "attachment_preview/static/src/js/web_views/form/form_controller.esm.js", + "attachment_preview/static/src/js/web_views/form/form_renderer.esm.js", "attachment_preview/static/src/scss/attachment_preview.scss", "attachment_preview/static/src/xml/attachment_preview.xml", ], diff --git a/attachment_preview/static/src/js/attachmentPreviewWidget.esm.js b/attachment_preview/static/src/js/attachmentPreviewWidget.esm.js index 431969be..845ccc78 100644 --- a/attachment_preview/static/src/js/attachmentPreviewWidget.esm.js +++ b/attachment_preview/static/src/js/attachmentPreviewWidget.esm.js @@ -12,8 +12,8 @@ export class AttachmentPreviewWidget extends Component { ({detail: {attachment_id, attachment_info_list}}) => this._onAttachmentPreview(attachment_id, attachment_info_list) ); + Component.env.bus.addEventListener("hide_attachment_preview", this.hide); this.state = useState({activeIndex: 0}); - this.rootRef = useRef("root"); this.currentRef = useRef("current"); this.iframeRef = useRef("iframe"); onWillStart(async () => { @@ -60,13 +60,11 @@ export class AttachmentPreviewWidget extends Component { } show() { - $(this.rootRef.el).removeClass("d-none"); - Component.env.bus.trigger("shown"); + $(".attachment_preview_widget").removeClass("d-none"); } hide() { - $(this.rootRef.el).addClass("d-none"); - Component.env.bus.trigger("hidden"); + $(".attachment_preview_widget").addClass("d-none"); } updatePaginator() { diff --git a/attachment_preview/static/src/js/web_views/form/form_controller.esm.js b/attachment_preview/static/src/js/web_views/form/form_controller.esm.js new file mode 100644 index 00000000..5ab739f4 --- /dev/null +++ b/attachment_preview/static/src/js/web_views/form/form_controller.esm.js @@ -0,0 +1,14 @@ +import {FormController} from "@web/views/form/form_controller"; +import {patch} from "@web/core/utils/patch"; + +patch(FormController.prototype, { + onWillLoadRoot(nextConfiguration) { + super.onWillLoadRoot(...arguments); + const isSameThread = + this.model.root?.resId === nextConfiguration.resId && + this.model.root?.resModel === nextConfiguration.resModel; + if (!isSameThread) { + this.env.bus.trigger("hide_attachment_preview"); + } + }, +}); diff --git a/attachment_preview/static/src/scss/attachment_preview.scss b/attachment_preview/static/src/scss/attachment_preview.scss index 8f030619..c222cb85 100644 --- a/attachment_preview/static/src/scss/attachment_preview.scss +++ b/attachment_preview/static/src/scss/attachment_preview.scss @@ -11,7 +11,7 @@ left: 65.3%; width: 100%; height: 100%; - z-index: 10; + z-index: 20; } .attachment_preview_iframe { width: 36%; diff --git a/attachment_preview/static/src/xml/attachment_preview.xml b/attachment_preview/static/src/xml/attachment_preview.xml index 315c3048..06fa74c6 100644 --- a/attachment_preview/static/src/xml/attachment_preview.xml +++ b/attachment_preview/static/src/xml/attachment_preview.xml @@ -39,7 +39,7 @@ -
+