mirror of
https://github.com/go-vikunja/vikunja.git
synced 2026-04-24 22:25:15 +00:00
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>
44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
import AbstractService from '@/services/abstractService'
|
|
import TaskModel from '@/models/task'
|
|
|
|
import type {ITask} from '@/modelTypes/ITask'
|
|
import BucketModel from '@/models/bucket'
|
|
|
|
export interface TaskFilterParams {
|
|
sort_by: ('start_date' | 'end_date' | 'due_date' | 'done' | 'id' | 'position' | 'kanban_position')[],
|
|
order_by: ('asc' | 'desc')[],
|
|
filter: string,
|
|
filter_include_nulls: boolean,
|
|
filter_timezone?: string,
|
|
s: string,
|
|
per_page?: number,
|
|
expand?: 'subtasks' | null,
|
|
}
|
|
|
|
export function getDefaultTaskFilterParams(): TaskFilterParams {
|
|
return {
|
|
sort_by: ['position', 'id'],
|
|
order_by: ['asc', 'desc'],
|
|
filter: '',
|
|
filter_include_nulls: false,
|
|
filter_timezone: '',
|
|
s: '',
|
|
expand: 'subtasks',
|
|
}
|
|
}
|
|
|
|
export default class TaskCollectionService extends AbstractService<ITask> {
|
|
constructor() {
|
|
super({
|
|
getAll: '/projects/{projectId}/views/{viewId}/tasks',
|
|
})
|
|
}
|
|
|
|
modelFactory(data) {
|
|
// FIXME: There must be a better way for this…
|
|
if (typeof data.project_view_id !== 'undefined') {
|
|
return new BucketModel(data)
|
|
}
|
|
return new TaskModel(data)
|
|
}
|
|
} |