Сheck attachments on compose (Closes #161)

This commit is contained in:
RainLoop Team 2014-07-17 14:39:13 +04:00
parent d80a9e8485
commit 97d3f4a13c
28 changed files with 201 additions and 168 deletions

View file

@ -53,6 +53,7 @@ function PopupsComposeViewModel()
this.savedOrSendingText = ko.observable('');
this.emptyToError = ko.observable(false);
this.attachmentsInProcessError = ko.observable(false);
this.showCcAndBcc = ko.observable(false);
this.cc.subscribe(fCcAndBccCheckHelper, this);
@ -160,6 +161,13 @@ function PopupsComposeViewModel()
this.emptyToError(false);
}
}, this);
this.attachmentsInProcess.subscribe(function (aValue) {
if (this.attachmentsInProcessError() && Utils.isArray(aValue) && 0 === aValue.length)
{
this.attachmentsInProcessError(false);
}
}, this);
this.editorResizeThrottle = _.throttle(_.bind(this.editorResize, this), 100);
@ -167,14 +175,6 @@ function PopupsComposeViewModel()
this.editorResizeThrottle();
}, this);
this.canBeSended = ko.computed(function () {
return !this.sending() &&
!this.saving() &&
0 === this.attachmentsInProcess().length &&
0 < this.to().length
;
}, this);
this.canBeSendedOrSaved = ko.computed(function () {
return !this.sending() && !this.saving();
}, this);
@ -198,7 +198,11 @@ function PopupsComposeViewModel()
aFlagsCache = []
;
if (0 === sTo.length)
if (0 < this.attachmentsInProcess().length)
{
this.attachmentsInProcessError(true);
}
else if (0 === sTo.length)
{
this.emptyToError(true);
}
@ -1463,6 +1467,7 @@ PopupsComposeViewModel.prototype.reset = function ()
this.savedTime(0);
this.savedOrSendingText('');
this.emptyToError(false);
this.attachmentsInProcessError(false);
this.showCcAndBcc(false);
this.attachments([]);