feat(views): save task position in list view
This commit is contained in:
parent
f364f3bec8
commit
4170f5468f
@ -73,7 +73,7 @@
|
|||||||
>
|
>
|
||||||
<template v-if="canWrite">
|
<template v-if="canWrite">
|
||||||
<span class="icon handle">
|
<span class="icon handle">
|
||||||
<icon icon="grip-lines" />
|
<icon icon="grip-lines"/>
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
</SingleTaskInProject>
|
</SingleTaskInProject>
|
||||||
@ -118,6 +118,8 @@ import {useTaskStore} from '@/stores/tasks'
|
|||||||
|
|
||||||
import type {IProject} from '@/modelTypes/IProject'
|
import type {IProject} from '@/modelTypes/IProject'
|
||||||
import type {IProjectView} from '@/modelTypes/IProjectView'
|
import type {IProjectView} from '@/modelTypes/IProjectView'
|
||||||
|
import TaskPositionService from '@/services/taskPosition'
|
||||||
|
import TaskPositionModel from '@/models/taskPosition'
|
||||||
|
|
||||||
const {
|
const {
|
||||||
projectId,
|
projectId,
|
||||||
@ -145,6 +147,8 @@ const {
|
|||||||
sortByParam,
|
sortByParam,
|
||||||
} = useTaskList(() => projectId, () => view.id, {position: 'asc'})
|
} = useTaskList(() => projectId, () => view.id, {position: 'asc'})
|
||||||
|
|
||||||
|
const taskPositionService = ref(new TaskPositionService())
|
||||||
|
|
||||||
const tasks = ref<ITask[]>([])
|
const tasks = ref<ITask[]>([])
|
||||||
watch(
|
watch(
|
||||||
allTasks,
|
allTasks,
|
||||||
@ -234,13 +238,17 @@ async function saveTaskPosition(e) {
|
|||||||
const taskBefore = tasks.value[e.newIndex - 1] ?? null
|
const taskBefore = tasks.value[e.newIndex - 1] ?? null
|
||||||
const taskAfter = tasks.value[e.newIndex + 1] ?? null
|
const taskAfter = tasks.value[e.newIndex + 1] ?? null
|
||||||
|
|
||||||
const newTask = {
|
const position = calculateItemPosition(taskBefore !== null ? taskBefore.position : null, taskAfter !== null ? taskAfter.position : null)
|
||||||
...task,
|
|
||||||
position: calculateItemPosition(taskBefore !== null ? taskBefore.position : null, taskAfter !== null ? taskAfter.position : null),
|
|
||||||
}
|
|
||||||
|
|
||||||
const updatedTask = await taskStore.update(newTask)
|
await taskPositionService.value.update(new TaskPositionModel({
|
||||||
tasks.value[e.newIndex] = updatedTask
|
position,
|
||||||
|
projectViewId: view.id,
|
||||||
|
taskId: task.id,
|
||||||
|
}))
|
||||||
|
tasks.value[e.newIndex] = {
|
||||||
|
...task,
|
||||||
|
position,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function prepareFiltersAndLoadTasks() {
|
function prepareFiltersAndLoadTasks() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user