-
Notifications
You must be signed in to change notification settings - Fork 545
/
Copy pathclone-on-control.vue
82 lines (78 loc) · 1.78 KB
/
clone-on-control.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
<template>
<div class="row">
<div class="col-3">
<h3>Draggable 1</h3>
<draggable
class="dragArea list-group"
:list="list1"
:clone="clone"
:group="{ name: 'people', pull: pullFunction }"
@start="start"
item-key="id"
>
<template #item="{ element }">
<div class="list-group-item">
{{ element.name }}
</div>
</template>
</draggable>
</div>
<div class="col-3">
<h3>Draggable 2</h3>
<draggable
class="dragArea list-group"
:list="list2"
group="people"
item-key="id"
>
<template #item="{ element }">
<div class="list-group-item">
{{ element.name }}
</div>
</template>
</draggable>
</div>
<rawDisplayer class="col-3" :value="list1" title="List 1" />
<rawDisplayer class="col-3" :value="list2" title="List 2" />
</div>
</template>
<script>
import draggable from "@/vuedraggable";
let idGlobal = 8;
export default {
name: "clone-on-control",
display: "Clone on Control",
instruction: "Press Ctrl to clone element from list 1",
order: 4,
components: {
draggable
},
data() {
return {
list1: [
{ name: "Jesus", id: 1 },
{ name: "Paul", id: 2 },
{ name: "Peter", id: 3 }
],
list2: [
{ name: "Luc", id: 5 },
{ name: "Thomas", id: 6 },
{ name: "John", id: 7 }
],
controlOnStart: true
};
},
methods: {
clone({ name }) {
return { name, id: idGlobal++ };
},
pullFunction() {
return this.controlOnStart ? "clone" : true;
},
start({ originalEvent }) {
this.controlOnStart = originalEvent.ctrlKey;
}
}
};
</script>
<style scoped></style>