From 3a7ad5285737d57f2c855372a837eaf39199baf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20K=C3=BChn?= Date: Fri, 1 Apr 2022 14:10:23 +0000 Subject: [PATCH] [IMP] mail: introduce AttachmentViewer/previous Task-2579306 Part-of: odoo/odoo#88152 --- .../attachment_viewer/attachment_viewer.js | 16 ++-------------- .../mail/static/src/models/attachment_viewer.js | 11 ++++++++++- 2 files changed, 12 insertions(+), 15 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 be90205c4a9..f5f02da6990 100644 --- a/addons/mail/static/src/components/attachment_viewer/attachment_viewer.js +++ b/addons/mail/static/src/components/attachment_viewer/attachment_viewer.js @@ -117,18 +117,6 @@ export class AttachmentViewer extends Component { } } - /** - * Display the previous attachment in the list of attachments. - * - * @private - */ - _previous() { - if (!this.attachmentViewer.dialogOwner || !this.attachmentViewer.dialogOwner.attachmentListOwnerAsAttachmentView) { - return; - } - this.attachmentViewer.dialogOwner.attachmentListOwnerAsAttachmentView.selectPreviousAttachment(); - } - /** * Prompt the browser print of this attachment. * @@ -291,7 +279,7 @@ export class AttachmentViewer extends Component { */ _onClickPrevious(ev) { ev.stopPropagation(); - this._previous(); + this.attachmentViewer.previous(); } /** @@ -359,7 +347,7 @@ export class AttachmentViewer extends Component { this.attachmentViewer.next(); break; case 'ArrowLeft': - this._previous(); + this.attachmentViewer.previous(); break; case 'Escape': this.attachmentViewer.close(); diff --git a/addons/mail/static/src/models/attachment_viewer.js b/addons/mail/static/src/models/attachment_viewer.js index 186c1a8db75..0036e77fd8a 100644 --- a/addons/mail/static/src/models/attachment_viewer.js +++ b/addons/mail/static/src/models/attachment_viewer.js @@ -23,7 +23,7 @@ registerModel({ return Boolean(this.component && this.component.root.el && this.component.root.el.contains(element)); }, /** - * Display the previous attachment in the list of attachments. + * Display the next attachment in the list of attachments. */ next() { if (!this.dialogOwner || !this.dialogOwner.attachmentListOwnerAsAttachmentView) { @@ -103,6 +103,15 @@ registerModel({ ev.stopPropagation(); this.update({ isImageLoading: false }); }, + /** + * Display the previous attachment in the list of attachments. + */ + previous() { + if (!this.dialogOwner || !this.dialogOwner.attachmentListOwnerAsAttachmentView) { + return; + } + this.dialogOwner.attachmentListOwnerAsAttachmentView.selectPreviousAttachment(); + }, /** * @private * @returns {string}