diff options
-rw-r--r-- | service/pixelated/adapter/pixelated_mail.py | 1 | ||||
-rw-r--r-- | web-ui/app/js/mixins/with_mail_edit_base.js | 20 | ||||
-rw-r--r-- | web-ui/app/js/services/model/mail.js | 4 | ||||
-rw-r--r-- | web-ui/test/spec/mixins/with_mail_edit_base.spec.js | 27 | ||||
-rw-r--r-- | web-ui/test/spec/services/model/mail.spec.js | 3 | ||||
-rw-r--r-- | web-ui/test/test_data.js | 10 |
6 files changed, 33 insertions, 32 deletions
diff --git a/service/pixelated/adapter/pixelated_mail.py b/service/pixelated/adapter/pixelated_mail.py index c6c8681d..95f417d2 100644 --- a/service/pixelated/adapter/pixelated_mail.py +++ b/service/pixelated/adapter/pixelated_mail.py @@ -277,6 +277,7 @@ class PixelatedMail: 'header': {k.lower(): v for k, v in self.headers.items()}, 'ident': self.ident, 'tags': list(self.tags), + 'mailbox': self.mailbox_name, 'status': statuses, 'security_casing': self.security_casing, 'body': self.body diff --git a/web-ui/app/js/mixins/with_mail_edit_base.js b/web-ui/app/js/mixins/with_mail_edit_base.js index 6f176eaa..4f811235 100644 --- a/web-ui/app/js/mixins/with_mail_edit_base.js +++ b/web-ui/app/js/mixins/with_mail_edit_base.js @@ -59,6 +59,7 @@ define( }; function thereAreRecipientsToDisplay() { + var allRecipients = _.chain(this.attr.recipientValues). values(). flatten(). @@ -68,6 +69,20 @@ define( return !_.isEmpty(allRecipients); } + this.warnSendButtonOfRecipients = function () { + if (thereAreRecipientsToDisplay.call(this)) { + _.forOwn(this.attr.recipientValues, function (recipients, recipientsType) { + if (!_.isUndefined(recipients) && !_.isEmpty(recipients)) { + var recipientsUpdatedData = { + newRecipients: recipients, + name: recipientsType + }; + this.trigger(document, events.ui.recipients.updated, recipientsUpdatedData); + } + }.bind(this)); + } + }; + this.render = function(template, context) { this.$node.html(template(context)); @@ -81,9 +96,7 @@ define( this.on(this.select('trashButton'), 'click', this.trashMail); SendButton.attachTo(this.select('sendButton')); - if (thereAreRecipientsToDisplay.call(this)) { - this.trigger(document, events.ui.sendbutton.enable); - } + this.warnSendButtonOfRecipients(); }; this.enableAutoSave = function () { @@ -172,7 +185,6 @@ define( return !_.isEmpty(_.flatten(_.values(this.attr.recipientValues))); }; - // Validators and formatters function allRecipientsAreEmails(mail) { var allRecipients = mail.header.to.concat(mail.header.cc).concat(mail.header.bcc); return _.isEmpty(allRecipients) ? false : _.all(allRecipients, emailFormatChecker); diff --git a/web-ui/app/js/services/model/mail.js b/web-ui/app/js/services/model/mail.js index 373eb683..9fe2bf44 100644 --- a/web-ui/app/js/services/model/mail.js +++ b/web-ui/app/js/services/model/mail.js @@ -23,11 +23,11 @@ define(['helpers/contenttype'], var asMail = (function () { function isSentMail() { - return _.contains(this.tags, 'sent'); + return this.mailbox == 'SENT'; } function isDraftMail() { - return _.contains(this.tags, 'drafts'); + return this.mailbox == 'DRAFTS'; } function normalize(recipients) { diff --git a/web-ui/test/spec/mixins/with_mail_edit_base.spec.js b/web-ui/test/spec/mixins/with_mail_edit_base.spec.js index 10b7d04c..f62c1f75 100644 --- a/web-ui/test/spec/mixins/with_mail_edit_base.spec.js +++ b/web-ui/test/spec/mixins/with_mail_edit_base.spec.js @@ -15,33 +15,18 @@ describeMixin('mixins/with_mail_edit_base', function () { }); describe('initialization', function() { - it('should enable send button when rendering with recipients', function() { - var enableSendButtonEvent = spyOnEvent(document, Pixelated.events.ui.sendbutton.enable); - this.component.render(function() {}, { - recipients: { to: ['foobar@mail.com'], cc: [] } - }); - expect(enableSendButtonEvent).toHaveBeenTriggeredOn(document); - enableSendButtonEvent = spyOnEvent(document, Pixelated.events.ui.sendbutton.enable); - this.component.render(function() {}, { - recipients: { to: ['foobar@mail.com'], cc: undefined } - }); - expect(enableSendButtonEvent).toHaveBeenTriggeredOn(document); - }); + it('should warn send button of existing recipients', function () { + var recipientsUpdatedEvent = spyOnEvent(document, Pixelated.events.ui.recipients.updated); - it('should not enable send button when rendering without recipients', function() { - var enableSendButtonEvent = spyOnEvent(document, Pixelated.events.ui.sendbutton.enable); this.component.render(function() {}, { - recipients: { to: [], cc: [] } + recipients: { to: ['foobar@mail.com'], cc: [] } }); - expect(enableSendButtonEvent).not.toHaveBeenTriggeredOn(document); - enableSendButtonEvent = spyOnEvent(document, Pixelated.events.ui.sendbutton.enable); - this.component.render(function() {}, { - recipients: { to: undefined, cc: undefined } - }); - expect(enableSendButtonEvent).not.toHaveBeenTriggeredOn(document); + expect(recipientsUpdatedEvent).toHaveBeenTriggeredOnAndWith(document, { newRecipients: ['foobar@mail.com'], name: 'to'}); + expect(recipientsUpdatedEvent).not.toHaveBeenTriggeredOnAndWith(document, { newRecipients: [], name: 'cc'}); }); + }); describe('when the user is typing in subject or body', function() { diff --git a/web-ui/test/spec/services/model/mail.spec.js b/web-ui/test/spec/services/model/mail.spec.js index 9b5f71c6..24a8d244 100644 --- a/web-ui/test/spec/services/model/mail.spec.js +++ b/web-ui/test/spec/services/model/mail.spec.js @@ -9,7 +9,8 @@ require(['services/model/mail'], function (Mail) { it('returns the "to" and "cc" addresses if the mail was sent', function () { var mail = Mail.create({ header: { to: ['a@b.c', 'e@f.g'], cc: ['x@x.x'] }, - tags: ['sent'] + tags: [], + mailbox: 'SENT' }); var addresses = mail.replyToAddress(); diff --git a/web-ui/test/test_data.js b/web-ui/test/test_data.js index c32bc65f..bf3626bb 100644 --- a/web-ui/test/test_data.js +++ b/web-ui/test/test_data.js @@ -22,17 +22,19 @@ define(function() { var rawSentMail = { 'header':{'to':'mariane_dach@davis.info', 'cc': 'duda@la.lu', 'from':'afton_braun@botsford.biz','subject':'Consectetur sit omnis veniam blanditiis.','date':'2014-06-17T11:56:53-03:00'}, 'ident':9359, - 'tags':['sent','photography','sky'], + 'tags':['photography','sky'], 'status':['read'], - 'body':'Illum eos nihil commodi voluptas. Velit consequatur odio quibusdam. Beatae aliquam hic quos.' + 'body':'Illum eos nihil commodi voluptas. Velit consequatur odio quibusdam. Beatae aliquam hic quos.', + 'mailbox': 'SENT' }; var rawDraftMail = { 'header':{'to':'mariane_dach@davis.info','from':'afton_braun@botsford.biz','subject':'Consectetur sit omnis veniam blanditiis.','date':'2014-06-17T11:56:53-03:00'}, 'ident':9360, - 'tags':['drafts','photography','sky'], + 'tags':['photography','sky'], 'status':['read'], - 'body':'Illum eos nihil commodi voluptas. Velit consequatur odio quibusdam. Beatae aliquam hic quos.' + 'body':'Illum eos nihil commodi voluptas. Velit consequatur odio quibusdam. Beatae aliquam hic quos.', + 'mailbox': 'DRAFTS' }; var rawRecievedMail = { |