diff --git a/pkg/models/task_collection.go b/pkg/models/task_collection.go index 700585713..f71b203e5 100644 --- a/pkg/models/task_collection.go +++ b/pkg/models/task_collection.go @@ -74,7 +74,7 @@ func validateTaskField(fieldName string) error { return ErrInvalidTaskField{TaskField: fieldName} } -func getTaskFilterOptsFromCollection(tf *TaskCollection) (opts *taskSearchOptions, err error) { +func getTaskFilterOptsFromCollection(tf *TaskCollection, projectView *ProjectView) (opts *taskSearchOptions, err error) { if len(tf.SortByArr) > 0 { tf.SortBy = append(tf.SortBy, tf.SortByArr...) } @@ -95,6 +95,10 @@ func getTaskFilterOptsFromCollection(tf *TaskCollection) (opts *taskSearchOption param.orderBy = getSortOrderFromString(tf.OrderBy[i]) } + if s == taskPropertyPosition && projectView != nil { + param.projectViewID = projectView.ID + } + // Param validation if err := param.validate(); err != nil { return nil, err @@ -177,14 +181,16 @@ func (tf *TaskCollection) ReadAll(s *xorm.Session, a web.Auth, search string, pa return nil, 0, 0, err } - if tf.Filter != "" { - tf.Filter = "(" + tf.Filter + ") && (" + view.Filter + ")" - } else { - tf.Filter = view.Filter + if view.Filter != "" { + if tf.Filter != "" { + tf.Filter = "(" + tf.Filter + ") && (" + view.Filter + ")" + } else { + tf.Filter = view.Filter + } } } - opts, err := getTaskFilterOptsFromCollection(tf) + opts, err := getTaskFilterOptsFromCollection(tf, view) if err != nil { return nil, 0, 0, err }