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 6570df37d43..219cb44c481 100644 --- a/addons/mail/static/src/components/attachment_viewer/attachment_viewer.js +++ b/addons/mail/static/src/components/attachment_viewer/attachment_viewer.js @@ -79,29 +79,6 @@ export class AttachmentViewer extends Component { return this.messaging && this.messaging.models['AttachmentViewer'].get(this.props.localId); } - /** - * Compute the style of the image (scale + rotation). - * - * @returns {string} - */ - get imageStyle() { - const attachmentViewer = this.attachmentViewer; - let style = `transform: ` + - `scale3d(${attachmentViewer.scale}, ${attachmentViewer.scale}, 1) ` + - `rotate(${attachmentViewer.angle}deg);`; - - if (attachmentViewer.angle % 180 !== 0) { - style += `` + - `max-height: ${window.innerWidth}px; ` + - `max-width: ${window.innerHeight}px;`; - } else { - style += `` + - `max-height: 100%; ` + - `max-width: 100%;`; - } - return style; - } - //-------------------------------------------------------------------------- // Private //-------------------------------------------------------------------------- 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 09fcd963418..641d6bd64b0 100644 --- a/addons/mail/static/src/components/attachment_viewer/attachment_viewer.xml +++ b/addons/mail/static/src/components/attachment_viewer/attachment_viewer.xml @@ -43,7 +43,7 @@ - Viewer + Viewer diff --git a/addons/mail/static/src/models/attachment_viewer/attachment_viewer.js b/addons/mail/static/src/models/attachment_viewer/attachment_viewer.js index da956f57ca8..ffe17cf8a06 100644 --- a/addons/mail/static/src/models/attachment_viewer/attachment_viewer.js +++ b/addons/mail/static/src/models/attachment_viewer/attachment_viewer.js @@ -30,6 +30,26 @@ registerModel({ const accessToken = this.attachment.accessToken ? `?access_token=${this.attachment.accessToken}` : ''; return `/web/image/${this.attachment.id}${accessToken}`; }, + /** + * @private + * @returns {string} + */ + _computeImageStyle() { + let style = `transform: ` + + `scale3d(${this.scale}, ${this.scale}, 1) ` + + `rotate(${this.angle}deg);`; + + if (this.angle % 180 !== 0) { + style += `` + + `max-height: ${window.innerWidth}px; ` + + `max-width: ${window.innerHeight}px;`; + } else { + style += `` + + `max-height: 100%; ` + + `max-width: 100%;`; + } + return style; + }, }, fields: { /** @@ -60,6 +80,12 @@ registerModel({ isCausal: true, readonly: true, }), + /** + * Style of the image (scale + rotation). + */ + imageStyle: attr({ + compute: '_computeImageStyle', + }), /** * Determines the source URL to use for the image. */