From c28bdb520cc4ea1249d5a2953d9f78d40dd10806 Mon Sep 17 00:00:00 2001 From: NavaL Date: Mon, 11 Jan 2016 18:37:03 +0100 Subject: auto save draft on adding attachment, within timeout Issue #573 --- web-ui/app/js/mail_view/ui/draft_box.js | 2 +- web-ui/app/js/mixins/with_mail_edit_base.js | 1 + web-ui/test/spec/mixins/with_mail_edit_base.spec.js | 12 ++++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) (limited to 'web-ui') diff --git a/web-ui/app/js/mail_view/ui/draft_box.js b/web-ui/app/js/mail_view/ui/draft_box.js index 6a640d88..88051f30 100644 --- a/web-ui/app/js/mail_view/ui/draft_box.js +++ b/web-ui/app/js/mail_view/ui/draft_box.js @@ -87,7 +87,7 @@ define( this.on(this, events.mail.here, this.renderDraftBox); this.on(document, events.mail.sent, this.showNoMessageSelected); this.on(document, events.mail.deleted, this.mailDeleted); - this.trigger(document, events.mail.want, { mail: this.attr.mailIdent , caller: this }); + this.trigger(document, events.mail.want, { mail: this.attr.mailIdent, caller: this }); }); } } 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 d078c582..d7da4680 100644 --- a/web-ui/app/js/mixins/with_mail_edit_base.js +++ b/web-ui/app/js/mixins/with_mail_edit_base.js @@ -107,6 +107,7 @@ define( this.enableAutoSave = function () { this.select('bodyBox').on('input', this.monitorInput.bind(this)); this.select('subjectBox').on('input', this.monitorInput.bind(this)); + this.on(document, events.mail.appendAttachment, this.monitorInput.bind(this)); DraftSaveStatus.attachTo(this.select('draftSaveStatus')); }; 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 2b35d4f5..4ff02318 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 @@ -48,6 +48,18 @@ describeMixin('mixins/with_mail_edit_base', function () { }, 10); }); + it('saves the draft when an attachment is added within timeout', function(done) { + var saveDraftSpy = spyOnEvent(document, Pixelated.events.mail.saveDraft); + this.component.enableAutoSave(); + this.component.trigger(document, Pixelated.events.mail.appendAttachment); + expect(saveDraftSpy).not.toHaveBeenTriggeredOn(document); + + setTimeout(function () { + expect(saveDraftSpy).toHaveBeenTriggeredOn(document); + done(); + }, 10); + }); + it('does not save if mail is sent before the save draft interval number of seconds', function(done) { var saveDraftSpy = spyOnEvent(document, Pixelated.events.mail.saveDraft); this.component.monitorInput(); -- cgit v1.2.3