diff --git a/pkg/models/task_collection.go b/pkg/models/task_collection.go index ec2bf0a5..70be8d74 100644 --- a/pkg/models/task_collection.go +++ b/pkg/models/task_collection.go @@ -149,6 +149,11 @@ func (tf *TaskCollection) ReadAll(s *xorm.Session, a web.Auth, search string, pa return nil, 0, 0, err } + sf.Filters.SortByArr = tf.SortByArr + sf.Filters.SortBy = tf.SortBy + sf.Filters.OrderByArr = tf.OrderByArr + sf.Filters.OrderBy = tf.OrderBy + return sf.getTaskCollection().ReadAll(s, a, search, page, perPage) } diff --git a/pkg/models/task_collection_test.go b/pkg/models/task_collection_test.go index 84528926..fa21f6aa 100644 --- a/pkg/models/task_collection_test.go +++ b/pkg/models/task_collection_test.go @@ -1081,6 +1081,24 @@ func TestTaskCollection_ReadAll(t *testing.T) { task2, }, }, + { + name: "saved filter with sort order", + fields: fields{ + ListID: -2, + SortBy: []string{"title", "id"}, + OrderBy: []string{"desc", "asc"}, + }, + args: args{ + a: &user.User{ID: 1}, + }, + want: []*Task{ + task9, + task8, + task7, + task6, + task5, + }, + }, } for _, tt := range tests {