Skip to content

Commit 8470908

Browse files
committed
Updates
1 parent 1815374 commit 8470908

5 files changed

Lines changed: 21 additions & 8 deletions

File tree

attachment_preview/__manifest__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
"attachment_preview/static/src/js/utils.esm.js",
2020
"attachment_preview/static/src/js/mail_core/attachment_list.esm.js",
2121
"attachment_preview/static/src/js/web_views/fields/binary_field.esm.js",
22-
"attachment_preview/static/src/js/web_views/form/form_renderer.esm.js",
2322
"attachment_preview/static/src/js/web_views/form/form_compiler.esm.js",
23+
"attachment_preview/static/src/js/web_views/form/form_controller.esm.js",
24+
"attachment_preview/static/src/js/web_views/form/form_renderer.esm.js",
2425
"attachment_preview/static/src/scss/attachment_preview.scss",
2526
"attachment_preview/static/src/xml/attachment_preview.xml",
2627
],

attachment_preview/static/src/js/attachmentPreviewWidget.esm.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ export class AttachmentPreviewWidget extends Component {
1212
({detail: {attachment_id, attachment_info_list}}) =>
1313
this._onAttachmentPreview(attachment_id, attachment_info_list)
1414
);
15+
Component.env.bus.addEventListener("hide_attachment_preview", this.hide);
1516
this.state = useState({activeIndex: 0});
16-
this.rootRef = useRef("root");
1717
this.currentRef = useRef("current");
1818
this.iframeRef = useRef("iframe");
1919
onWillStart(async () => {
@@ -60,13 +60,11 @@ export class AttachmentPreviewWidget extends Component {
6060
}
6161

6262
show() {
63-
$(this.rootRef.el).removeClass("d-none");
64-
Component.env.bus.trigger("shown");
63+
$(".attachment_preview_widget").removeClass("d-none");
6564
}
6665

6766
hide() {
68-
$(this.rootRef.el).addClass("d-none");
69-
Component.env.bus.trigger("hidden");
67+
$(".attachment_preview_widget").addClass("d-none");
7068
}
7169

7270
updatePaginator() {
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import {FormController} from "@web/views/form/form_controller";
2+
import {patch} from "@web/core/utils/patch";
3+
4+
patch(FormController.prototype, {
5+
onWillLoadRoot(nextConfiguration) {
6+
super.onWillLoadRoot(...arguments);
7+
const isSameThread =
8+
this.model.root?.resId === nextConfiguration.resId &&
9+
this.model.root?.resModel === nextConfiguration.resModel;
10+
if (!isSameThread) {
11+
this.env.bus.trigger("hide_attachment_preview");
12+
}
13+
},
14+
});

attachment_preview/static/src/scss/attachment_preview.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
left: 65.3%;
1212
width: 100%;
1313
height: 100%;
14-
z-index: 10;
14+
z-index: 20;
1515
}
1616
.attachment_preview_iframe {
1717
width: 36%;

attachment_preview/static/src/xml/attachment_preview.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
</t>
4040

4141
<t t-name="attachment_preview.AttachmentPreviewWidget">
42-
<div class="attachment_preview_widget d-none" t-ref="root">
42+
<div class="attachment_preview_widget d-none">
4343
<div class="attachment_preview_buttons">
4444
<div class="button-group pull-left">
4545
<button

0 commit comments

Comments
 (0)