feat(tasks): expand subtasks (#2345)
This change adds a parameter to expand subtasks - if provided, Vikunja will ensure all subtasks are present in the results list. Resolves https://community.vikunja.io/t/subtasks-show-on-different-pages/2292 Reviewed-on: https://kolaente.dev/vikunja/vikunja/pulls/2345 Co-authored-by: kolaente <k@knt.li> Co-committed-by: kolaente <k@knt.li>
This commit is contained in:
@ -45,12 +45,21 @@ type TaskCollection struct {
|
||||
// If set to true, the result will also include null values
|
||||
FilterIncludeNulls bool `query:"filter_include_nulls" json:"filter_include_nulls"`
|
||||
|
||||
// If set to `subtasks`, Vikunja will fetch only tasks which do not have subtasks and then in a
|
||||
// second step, will fetch all of these subtasks. This may result in more tasks than the
|
||||
// pagination limit being returned, but all subtasks will be present in the response.
|
||||
Expand TaskCollectionExpandable `query:"expand" json:"-"`
|
||||
|
||||
isSavedFilter bool
|
||||
|
||||
web.CRUDable `xorm:"-" json:"-"`
|
||||
web.Rights `xorm:"-" json:"-"`
|
||||
}
|
||||
|
||||
type TaskCollectionExpandable string
|
||||
|
||||
const TaskCollectionExpandSubtasks TaskCollectionExpandable = `subtasks`
|
||||
|
||||
func validateTaskField(fieldName string) error {
|
||||
switch fieldName {
|
||||
case
|
||||
@ -181,6 +190,7 @@ func getRelevantProjectsFromCollection(s *xorm.Session, a web.Auth, tf *TaskColl
|
||||
// @Param filter query string false "The filter query to match tasks by. Check out https://vikunja.io/docs/filters for a full explanation of the feature."
|
||||
// @Param filter_timezone query string false "The time zone which should be used for date match (statements like "now" resolve to different actual times)"
|
||||
// @Param filter_include_nulls query string false "If set to true the result will include filtered fields whose value is set to `null`. Available values are `true` or `false`. Defaults to `false`."
|
||||
// @Param expand query string false "If set to `subtasks`, Vikunja will fetch only tasks which do not have subtasks and then in a second step, will fetch all of these subtasks. This may result in more tasks than the pagination limit being returned, but all subtasks will be present in the response. You can only set this to `subtasks`."
|
||||
// @Security JWTKeyAuth
|
||||
// @Success 200 {array} models.Task "The tasks"
|
||||
// @Failure 500 {object} models.Message "Internal error"
|
||||
@ -251,6 +261,7 @@ func (tf *TaskCollection) ReadAll(s *xorm.Session, a web.Auth, search string, pa
|
||||
opts.search = search
|
||||
opts.page = page
|
||||
opts.perPage = perPage
|
||||
opts.expand = tf.Expand
|
||||
|
||||
if view != nil {
|
||||
var hasOrderByPosition bool
|
||||
|
Reference in New Issue
Block a user