Add sort by start date for the tasks list

Fixes #3840
This commit is contained in:
Francis Lachapelle
2016-11-30 12:13:48 -05:00
parent a1746cd386
commit 52cdb71d1f
5 changed files with 59 additions and 21 deletions
+1
View File
@@ -3,6 +3,7 @@
Enhancements
- [core] added handling of BYSETPOS for BYDAY in recurrence rules
- [web] added sort by start date for tasks (#3840)
Bug fixes
- [web] fixed JavaScript exception when SOGo is launched from an external link (#3900)
+18 -16
View File
@@ -54,21 +54,22 @@
#define taskCalendarNameIndex 2
#define taskStatusIndex 3
#define taskTitleIndex 4
#define taskEndDateIndex 5
#define taskClassificationIndex 6
#define taskLocationIndex 7
#define taskCategoryIndex 8
#define taskViewableIndex 9
#define taskEditableIndex 10
#define taskErasableIndex 11
#define taskPriorityIndex 12
#define taskOwnerIndex 13
#define taskIsCycleIndex 14
#define taskNextAlarmIndex 15
#define taskRecurrenceIdIndex 16
#define taskIsExceptionIndex 17
#define taskDescriptionIndex 18
#define taskStatusFlagIndex 19
#define taskStartDateIndex 5
#define taskEndDateIndex 6
#define taskClassificationIndex 7
#define taskLocationIndex 8
#define taskCategoryIndex 9
#define taskViewableIndex 10
#define taskEditableIndex 11
#define taskErasableIndex 12
#define taskPriorityIndex 13
#define taskOwnerIndex 14
#define taskIsCycleIndex 15
#define taskNextAlarmIndex 16
#define taskRecurrenceIdIndex 17
#define taskIsExceptionIndex 18
#define taskDescriptionIndex 19
#define taskStatusFlagIndex 20
@interface NSArray (SOGoEventComparison)
@@ -80,7 +81,8 @@
- (NSComparisonResult) compareTasksAscending: (NSArray *) otherTask;
- (NSComparisonResult) compareTasksPriorityAscending: (NSArray *) otherTask;
- (NSComparisonResult) compareTasksTitleAscending: (NSArray *) otherTask;
- (NSComparisonResult) compareTasksEndAscending: (NSArray *) otherTask;
- (NSComparisonResult) compareTasksStartDateAscending: (NSArray *) otherTask;
- (NSComparisonResult) compareTasksEndDateAscending: (NSArray *) otherTask;
- (NSComparisonResult) compareTasksLocationAscending: (NSArray *) otherTask;
- (NSComparisonResult) compareTasksCategoryAscending: (NSArray *) otherTask;
- (NSComparisonResult) compareTasksCalendarNameAscending: (NSArray *) otherTask;
+35 -1
View File
@@ -182,7 +182,41 @@
return [selfTitle caseInsensitiveCompare: otherTitle];
}
- (NSComparisonResult) compareTasksEndAscending: (NSArray *) otherTask
- (NSComparisonResult) compareTasksStartDateAscending: (NSArray *) otherTask
{
NSComparisonResult result;
unsigned int selfTime, otherTime;
// Start date
selfTime = [[self objectAtIndex: taskStartDateIndex] intValue];
otherTime = [[otherTask objectAtIndex: taskStartDateIndex] intValue];
if (selfTime && !otherTime)
result = NSOrderedAscending;
else if (!selfTime && otherTime)
result = NSOrderedDescending;
else
{
if (selfTime > otherTime)
result = NSOrderedDescending;
else if (selfTime < otherTime)
result = NSOrderedAscending;
else
{
// Calendar ID
result = [[self objectAtIndex: taskFolderIndex]
compare: [otherTask objectAtIndex: taskFolderIndex]];
if (result == NSOrderedSame)
// Task name
result = [[self objectAtIndex: taskTitleIndex]
compare: [otherTask objectAtIndex: taskTitleIndex]
options: NSCaseInsensitiveSearch];
}
}
return result;
}
- (NSComparisonResult) compareTasksEndDateAscending: (NSArray *) otherTask
{
NSComparisonResult result;
unsigned int selfTime, otherTime;
+4 -3
View File
@@ -90,7 +90,7 @@ static NSArray *tasksFields = nil;
{
tasksFields = [NSArray arrayWithObjects: @"c_name", @"c_folder",
@"calendarName",
@"c_status", @"c_title", @"c_enddate",
@"c_status", @"c_title", @"c_startdate", @"c_enddate",
@"c_classification", @"c_location", @"c_category",
@"viewable", @"editable", @"erasable",
@"c_priority", @"c_owner",
@@ -1595,7 +1595,6 @@ _computeBlocksPosition (NSArray *blocks)
forAllDay: NO]];
else
[filteredTask addObject: [NSNull null]];
if (([tasksView isEqualToString:@"view_today"] ||
[tasksView isEqualToString:@"view_next7"] ||
[tasksView isEqualToString:@"view_next14"] ||
@@ -1621,8 +1620,10 @@ _computeBlocksPosition (NSArray *blocks)
[filteredTasks sortUsingSelector: @selector (compareTasksTitleAscending:)];
else if ([sort isEqualToString: @"priority"])
[filteredTasks sortUsingSelector: @selector (compareTasksPriorityAscending:)];
else if ([sort isEqualToString: @"start"])
[filteredTasks sortUsingSelector: @selector (compareTasksStartDateAscending:)];
else if ([sort isEqualToString: @"end"])
[filteredTasks sortUsingSelector: @selector (compareTasksEndAscending:)];
[filteredTasks sortUsingSelector: @selector (compareTasksEndDateAscending:)];
else if ([sort isEqualToString: @"location"])
[filteredTasks sortUsingSelector: @selector (compareTasksLocationAscending:)];
else if ([sort isEqualToString: @"category"])
+1 -1
View File
@@ -466,7 +466,7 @@
<!-- selected --></md-icon> <var:string label:value="Calendar"/>
</md-button>
</md-menu-item>
<md-menu-item ng-if="list.componentType == 'events'">
<md-menu-item>
<md-button ng-click="list.sort('start')">
<md-icon ng-class="{ 'icon-check': list.sortedBy('start') }">
<!-- selected --></md-icon> <var:string label:value="Start"/>