1
0

fix(views): move bucket update to extra endpoint

BREAKING CHANGE: The bucket id of the task model is now only used internally and will not trigger a change in buckets when updating the task.

This resolves a problem where the task update routine needs to know the view context it is in. Because that's not really what it should be used for, the extra endpoint takes all required parameters and handles the complexity of actually updating the bucket.
This fixes a bug where it was impossible to move a task around between buckets of a saved filter view. In that case, the view of the bucket and the project the task was in would be different, hence the update failed.
This commit is contained in:
kolaente
2024-07-02 16:33:46 +02:00
parent e6ce1251f7
commit 359b07dabb
16 changed files with 743 additions and 350 deletions

View File

@ -306,6 +306,8 @@ import TaskPositionModel from '@/models/taskPosition'
import {i18n} from '@/i18n'
import ProjectViewService from '@/services/projectViews'
import ProjectViewModel from '@/models/projectView'
import TaskBucketService from '@/services/taskBucket'
import TaskBucketModel from '@/models/taskBucket'
const {
projectId,
@ -333,6 +335,7 @@ const kanbanStore = useKanbanStore()
const taskStore = useTaskStore()
const projectStore = useProjectStore()
const taskPositionService = ref(new TaskPositionService())
const taskBucketService = ref(new TaskBucketService())
const taskContainerRefs = ref<{ [id: IBucket['id']]: HTMLElement }>({})
const bucketLimitInputRef = ref<HTMLInputElement | null>(null)
@ -519,7 +522,12 @@ async function updateTaskPosition(e) {
await taskPositionService.value.update(newPosition)
if(bucketHasChanged) {
await taskStore.update(newTask)
await taskBucketService.value.update(new TaskBucketModel({
taskId: newTask.id,
bucketId: newTask.bucketId,
projectViewId: viewId,
projectId: project.value.id,
}))
}
// Make sure the first and second task don't both get position 0 assigned

View File

@ -0,0 +1,12 @@
import type {IProjectView} from '@/modelTypes/IProjectView'
import type {IAbstract} from '@/modelTypes/IAbstract'
import type {IBucket} from '@/modelTypes/IBucket'
import type {ITask} from '@/modelTypes/ITask'
import type {IProject} from '@/modelTypes/IProject'
export interface ITaskBucket extends IAbstract {
taskId: ITask['id']
bucketId: IBucket['id']
projectViewId: IProjectView['id']
projectId: IProject['id']
}

View File

@ -0,0 +1,14 @@
import AbstractModel from '@/models/abstractModel'
import type {ITaskBucket} from '@/modelTypes/ITaskBucket'
export default class TaskBucketModel extends AbstractModel<ITaskBucket> implements ITaskBucket {
taskId = 0
bucketId = 0
projectViewId = 0
projectId = 0
constructor(data: Partial<ITaskBucket>) {
super()
this.assignData(data)
}
}

View File

@ -0,0 +1,15 @@
import AbstractService from '@/services/abstractService'
import type {ITaskBucket} from '@/modelTypes/ITaskBucket'
import TaskBucketModel from '@/models/taskBucket'
export default class TaskBucketService extends AbstractService<ITaskBucket> {
constructor() {
super({
update: '/projects/{projectId}/views/{projectViewId}/buckets/{bucketId}/tasks',
})
}
modelFactory(data: Partial<ITaskBucket>) {
return new TaskBucketModel(data)
}
}