From efeef4b143a2ac6a18a6443b28d5e8a60e39e6ed Mon Sep 17 00:00:00 2001 From: RainLoop Team Date: Mon, 16 Dec 2013 20:08:05 +0400 Subject: [PATCH] Advanced search improvements (#32) --- dev/Storages/WebMailAjaxRemote.js | 2 +- .../PopupsAdvancedSearchViewModel.js | 25 +++++++++++++++-- .../app/libraries/MailSo/Mail/MailClient.php | 16 +++++------ .../templates/Views/PopupsAdvancedSearch.html | 15 +++++++++-- rainloop/v/0.0.0/langs/de.ini | 2 ++ rainloop/v/0.0.0/langs/en.ini | 2 ++ rainloop/v/0.0.0/langs/es.ini | 2 ++ rainloop/v/0.0.0/langs/fr.ini | 2 ++ rainloop/v/0.0.0/langs/is.ini | 2 ++ rainloop/v/0.0.0/langs/ko-kr.ini | 2 ++ rainloop/v/0.0.0/langs/lv.ini | 2 ++ rainloop/v/0.0.0/langs/nl.ini | 2 ++ rainloop/v/0.0.0/langs/pl.ini | 2 ++ rainloop/v/0.0.0/langs/pt-br.ini | 2 ++ rainloop/v/0.0.0/langs/pt-pt.ini | 2 ++ rainloop/v/0.0.0/langs/ru.ini | 2 ++ rainloop/v/0.0.0/langs/zh-cn.ini | 2 ++ rainloop/v/0.0.0/static/js/app.js | 27 ++++++++++++++++--- rainloop/v/0.0.0/static/js/app.min.js | 12 ++++----- 19 files changed, 101 insertions(+), 22 deletions(-) diff --git a/dev/Storages/WebMailAjaxRemote.js b/dev/Storages/WebMailAjaxRemote.js index af18e58d7..ae8c8ca7e 100644 --- a/dev/Storages/WebMailAjaxRemote.js +++ b/dev/Storages/WebMailAjaxRemote.js @@ -137,7 +137,7 @@ WebMailAjaxRemoteStorage.prototype.messageList = function (fCallback, sFolderFul iLimit = Utils.isUnd(iOffset) ? 20 : Utils.pInt(iLimit); sSearch = Utils.pString(sSearch); - if ('' !== sFolderHash) + if ('' !== sFolderHash && ('' === sSearch || -1 === sSearch.indexOf('has:'))) { this.defaultRequest(fCallback, 'MessageList', {}, '' === sSearch ? Consts.Defaults.DefaultAjaxTimeout : Consts.Defaults.SearchAjaxTimeout, diff --git a/dev/ViewModels/PopupsAdvancedSearchViewModel.js b/dev/ViewModels/PopupsAdvancedSearchViewModel.js index ad8d7650e..618405b2b 100644 --- a/dev/ViewModels/PopupsAdvancedSearchViewModel.js +++ b/dev/ViewModels/PopupsAdvancedSearchViewModel.js @@ -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); }; diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Mail/MailClient.php b/rainloop/v/0.0.0/app/libraries/MailSo/Mail/MailClient.php index d6ae893da..9a6be2911 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Mail/MailClient.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Mail/MailClient.php @@ -1051,14 +1051,14 @@ class MailClient { $oSearchBuilder->AddAnd('HEADER CONTENT-TYPE', '"MULTIPART/MIXED"'); } -// if (false !== strpos($sRawValue, 'flag')) -// { -// $oSearchBuilder->AddAnd('FLAGGED'); -// } -// if (false !== strpos($sRawValue, 'unseen')) -// { -// $oSearchBuilder->AddAnd('UNSEEN'); -// } + if (false !== strpos($sRawValue, 'flag') || false !== strpos($sRawValue, 'star')) + { + $oSearchBuilder->AddAnd('FLAGGED'); + } + if (false !== strpos($sRawValue, 'unseen')) + { + $oSearchBuilder->AddAnd('UNSEEN'); + } break; case 'DATE': $iDateStampFrom = $iDateStampTo = 0; diff --git a/rainloop/v/0.0.0/app/templates/Views/PopupsAdvancedSearch.html b/rainloop/v/0.0.0/app/templates/Views/PopupsAdvancedSearch.html index ecf761870..2138d564a 100644 --- a/rainloop/v/0.0.0/app/templates/Views/PopupsAdvancedSearch.html +++ b/rainloop/v/0.0.0/app/templates/Views/PopupsAdvancedSearch.html @@ -7,6 +7,7 @@ -
+ +