Advanced search improvements (#32)

This commit is contained in:
RainLoop Team 2013-12-16 20:08:05 +04:00
parent c8a5d45f37
commit efeef4b143
19 changed files with 101 additions and 22 deletions

View file

@ -15,7 +15,10 @@ function PopupsAdvancedSearchViewModel()
this.subject = ko.observable('');
this.text = ko.observable('');
this.selectedDateValue = ko.observable(-1);
this.hasAttachments = ko.observable(false);
this.starred = ko.observable(false);
this.unseen = ko.observable(false);
this.searchCommand = Utils.createCommand(this, function () {
@ -50,7 +53,8 @@ PopupsAdvancedSearchViewModel.prototype.buildSearchString = function ()
sFrom = Utils.trim(this.from()),
sTo = Utils.trim(this.to()),
sSubject = Utils.trim(this.subject()),
sText = Utils.trim(this.text())
sText = Utils.trim(this.text()),
aHas = []
;
if (sFrom && '' !== sFrom)
@ -70,7 +74,22 @@ PopupsAdvancedSearchViewModel.prototype.buildSearchString = function ()
if (this.hasAttachments())
{
aResult.push('has:attachments');
aHas.push('attachments');
}
if (this.unseen())
{
aHas.push('unseen');
}
if (this.starred())
{
aHas.push('flag');
}
if (0 < aHas.length)
{
aResult.push('has:' + aHas.join(','));
}
if (-1 < this.selectedDateValue())
@ -95,6 +114,8 @@ PopupsAdvancedSearchViewModel.prototype.clearPopup = function ()
this.selectedDateValue(-1);
this.hasAttachments(false);
this.starred(false);
this.unseen(false);
this.fromFocus(true);
};