1
0

Make the _unix suffix optional when sorting tasks

This commit is contained in:
kolaente
2020-05-15 16:07:36 +02:00
parent 851f0d6c08
commit 92e5e2db6a
3 changed files with 31 additions and 1 deletions

View File

@ -118,6 +118,20 @@ func (tf *TaskCollection) ReadAll(a web.Auth, search string, page int, perPage i
if len(tf.OrderBy) > i {
param.orderBy = getSortOrderFromString(tf.OrderBy[i])
}
// Special case for pseudo date fields
// FIXME: This is really dirty, to fix this properly the db fields should be renamed
switch param.sortBy {
case "done_at":
param.sortBy = taskPropertyDoneAtUnix
case "due_date":
param.sortBy = taskPropertyDueDateUnix
case "start_date":
param.sortBy = taskPropertyStartDateUnix
case "end_date":
param.sortBy = taskPropertyEndDateUnix
}
// Param validation
if err := param.validate(); err != nil {
return nil, 0, 0, err

View File

@ -90,7 +90,7 @@ func getTaskFiltersByCollections(c *TaskCollection) (filters []*taskFilter, err
}
// Special case for pseudo date fields
// FIXME: This is really dirty, to fix this the db fields should be renamed
// FIXME: This is really dirty, to fix this properly the db fields should be renamed
if filter.field+"_unix" == taskPropertyDoneAtUnix ||
filter.field+"_unix" == taskPropertyDueDateUnix ||
filter.field+"_unix" == taskPropertyStartDateUnix ||