11
11
<p v-if =" boards.length === 0" class =" text-center text-gray-200" >
12
12
You have no boards
13
13
</p >
14
- <template v-else >
15
- <div
16
- class =" flex space-x-6 scroll pb-4 overflow-auto"
17
- style =" height : calc (100vh - 6.5rem )"
18
- >
14
+ <draggable
15
+ v-else
16
+ v-model =" boards"
17
+ :animation =" 250"
18
+ item-key =" id"
19
+ group =" boards"
20
+ class =" flex space-x-6 scroll pb-4 overflow-auto"
21
+ style =" height : calc (100vh - 6.5rem )"
22
+ >
23
+ <template #item =" { element } " >
19
24
<board-column
20
- v-for =" board in boards"
21
- v-bind =" { key: board.id, board, repository: project.repository }"
22
- :key =" board.id"
25
+ v-bind =" { board: element, repository: project.repository }"
23
26
@modal =" showModal"
24
27
></board-column >
25
- </div >
26
- </template >
28
+ </template >
29
+ </draggable >
27
30
<ui-modal v-model =" modalState.show" position =" items-start" >
28
31
<template #header >
29
32
<p >{{ modalState.type === 'issue' ? 'Add Issue Card' : 'Add Card' }}</p >
42
45
import { computed , shallowReactive } from ' vue' ;
43
46
import { useStore } from ' vuex' ;
44
47
import { useRoute } from ' vue-router' ;
48
+ import Draggable from ' vuedraggable/src/vuedraggable' ;
45
49
import { useDialog } from ' @/composable/dialog' ;
46
50
import Board from ' @/models/board' ;
47
51
import AddCard from ' @/components/boards/AddCard.vue' ;
48
52
import BoardColumn from ' @/components/boards/BoardColumn.vue' ;
49
53
import AddIssueCard from ' @/components/boards/AddIssueCard.vue' ;
50
54
51
55
export default {
52
- components: { AddCard, AddIssueCard, BoardColumn },
56
+ components: { AddCard, AddIssueCard, BoardColumn, Draggable },
53
57
props: {
54
58
packageJSON: {
55
59
type: Object ,
@@ -72,18 +76,31 @@ export default {
72
76
boardId: ' ' ,
73
77
});
74
78
75
- const boards = computed (() =>
76
- Board .query ().where (' projectId' , route .params .id ).with (' cards' ).get ()
77
- );
79
+ const boards = computed ({
80
+ get () {
81
+ return Board .query ()
82
+ .where (' projectId' , route .params .id )
83
+ .orderBy (' order' )
84
+ .get ();
85
+ },
86
+ set (value ) {
87
+ const data = value .map ((item , index ) => ({ ... item, order: index }));
88
+
89
+ Board .update ({ data });
90
+ },
91
+ });
78
92
79
93
function addBoard () {
80
94
dialog .prompt ({
81
95
title: ' Add board' ,
82
96
label: ' Board name' ,
83
97
onConfirm (name ) {
98
+ const maxOrder = Board .query ().max (' order' );
99
+
84
100
Board .insert ({
85
101
data: {
86
102
name,
103
+ order: maxOrder + 1 ,
87
104
projectId: route .params .id ,
88
105
},
89
106
});
0 commit comments