From 591f3da27ed7f4c3547478f4a7db21ea3a7aee42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20K=C3=BChn?= Date: Fri, 1 Apr 2022 13:31:47 +0000 Subject: [PATCH] [IMP] mail: introduce AttachmentViewer/close Task-2579306 Part-of: odoo/odoo#88152 --- .../attachment_viewer/attachment_viewer.js | 17 ++++------------- .../mail/static/src/models/attachment_viewer.js | 6 ++++++ 2 files changed, 10 insertions(+), 13 deletions(-) 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 7cab8501f35..2b43c5a17bd 100644 --- a/addons/mail/static/src/components/attachment_viewer/attachment_viewer.js +++ b/addons/mail/static/src/components/attachment_viewer/attachment_viewer.js @@ -86,15 +86,6 @@ export class AttachmentViewer extends Component { // Private //-------------------------------------------------------------------------- - /** - * Close the dialog with this attachment viewer. - * - * @private - */ - _close() { - this.attachmentViewer.delete(); - } - /** * Determine whether the current image is rendered for the 1st time, and if * that's the case, display a spinner until loaded. @@ -290,7 +281,7 @@ export class AttachmentViewer extends Component { } // TODO: clicking on the background should probably be handled by the dialog? // task-2092965 - this._close(); + this.attachmentViewer.close(); } /** @@ -300,7 +291,7 @@ export class AttachmentViewer extends Component { * @param {MouseEvent} ev */ _onClickClose(ev) { - this._close(); + this.attachmentViewer.close(); } /** @@ -455,10 +446,10 @@ export class AttachmentViewer extends Component { this._previous(); break; case 'Escape': - this._close(); + this.attachmentViewer.close(); break; case 'q': - this._close(); + this.attachmentViewer.close(); break; case 'r': this._rotate(); diff --git a/addons/mail/static/src/models/attachment_viewer.js b/addons/mail/static/src/models/attachment_viewer.js index ffe17cf8a06..9123e61b594 100644 --- a/addons/mail/static/src/models/attachment_viewer.js +++ b/addons/mail/static/src/models/attachment_viewer.js @@ -7,6 +7,12 @@ registerModel({ name: 'AttachmentViewer', identifyingFields: ['dialogOwner'], recordMethods: { + /** + * Close the dialog with this attachment viewer. + */ + close() { + this.delete(); + }, /** * Returns whether the given html element is inside this attachment viewer. *