From f2d0995362ccdae88ba64597ea6f0feca3eab618 Mon Sep 17 00:00:00 2001 From: Thanh Dodeur Date: Thu, 4 Apr 2019 09:24:34 +0000 Subject: [PATCH] [FIX] mail: fixes document viewer's url preview MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit fixes the document viewer: the document viewer was altering the `type` key of attachment objects, this issue was causing matching errors in some cases. With this commit, the document viewer widget uses its own key `attachment.fileType` to store the information that used to override `attachment.type` closes odoo/odoo#32414 Signed-off-by: Alexandre Kühn (aku) --- addons/mail/static/src/js/document_viewer.js | 5 ++--- addons/mail/static/src/xml/thread.xml | 20 +++++++++---------- .../static/tests/document_viewer_tests.js | 19 ++++++++++++++++++ 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/addons/mail/static/src/js/document_viewer.js b/addons/mail/static/src/js/document_viewer.js index 338b5889828..8b6f27b480e 100644 --- a/addons/mail/static/src/js/document_viewer.js +++ b/addons/mail/static/src/js/document_viewer.js @@ -44,11 +44,10 @@ var DocumentViewer = Widget.extend({ this._super.apply(this, arguments); this.attachment = _.filter(attachments, function (attachment) { var match = attachment.type === 'url' ? attachment.url.match("(youtu|.png|.jpg|.gif)") : attachment.mimetype.match("(image|video|application/pdf|text)"); - if (match) { - attachment.type = match[1]; + attachment.fileType = match[1]; if (match[1].match("(.png|.jpg|.gif)")) { - attachment.type = 'image'; + attachment.fileType = 'image'; } if (match[1] === 'youtu') { var youtube_array = attachment.url.split('/'); diff --git a/addons/mail/static/src/xml/thread.xml b/addons/mail/static/src/xml/thread.xml index be73917a1b5..6d8782cad97 100644 --- a/addons/mail/static/src/xml/thread.xml +++ b/addons/mail/static/src/xml/thread.xml @@ -38,9 +38,9 @@
- - - + + + @@ -48,19 +48,19 @@
-
+
- Viewer -