summaryrefslogtreecommitdiff
path: root/web-ui/app/js/mixins/with_mail_edit_base.js
diff options
context:
space:
mode:
authorDuda Dornelles <ddornell@thoughtworks.com>2014-10-09 10:49:08 +0200
committerDuda Dornelles <ddornell@thoughtworks.com>2014-10-09 10:51:18 +0200
commit21b025f80e8fc4168a9717cf691114a0b5154baf (patch)
treedbf6ec4a3747f2e4291c7c3afc353128bc4aafe8 /web-ui/app/js/mixins/with_mail_edit_base.js
parentba8024b667a4ca16305e3b8c6fe566ba328a488d (diff)
Fixing bug where the send button would get disabled at times even if there were valid receipients
Diffstat (limited to 'web-ui/app/js/mixins/with_mail_edit_base.js')
-rw-r--r--web-ui/app/js/mixins/with_mail_edit_base.js20
1 files changed, 16 insertions, 4 deletions
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);