From 34e71e0545c9d8e20c494e3784a4b7dcb14c505b Mon Sep 17 00:00:00 2001 From: NavaL Date: Mon, 8 Feb 2016 17:30:54 +0100 Subject: updated read.me Issue #593 --- haha.diff | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 haha.diff (limited to 'haha.diff') diff --git a/haha.diff b/haha.diff new file mode 100644 index 00000000..b4a59fc2 --- /dev/null +++ b/haha.diff @@ -0,0 +1,93 @@ +diff --git a/web-ui/app/js/mail_view/data/attachment_list.js b/web-ui/app/js/mail_view/data/attachment_list.js +index af48b05..0815cdf 100644 +--- a/web-ui/app/js/mail_view/data/attachment_list.js ++++ b/web-ui/app/js/mail_view/data/attachment_list.js +@@ -30,6 +30,7 @@ define( + + this.addAttachment = function (event, data) { + this.attr.attachments.push(data); ++ console.log(this.attr.attachments); + }; + + this.after('initialize', function () { +diff --git a/web-ui/app/js/mail_view/ui/attachment.js b/web-ui/app/js/mail_view/ui/attachment.js +index f57fea5..529bc97 100644 +--- a/web-ui/app/js/mail_view/ui/attachment.js ++++ b/web-ui/app/js/mail_view/ui/attachment.js +@@ -19,14 +19,15 @@ define( + [ + 'flight/lib/component', + 'page/events', +- 'features' ++ 'features', ++ 'helpers/monitored_ajax' + ], + +- function (defineComponent, events, features) { ++ function (defineComponent, events, features, monitoredAjax) { + 'use strict'; + + return defineComponent(function () { +- this.render = function () { ++ this.renderButton = function () { + this.$node.html(''); + }; + +@@ -52,14 +53,34 @@ define( + }); + } + ++ this.updateAttachmentList = function(data){ ++ $('#files').html('' + data.filename + ' (' + humanReadable(data.filesize) + ')' + ''); ++ console.log(data); ++ this.trigger(document, events.mail.uploadedAttachment, data); ++ }.bind(this); ++ + this.upload = function () { +- addJqueryFileUploadConfig(this); +- $('#fileupload').click(); ++ var $fileUploadInput = $('#fileupload'); ++ $fileUploadInput.click(); ++ $fileUploadInput.on('change', this.uploadAttachment); + }; + ++ this.uploadAttachment = function () { ++ var data = new FormData(), ++ attachment = $('#fileupload')[0].files[0]; ++ ++ data.append('attachment', attachment); ++ monitoredAjax(this, '/attachment', { ++ type: 'POST', ++ contentType: false, ++ processData: false, ++ data: data ++ }).done(this.updateAttachmentList); ++ }.bind(this); ++ + this.after('initialize', function () { + if (features.isEnabled('attachment')) { +- this.render(); ++ this.renderButton(); + } + this.on(this.$node, 'click', this.upload); + }); +diff --git a/web-ui/test/spec/mail_view/ui/attachment.spec.js b/web-ui/test/spec/mail_view/ui/attachment.spec.js +index bbea2f5..bfd9626 100644 +--- a/web-ui/test/spec/mail_view/ui/attachment.spec.js ++++ b/web-ui/test/spec/mail_view/ui/attachment.spec.js +@@ -11,11 +11,12 @@ describeComponent('mail_view/ui/attachment', function () { + expect(this.$node.html()).toMatch(''); + }); + +- xit('uploads attachment on click', function () { +- var fileUploads = spyOn($, 'fileupload'); ++ iit('uploads attachment on click', function () { ++ var ajax = spyOn(this.component, 'monitoredAjax'); + this.$node.click(); +- expect(fileUploads).toHaveBeenCalled(); ++ expect(ajax).toHaveBeenCalled(); + }); + ++ + }); + }); -- cgit v1.2.3