From f3590959b0d33b859e09cd042cb2765ba39f0030 Mon Sep 17 00:00:00 2001 From: William Braeckman Date: Thu, 16 Jun 2022 11:58:21 +0000 Subject: [PATCH] [IMP] mail: improve attachment_viewer This commit improves the expendability of the attachment_viewer model and component by making it less dependent on attachment_list. This is required by the refactoring in wowl of the documents app(s). TaskId-2898342 closes odoo/odoo#94930 Related: odoo/enterprise#28976 Signed-off-by: Yannick Tivisse (yti) --- .../attachment_viewer/attachment_viewer.js | 8 +- .../attachment_viewer/attachment_viewer.xml | 38 ++--- addons/mail/static/src/models/attachment.js | 4 + .../static/src/models/attachment_viewer.js | 47 +++--- .../src/models/attachment_viewer_viewable.js | 134 ++++++++++++++++++ 5 files changed, 186 insertions(+), 45 deletions(-) create mode 100644 addons/mail/static/src/models/attachment_viewer_viewable.js diff --git a/addons/mail/static/src/components/attachment_viewer/attachment_viewer.js b/addons/mail/static/src/components/attachment_viewer/attachment_viewer.js index 9a05bbf6956..476c2860f12 100644 --- a/addons/mail/static/src/components/attachment_viewer/attachment_viewer.js +++ b/addons/mail/static/src/components/attachment_viewer/attachment_viewer.js @@ -93,13 +93,13 @@ export class AttachmentViewer extends Component { * @private */ _handleImageLoad() { - if (!this.attachmentViewer.exists() || !this.attachmentViewer.attachment) { + if (!this.attachmentViewer.exists() || !this.attachmentViewer.attachmentViewerViewable) { return; } const refs = this._getRefs(); - const image = refs[`image_${this.attachmentViewer.attachment.id}`]; + const image = refs[`image_${this.attachmentViewer.attachmentViewerViewable.localId}`]; if ( - this.attachmentViewer.attachment.isImage && + this.attachmentViewer.attachmentViewerViewable.isImage && (!image || !image.complete) ) { this.attachmentViewer.update({ isImageLoading: true }); @@ -142,7 +142,7 @@ export class AttachmentViewer extends Component { _updateZoomerStyle() { const attachmentViewer = this.attachmentViewer; const refs = this._getRefs(); - const image = refs[`image_${this.attachmentViewer.attachment.id}`]; + const image = refs[`image_${this.attachmentViewer.attachmentViewerViewable.localId}`]; const tx = image.offsetWidth * attachmentViewer.scale > this._zoomerRef.el.offsetWidth ? this._translate.x + this._translate.dx : 0; diff --git a/addons/mail/static/src/components/attachment_viewer/attachment_viewer.xml b/addons/mail/static/src/components/attachment_viewer/attachment_viewer.xml index d92ff351df5..994f3dd9072 100644 --- a/addons/mail/static/src/components/attachment_viewer/attachment_viewer.xml +++ b/addons/mail/static/src/components/attachment_viewer/attachment_viewer.xml @@ -5,24 +5,24 @@
- +
- + - + - + - +
- +
@@ -35,33 +35,33 @@
-
- +
+
- Viewer + Viewer
- -