summaryrefslogtreecommitdiff
path: root/web-ui/app/js/mail_view
diff options
context:
space:
mode:
authorJefferson Stachelski <jstachel@thoughtworks.com>2016-02-01 17:50:06 -0200
committerJefferson Stachelski <jstachel@thoughtworks.com>2016-02-01 17:50:47 -0200
commite3939d4c1dff0f152fa13ce8a89f751c79ecace2 (patch)
tree67bfc6d9024a271ece8b306101304a01f1f96962 /web-ui/app/js/mail_view
parentc7c8607665de3fbe7238436c6b6b240673549aec (diff)
Issue #549 - Implemented UI part of remote attachments
Diffstat (limited to 'web-ui/app/js/mail_view')
-rw-r--r--web-ui/app/js/mail_view/ui/attachment_list.js16
-rw-r--r--web-ui/app/js/mail_view/ui/draft_box.js17
-rw-r--r--web-ui/app/js/mail_view/ui/forward_box.js17
3 files changed, 45 insertions, 5 deletions
diff --git a/web-ui/app/js/mail_view/ui/attachment_list.js b/web-ui/app/js/mail_view/ui/attachment_list.js
index f0581c67..3def6870 100644
--- a/web-ui/app/js/mail_view/ui/attachment_list.js
+++ b/web-ui/app/js/mail_view/ui/attachment_list.js
@@ -53,15 +53,25 @@ define(
this.renderAttachmentListView = function (data) {
var currentHtml = this.select('attachmentListItem').html();
var item = this.buildAttachmentListItem(data);
- this.select('attachmentListItem').html(currentHtml + item);
+ this.select('attachmentListItem').append(item);
};
this.buildAttachmentListItem = function (attachment) {
var attachmentData = {ident: attachment.ident,
encoding: attachment.encoding,
name: attachment.name,
- size: attachment.size};
- return templates.compose.attachmentItem(attachmentData);
+ size: attachment.size,
+ removable: true};
+
+ var element = $(templates.compose.attachmentItem(attachmentData));
+ var self = this;
+ element.find('i.remove-icon').bind('click', function(event) {
+ var element = $(this);
+ var ident = element.closest('li').attr('data-ident');
+ self.trigger(document, events.mail.removeAttachment, {ident: ident});
+ event.preventDefault();
+ });
+ return element;
};
this.checkAttachmentSize = function(e, data) {
diff --git a/web-ui/app/js/mail_view/ui/draft_box.js b/web-ui/app/js/mail_view/ui/draft_box.js
index 88051f30..07a7e472 100644
--- a/web-ui/app/js/mail_view/ui/draft_box.js
+++ b/web-ui/app/js/mail_view/ui/draft_box.js
@@ -64,7 +64,15 @@ define(
},
subject: mail.header.subject,
body: body,
- attachments: mail.attachments
+ attachments: this.convertToRemovableAttachments(mail.attachments)
+ });
+
+ var self = this;
+ this.$node.find('i.remove-icon').bind('click', function(event) {
+ var element = $(this);
+ var ident = element.closest('li').attr('data-ident');
+ self.trigger(document, events.mail.removeAttachment, {ident: ident});
+ event.preventDefault();
});
this.enableFloatlabel('input.floatlabel');
@@ -77,6 +85,13 @@ define(
this.on(this.select('closeMailButton'), 'click', this.showNoMessageSelected);
};
+ this.convertToRemovableAttachments = function(attachments) {
+ return attachments.map(function(attachment) {
+ attachment.removable = true;
+ return attachment;
+ });
+ };
+
this.mailDeleted = function(event, data) {
if (_.contains(_.pluck(data.mails, 'ident'), this.attr.ident)) {
this.trigger(events.dispatchers.rightPane.openNoMessageSelected);
diff --git a/web-ui/app/js/mail_view/ui/forward_box.js b/web-ui/app/js/mail_view/ui/forward_box.js
index a1b8dc41..3d643b2f 100644
--- a/web-ui/app/js/mail_view/ui/forward_box.js
+++ b/web-ui/app/js/mail_view/ui/forward_box.js
@@ -46,14 +46,29 @@ define(
subject: this.attr.subject,
recipients: { to: [], cc: []},
body: viewHelper.quoteMail(mail),
- attachments: mail.attachments
+ attachments: this.convertToRemovableAttachments(mail.attachments)
});
+ var self = this;
+ this.$node.find('i.remove-icon').bind('click', function(event) {
+ var element = $(this);
+ var ident = element.closest('li').attr('data-ident');
+ self.trigger(document, events.mail.removeAttachment, {ident: ident});
+ event.preventDefault();
+ });
+
this.on(this.select('subjectDisplay'), 'click', this.showSubjectInput);
this.select('recipientsDisplay').hide();
this.select('recipientsFields').show();
};
+ this.convertToRemovableAttachments = function(attachments) {
+ return attachments.map(function(attachment) {
+ attachment.removable = true;
+ return attachment;
+ });
+ };
+
this.showSubjectInput = function() {
this.select('subjectDisplay').hide();
this.select('subjectInput').show();