This commit is contained in:
Anjeel Haria
2025-12-11 10:01:41 +05:30
parent 181537468d
commit 8470908964
5 changed files with 21 additions and 8 deletions

View File

@@ -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",
],

View File

@@ -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() {

View File

@@ -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");
}
},
});

View File

@@ -11,7 +11,7 @@
left: 65.3%;
width: 100%;
height: 100%;
z-index: 10;
z-index: 20;
}
.attachment_preview_iframe {
width: 36%;

View File

@@ -39,7 +39,7 @@
</t>
<t t-name="attachment_preview.AttachmentPreviewWidget">
<div class="attachment_preview_widget d-none" t-ref="root">
<div class="attachment_preview_widget d-none">
<div class="attachment_preview_buttons">
<div class="button-group pull-left">
<button