File tree Expand file tree Collapse file tree 2 files changed +17
-10
lines changed Expand file tree Collapse file tree 2 files changed +17
-10
lines changed Original file line number Diff line number Diff line change 1
1
<script setup lang="ts">
2
- import { VueDraggable } from ' vue-draggable-plus'
2
+ import { type SortableEvent , VueDraggable } from ' vue-draggable-plus'
3
3
import type { Task } from ' ../types/tasks'
4
- import type { VueDraggableEvent } from ' ~/types/vue-draggable-plus'
5
4
import { doneTaskStatuses } from ' ~/constants/tasks'
6
5
7
6
const props = defineProps <{
@@ -29,18 +28,23 @@ watchEffect(() => {
29
28
}
30
29
})
31
30
32
- function handleMoveTask(event : VueDraggableEvent ) {
33
- const { id, kind } = event .item .dataset
34
- const { column } = event .to .dataset
31
+ function handleMoveTask(event : SortableEvent ) {
32
+ const { oldIndex, newIndex, item, to } = event
33
+ const { id, kind } = item .dataset
34
+ const { column } = to .dataset
35
+ if (! id || ! kind || ! column || oldIndex === undefined || newIndex === undefined ) {
36
+ throw new Error (' Invalid task move event' )
37
+ }
38
+
35
39
const task = props .tasks .find ((task ) => task .rpb .kind === kind && task .id === id )
36
- if (! task || ! column || (task .rpb .column === column && event . oldIndex === event . newIndex )) {
40
+ if (! task || ! column || (task .rpb .column === column && oldIndex === newIndex )) {
37
41
return
38
42
}
39
43
40
44
tasks .moveTask ({
41
45
task ,
42
46
column ,
43
- index: event . newIndex ,
47
+ index: newIndex ,
44
48
})
45
49
}
46
50
Original file line number Diff line number Diff line change 1
1
<script setup lang="ts">
2
- import { VueDraggable } from ' vue-draggable-plus'
2
+ import { type SortableEvent , VueDraggable } from ' vue-draggable-plus'
3
3
import { elementIds } from ' ~/constants/elements'
4
- import type { VueDraggableEvent } from ' ~/types/vue-draggable-plus'
5
4
6
5
const auth = useAuthStore ()
7
6
const tasks = useTasksStore ()
@@ -15,7 +14,11 @@ watchEffect(() => {
15
14
}
16
15
})
17
16
18
- function handleMoveColumn({ oldIndex , newIndex }: VueDraggableEvent ) {
17
+ function handleMoveColumn({ oldIndex , newIndex }: SortableEvent ) {
18
+ if (! oldIndex || ! newIndex ) {
19
+ throw new Error (' Invalid column move event' )
20
+ }
21
+
19
22
const column = board .state .columns [oldIndex ]
20
23
if (! column ) {
21
24
return
You can’t perform that action at this time.
0 commit comments