diff --git a/pkg/models/task_collection.go b/pkg/models/task_collection.go index 4651f72bc..227caaa46 100644 --- a/pkg/models/task_collection.go +++ b/pkg/models/task_collection.go @@ -35,11 +35,9 @@ type TaskCollection struct { Search string `query:"s" json:"s"` // The query parameter to sort by. This is for ex. done, priority, etc. - SortBy []string `query:"sort_by" json:"sort_by"` - SortByArr []string `query:"sort_by[]" json:"-"` + SortBy []string `query:"sort_by" json:"sort_by"` // The query parameter to order the items by. This can be either asc or desc, with asc being the default. - OrderBy []string `query:"order_by" json:"order_by"` - OrderByArr []string `query:"order_by[]" json:"-"` + OrderBy []string `query:"order_by" json:"order_by"` // The filter query to match tasks by. Check out https://vikunja.io/docs/filters for a full explanation. Filter string `query:"filter" json:"filter"` @@ -56,8 +54,7 @@ type TaskCollection struct { // If set to `reactions`, the reactions of each task will be present in the response. // If set to `comments`, the first 50 comments of each task will be present in the response. // You can set this multiple times with different values. - Expand []TaskCollectionExpandable `query:"expand" json:"-"` - ExpandArr []TaskCollectionExpandable `query:"expand[]" json:"-"` + Expand []TaskCollectionExpandable `query:"expand" json:"-"` isSavedFilter bool @@ -107,18 +104,6 @@ func validateTaskField(fieldName string) error { } func getTaskFilterOptsFromCollection(tf *TaskCollection, projectView *ProjectView) (opts *taskSearchOptions, err error) { - if len(tf.SortByArr) > 0 { - tf.SortBy = append(tf.SortBy, tf.SortByArr...) - } - - if len(tf.OrderByArr) > 0 { - tf.OrderBy = append(tf.OrderBy, tf.OrderByArr...) - } - - if len(tf.ExpandArr) > 0 { - tf.Expand = append(tf.Expand, tf.ExpandArr...) - } - var sort = make([]*sortParam, 0, len(tf.SortBy)) for i, s := range tf.SortBy { param := &sortParam{ @@ -272,18 +257,12 @@ func (tf *TaskCollection) ReadAll(s *xorm.Session, a web.Auth, search string, pa // By prepending sort options before the saved ones from the filter, we make sure the supplied sort // options via query take precedence over the rest. - sortby := append(tf.SortBy, tf.SortByArr...) - sortby = append(sortby, sf.Filters.SortBy...) - sortby = append(sortby, sf.Filters.SortByArr...) + sortby := append(tf.SortBy, sf.Filters.SortBy...) - orderby := append(tf.OrderBy, tf.OrderByArr...) - orderby = append(orderby, sf.Filters.OrderBy...) - orderby = append(orderby, sf.Filters.OrderByArr...) + orderby := append(tf.OrderBy, sf.Filters.OrderBy...) sf.Filters.SortBy = sortby - sf.Filters.SortByArr = nil sf.Filters.OrderBy = orderby - sf.Filters.OrderByArr = nil if sf.Filters.FilterTimezone == "" { u, err := user.GetUserByID(s, a.GetID()) @@ -297,8 +276,7 @@ func (tf *TaskCollection) ReadAll(s *xorm.Session, a web.Auth, search string, pa tc.ProjectViewID = tf.ProjectViewID tc.ProjectID = tf.ProjectID tc.isSavedFilter = true - tc.Expand = append(tf.Expand, tf.ExpandArr...) - tc.ExpandArr = nil + tc.Expand = tf.Expand if tf.Filter != "" { if tc.Filter != "" { diff --git a/pkg/models/tasks.go b/pkg/models/tasks.go index b7515b40a..236bc7bca 100644 --- a/pkg/models/tasks.go +++ b/pkg/models/tasks.go @@ -141,8 +141,7 @@ type Task struct { CommentCount *int64 `xorm:"-" json:"comment_count,omitempty"` // Behaves exactly the same as with the TaskCollection.Expand parameter - Expand []TaskCollectionExpandable `xorm:"-" json:"-" query:"expand"` - ExpandArr []TaskCollectionExpandable `xorm:"-" json:"-" query:"expand[]"` + Expand []TaskCollectionExpandable `xorm:"-" json:"-" query:"expand"` // The position of the task - any task project can be sorted as usual by this parameter. // When accessing tasks via views with buckets, this is primarily used to sort them based on a range. @@ -1966,7 +1965,6 @@ func (t *Task) Delete(s *xorm.Session, a web.Auth) (err error) { // @Router /tasks/{id} [get] func (t *Task) ReadOne(s *xorm.Session, a web.Auth) (err error) { - t.Expand = append(t.Expand, t.ExpandArr...) expand := t.Expand if err = t.resolveIDFromProjectAndIndex(s); err != nil { return diff --git a/pkg/models/tasks_permissions.go b/pkg/models/tasks_permissions.go index 71459b13f..c4f07aaa3 100644 --- a/pkg/models/tasks_permissions.go +++ b/pkg/models/tasks_permissions.go @@ -40,7 +40,6 @@ func (t *Task) CanCreate(s *xorm.Session, a web.Auth) (bool, error) { // CanRead determines if a user can read a task func (t *Task) CanRead(s *xorm.Session, a web.Auth) (canRead bool, maxPermission int, err error) { - t.Expand = append(t.Expand, t.ExpandArr...) expand := t.Expand if err = t.resolveIDFromProjectAndIndex(s); err != nil { return