-
Notifications
You must be signed in to change notification settings - Fork 67
/
Advanced.vue
85 lines (78 loc) · 1.55 KB
/
Advanced.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<template>
<ComponentExample link="Advanced">
<VueNestable
v-model="nestableItems"
:max-depth="2"
:hooks="{
'beforeMove': beforeMove
}"
key-prop="key"
children-prop="nested"
class-prop="class"
>
<template slot-scope="{ item }">
<!-- Handler -->
<VueNestableHandle :item="item">
<i class="fas fa-bars" />
</VueNestableHandle>
<!-- Content -->
<span>Item :: {{ item.text }}</span>
</template>
</VueNestable>
</ComponentExample>
</template>
<script>
import ComponentExample from './ComponentExample.vue'
export default {
components: {
ComponentExample
},
data () {
return {
nestableItems: [
{
key: 0,
class: 'purple-text-color',
text: 'Andy'
}, {
key: 1,
class: 'blue-text-color',
text: 'Harry',
nested: [{
key: 2,
text: 'David'
}]
}, {
key: 3,
class: 'red-text-color',
text: 'Lisa'
}, {
key: 4,
text: 'I can not be nested'
}
]
}
},
methods: {
beforeMove ({ dragItem, pathFrom, pathTo }) {
// Item 4 can not be nested more than one level
if (dragItem.key === 4) {
return pathTo.length === 1
}
// All other items can be
return true
}
}
}
</script>
<style>
.blue-text-color {
color: #415ad4;
}
.purple-text-color {
color: #b43ceb;
}
.red-text-color {
color: #e13a3a;
}
</style>