1
0

feat(views): fetch tasks via view context when accessing them through views

This commit is contained in:
kolaente
2024-03-15 22:18:44 +01:00
parent ee6ea03506
commit cf15cc6f12
16 changed files with 210 additions and 108 deletions

View File

@ -15,6 +15,7 @@ import type {ITask} from '@/modelTypes/ITask'
import type {IProject} from '@/modelTypes/IProject'
import type {IBucket} from '@/modelTypes/IBucket'
import {useAuthStore} from '@/stores/auth'
import type {IProjectView} from '@/modelTypes/IProjectView'
const TASKS_PER_BUCKET = 25
@ -247,6 +248,7 @@ export const useKanbanStore = defineStore('kanban', () => {
async function loadNextTasksForBucket(
projectId: IProject['id'],
viewId: IProjectView['id'],
ps: TaskFilterParams,
bucketId: IBucket['id'],
) {
@ -275,7 +277,7 @@ export const useKanbanStore = defineStore('kanban', () => {
const taskService = new TaskCollectionService()
try {
const tasks = await taskService.getAll({projectId}, params, page)
const tasks = await taskService.getAll({projectId, viewId}, params, page)
addTasksToBucket({tasks, bucketId: bucketId})
setTasksLoadedForBucketPage({bucketId, page})
if (taskService.totalPages <= page) {

View File

@ -30,6 +30,7 @@ import ProjectUserService from '@/services/projectUsers'
import {useAuthStore} from '@/stores/auth'
import TaskCollectionService, {type TaskFilterParams} from '@/services/taskCollection'
import {getRandomColorHex} from '@/helpers/color/randomColor'
import type {IProjectView} from '@/modelTypes/IProjectView'
interface MatchedAssignee extends IUser {
match: string,
@ -124,21 +125,23 @@ export const useTaskStore = defineStore('task', () => {
})
}
async function loadTasks(params: TaskFilterParams, projectId: IProject['id'] | null = null) {
async function loadTasks(
params: TaskFilterParams,
projectId: IProject['id'] | null = null,
) {
if (!params.filter_timezone || params.filter_timezone === '') {
params.filter_timezone = authStore.settings.timezone
}
if (projectId !== null) {
params.filter = 'project = '+projectId+' && (' + params.filter +')'
}
const cancel = setModuleLoading(setIsLoading)
try {
if (projectId === null) {
const taskService = new TaskService()
tasks.value = await taskService.getAll({}, params)
} else {
const taskCollectionService = new TaskCollectionService()
tasks.value = await taskCollectionService.getAll({projectId}, params)
}
const taskService = new TaskService()
tasks.value = await taskService.getAll({}, params)
baseStore.setHasTasks(tasks.value.length > 0)
return tasks.value
} finally {