summaryrefslogtreecommitdiff
path: root/web-ui/app/js/mixins
diff options
context:
space:
mode:
authorGiovane <giovaneliberato@gmail.com>2015-11-27 15:47:58 -0200
committerGiovane <giovaneliberato@gmail.com>2015-11-27 15:53:11 -0200
commit07be9f6109e3dff49775aa51f0a481b5fd524d3b (patch)
tree29e2df328027c60349d17a8f62fdd556fafceeb3 /web-ui/app/js/mixins
parentc1476b4b1c96996464217444e8cdf5d94d248bea (diff)
Created a discard draft behaviour #512 w/ bwagner
If a draft was never saved before, and there wasn't any change to save, we now discard it instead saving and deleting it. This also lessens the calls to saveDraft that was causing some draft duplication.
Diffstat (limited to 'web-ui/app/js/mixins')
-rw-r--r--web-ui/app/js/mixins/with_compose_inline.js4
-rw-r--r--web-ui/app/js/mixins/with_mail_edit_base.js19
2 files changed, 18 insertions, 5 deletions
diff --git a/web-ui/app/js/mixins/with_compose_inline.js b/web-ui/app/js/mixins/with_compose_inline.js
index cd5dcd8b..b39201ae 100644
--- a/web-ui/app/js/mixins/with_compose_inline.js
+++ b/web-ui/app/js/mixins/with_compose_inline.js
@@ -65,6 +65,10 @@ define(
this.attr.mail.ident = data.ident;
};
+ this.discardDraft = function() {
+ this.trashReply();
+ };
+
this.after('initialize', function () {
this.on(document, events.mail.sent, this.openMail);
this.on(document, events.mail.deleted, this.trashReply);
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 da92ad29..a3c88e66 100644
--- a/web-ui/app/js/mixins/with_mail_edit_base.js
+++ b/web-ui/app/js/mixins/with_mail_edit_base.js
@@ -118,10 +118,14 @@ define(
this.trashMail = function() {
this.cancelPostponedSaveDraft();
- this.trigger(document, events.mail.save, {
- mail: this.buildMail(),
- callback: this.deleteMail.bind(this)
- });
+ if (this.attr.ident) {
+ this.trigger(document, events.mail.save, {
+ mail: this.buildMail(),
+ callback: this.deleteMail.bind(this)
+ });
+ } else {
+ this.trigger(document, events.ui.mail.discard);
+ }
};
this.trim_recipient = function(recipients) {
@@ -133,7 +137,7 @@ define(
this.sendMail = function () {
this.cancelPostponedSaveDraft();
var mail = this.buildMail('sent');
-
+
if (allRecipientsAreEmails(mail)) {
mail.header.to = this.trim_recipient(mail.header.to);
mail.header.cc = this.trim_recipient(mail.header.cc);
@@ -219,6 +223,10 @@ define(
});
};
+ this.before('initialize', function () {
+ this.discardDraft = function () {};
+ });
+
this.after('initialize', function () {
this.on(document, events.dispatchers.rightPane.clear, this.teardown);
this.on(document, events.ui.recipients.updated, this.recipientsUpdated);
@@ -227,6 +235,7 @@ define(
this.on(document, events.ui.mail.send, this.sendMail);
+ this.on(document, events.ui.mail.discard, this.discardDraft);
this.on(document, events.ui.tag.selected, this.saveTag);
this.on(document, events.ui.tag.select, this.saveTag);
});