From 7f1788eba974eff755b964cf8ee637ee74427dbb Mon Sep 17 00:00:00 2001 From: kolaente Date: Sat, 16 Mar 2024 13:28:06 +0100 Subject: [PATCH] fix(views): get tasks in saved filter --- pkg/models/task_collection.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pkg/models/task_collection.go b/pkg/models/task_collection.go index 95e5ad5d7..07594a44f 100644 --- a/pkg/models/task_collection.go +++ b/pkg/models/task_collection.go @@ -42,6 +42,8 @@ type TaskCollection struct { // If set to true, the result will also include null values FilterIncludeNulls bool `query:"filter_include_nulls" json:"filter_include_nulls"` + isSavedFilter bool + web.CRUDable `xorm:"-" json:"-"` web.Rights `xorm:"-" json:"-"` } @@ -152,7 +154,7 @@ func (tf *TaskCollection) ReadAll(s *xorm.Session, a web.Auth, search string, pa // If the project id is < -1 this means we're dealing with a saved filter - in that case we get and populate the filter // -1 is the favorites project which works as intended - if tf.ProjectID < -1 { + if !tf.isSavedFilter && tf.ProjectID < -1 { sf, err := getSavedFilterSimpleByID(s, getSavedFilterIDFromProjectID(tf.ProjectID)) if err != nil { return nil, 0, 0, err @@ -182,7 +184,12 @@ func (tf *TaskCollection) ReadAll(s *xorm.Session, a web.Auth, search string, pa sf.Filters.FilterTimezone = u.Timezone } - return sf.getTaskCollection().ReadAll(s, a, search, page, perPage) + tc := sf.getTaskCollection() + tc.ProjectViewID = tf.ProjectViewID + tc.ProjectID = tf.ProjectID + tc.isSavedFilter = true + + return tc.ReadAll(s, a, search, page, perPage) } var view *ProjectView @@ -230,7 +237,7 @@ func (tf *TaskCollection) ReadAll(s *xorm.Session, a web.Auth, search string, pa // If the project ID is not set, we get all tasks for the user. // This allows to use this function in Task.ReadAll with a possibility to deprecate the latter at some point. var projects []*Project - if tf.ProjectID == 0 { + if tf.ProjectID == 0 || tf.isSavedFilter { projects, _, _, err = getRawProjectsForUser( s, &projectOptions{