Skip to content

Commit

Permalink
feat(mail): filter mailbox by flagged messages
Browse files Browse the repository at this point in the history
Fixes #1417
  • Loading branch information
cgx committed Oct 19, 2021
1 parent 270bc2e commit c2f95dc
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 17 deletions.
3 changes: 3 additions & 0 deletions UI/MailerUI/English.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@
/* Filter option in messages list */
"Show unread messages only" = "Show unread messages only";

/* Filter option in messages list */
"Show flagged messages only" = "Show flagged messages only";

/* Tree */
"SentFolderName" = "Sent";
"TrashFolderName" = "Trash";
Expand Down
8 changes: 7 additions & 1 deletion UI/MailerUI/UIxMailListActions.m
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ - (EOQualifier *) searchQualifier
NSArray *filters;
NSString *searchBy, *searchInput, *searchString, *match;
NSMutableArray *qualifiers, *searchArray;
BOOL unseenOnly;
BOOL unseenOnly, flaggedOnly;
int nbFilters, i;

request = [context request];
Expand All @@ -439,6 +439,7 @@ - (EOQualifier *) searchQualifier
match = nil;
filters = [content objectForKey: @"filters"];
unseenOnly = [[content objectForKey: @"unseenOnly"] boolValue];
flaggedOnly = [[content objectForKey: @"flaggedOnly"] boolValue];

if (filters)
{
Expand Down Expand Up @@ -483,6 +484,11 @@ - (EOQualifier *) searchQualifier
searchQualifier = [EOQualifier qualifierWithQualifierFormat: @"(not (flags = %@))", @"seen"];
[qualifiers addObject: searchQualifier];
}
if (flaggedOnly)
{
searchQualifier = [EOQualifier qualifierWithQualifierFormat: @"(flags = %@)", @"flagged"];
[qualifiers addObject: searchQualifier];
}

if ([qualifiers count] > 1)
{
Expand Down
33 changes: 28 additions & 5 deletions UI/Templates/MailerUI/UIxMailFolderTemplate.wox
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,28 @@
</md-button>
<a href="#" class="sg-folder-name"
ng-click="mailbox.searchMode($event)" ng-bind="mailbox.service.selectedFolder.$displayName"><!-- mailbox name --></a>
<md-button class="sg-icon-button" label:aria-label="Show unread messages only"
ng-click="mailbox.selectedFolder.toggleUnseenOnly()">
<md-icon class="md-default-theme md-fg md-primary" ng-class="{ 'md-hue-2': mailbox.selectedFolder.$unseenOnly }" >mark_as_unread</md-icon>
</md-button>
<md-menu>
<md-button class="sg-icon-button" label:aria-label="Filter"
ng-click="$mdMenu.open()">
<md-icon>filter_list</md-icon>
</md-button>
<md-menu-content width="4">
<md-menu-item>
<sg-checkmark
ng-change="mailbox.selectedFolder.$filter(mailbox.service.$query)"
ng-model="mailbox.selectedFolder.$unseenOnly"
sg-true-value="1"
sg-false-value="0"> <var:string label:value="Show unread messages only"/></sg-checkmark>
</md-menu-item>
<md-menu-item>
<sg-checkmark
ng-change="mailbox.selectedFolder.$filter(mailbox.service.$query)"
ng-model="mailbox.selectedFolder.$flaggedOnly"
sg-true-value="1"
sg-false-value="0"> <var:string label:value="Show flagged messages only"/></sg-checkmark>
</md-menu-item>
</md-menu-content>
</md-menu>
<md-menu>
<md-button class="sg-icon-button" label:aria-label="Sort"
ng-click="$mdMenu.open()">
Expand Down Expand Up @@ -283,7 +301,12 @@
<span ng-switch-when="0"><var:string label:value="No message"/></span>
<span ng-switch-default="true"><span ng-bind="mailbox.service.selectedFolder.getLength()"><!-- count --></span> <var:string label:value="messages"/></span>
</div>
<div class="md-truncate"><md-icon ng-class="{ 'md-flip': mailbox.ascending() }">sort</md-icon> <span ng-bind="mailbox.sort() | loc"><!-- active sort --></span></div>
<div class="md-truncate">
<span ng-show="mailbox.selectedFolder.$unseenOnly"><var:string label:value="Unread"/></span>
<span ng-show="mailbox.selectedFolder.$flaggedOnly"><var:string label:value="Flagged"/></span>
<md-icon ng-class="{ 'md-flip': mailbox.ascending() }">sort</md-icon>
<span ng-bind="mailbox.sort() | loc"><!-- active sort --></span>
</div>
</div>
</md-subheader>
<md-virtual-repeat-container class="md-flex" md-top-index="mailbox.selectedFolder.$topIndex">
Expand Down
14 changes: 3 additions & 11 deletions UI/WebServerResources/js/Mailer/Mailbox.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,17 +342,6 @@
return angular.isDefined(this.$selectedMessage);
};

/**
* @function toggleUnseenOnly
* @memberof Mailbox.prototype
* @desc Toggle filter by unseen messages only. Requires a round trip to the server.
*/
Mailbox.prototype.toggleUnseenOnly = function() {
var _this = this;
this.$unseenOnly = !this.$unseenOnly;
this.$filter(Mailbox.$query);
};

/**
* @function $filter
* @memberof Mailbox.prototype
Expand Down Expand Up @@ -408,6 +397,9 @@
if (this.$unseenOnly)
options.unseenOnly = 1;

if (this.$flaggedOnly)
options.flaggedOnly = 1;

// Restart the refresh timer, if needed
if (!Mailbox.$virtualMode) {
var refreshViewCheck = Mailbox.$Preferences.defaults.SOGoRefreshViewCheck;
Expand Down

0 comments on commit c2f95dc

Please sign in to comment.