-
-
Notifications
You must be signed in to change notification settings - Fork 303
Expand file tree
/
Copy pathEditListItems.vue
More file actions
92 lines (83 loc) · 1.68 KB
/
Copy pathEditListItems.vue
File metadata and controls
92 lines (83 loc) · 1.68 KB
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
86
87
88
89
90
91
92
<template>
<VList two-line class="pl-3">
<EditListItem
:key="nodeId"
v-model="selected"
:nodeId="nodeId"
@input="trackSelect"
@removed="handleRemoved"
/>
<div v-if="getChildren !== undefined && getChildren.length">
<EditListItems
v-for="childId in getChildren"
:key="childId"
v-model="selected"
:nodeId="childId"
:nodes="nodes"
:nodeIds="nodeIds"
@input="trackSelect"
@removed="handleRemoved"
/>
</div>
</VList>
</template>
<script>
import EditListItem from './EditListItem';
export default {
name: 'EditListItems',
components: {
EditListItem,
},
props: {
value: {
type: Array,
default: () => [],
},
nodeIds: {
type: Array,
default: () => [],
},
nodeId: {
type: String,
require: true,
default: null,
},
nodes: {
type: Object,
default: () => {},
},
},
computed: {
selected: {
get() {
return this.value;
},
set(items) {
this.$emit('input', items);
},
},
getChildren() {
const childrens = [];
Object.keys(this.nodes).forEach(nodeId => {
if (this.nodes[nodeId] === this.nodeId) {
childrens.push(nodeId);
}
});
return childrens;
},
},
methods: {
handleRemoved(nodeId) {
this.$emit('removed', nodeId);
},
trackSelect(value) {
this.$emit('input', value);
},
},
};
</script>
<style lang="less" scoped>
.v-divider {
margin-top: 0;
}
</style>