summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/js/composer.js
diff options
context:
space:
mode:
authorjpr-odoo <jpr@openerp.com>2017-09-04 18:18:12 +0200
committerYannick Tivisse <yti@odoo.com>2017-09-05 15:52:15 +0200
commit46699c5214229ea8aebcc04e08d0786fd2b67f35 (patch)
tree60f74e793b442ba8d2379f68743fb5a4724472e0 /addons/mail/static/src/js/composer.js
parentfa432175e991be13035757e5174625f954bae171 (diff)
[IMP] mail: Add a preview popup for attachments
Purpose ======= The goal is that when you click on an attachment, you should get a preview of it and then you get the possibility to download it.
Diffstat (limited to 'addons/mail/static/src/js/composer.js')
-rw-r--r--addons/mail/static/src/js/composer.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/addons/mail/static/src/js/composer.js b/addons/mail/static/src/js/composer.js
index 29806a08e51..f4ba98696a5 100644
--- a/addons/mail/static/src/js/composer.js
+++ b/addons/mail/static/src/js/composer.js
@@ -2,6 +2,7 @@ odoo.define('mail.composer', function (require) {
"use strict";
var chat_mixin = require('mail.chat_mixin');
+var DocumentViewer = require('mail.DocumentViewer');
var utils = require('mail.utils');
var core = require('web.core');
@@ -354,6 +355,8 @@ var BasicComposer = Widget.extend(chat_mixin, {
"click .o_composer_button_send": "send_message",
"click .o_composer_button_add_attachment": "on_click_add_attachment",
"click .o_attachment_delete": "on_attachment_delete",
+ "click .o_attachment_download": "_onAttachmentDownload",
+ "click .o_attachment_view": "_onAttachmentView",
},
// RPCs done to fetch the mention suggestions are throttled with the following value
MENTION_THROTTLE: 200,
@@ -758,6 +761,29 @@ var BasicComposer = Widget.extend(chat_mixin, {
focus: function () {
this.$input.focus();
},
+ //--------------------------------------------------------------------------
+ // Handlers
+ //--------------------------------------------------------------------------
+
+ /**
+ * @private
+ * @param {MouseEvent} event
+ */
+ _onAttachmentDownload: function (event) {
+ event.stopPropagation();
+ },
+ /**
+ * @private
+ * @param {MouseEvent} event
+ */
+ _onAttachmentView: function (event) {
+ var activeAttachmentID = $(event.currentTarget).data('id');
+ var attachments = this.get('attachment_ids');
+ if (activeAttachmentID) {
+ var attachmentViewer = new DocumentViewer(this, attachments, activeAttachmentID);
+ attachmentViewer.appendTo($('body'));
+ }
+ },
});
var ExtendedComposer = BasicComposer.extend({