From 21b025f80e8fc4168a9717cf691114a0b5154baf Mon Sep 17 00:00:00 2001 From: Duda Dornelles Date: Thu, 9 Oct 2014 10:49:08 +0200 Subject: Fixing bug where the send button would get disabled at times even if there were valid receipients --- web-ui/app/js/mixins/with_mail_edit_base.js | 20 ++++++++++++++++---- web-ui/app/js/services/model/mail.js | 4 ++-- 2 files changed, 18 insertions(+), 6 deletions(-) (limited to 'web-ui/app') 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) { -- cgit v1.2.3