-
Notifications
You must be signed in to change notification settings - Fork 75
/
simple.vue
165 lines (160 loc) · 3.74 KB
/
simple.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<template>
<div class="demo-content simple">
<v-title>Simple</v-title>
<div class="v-row">
<div v-for="(list, listName) in lists" class="v-col--auto">
<div class="panel">
<div class="panel__heading">
<h3>List {{listName}}</h3>
</div>
<div class="panel__body">
<vddl-list class="panel__body--list"
:list="list"
:inserted="handleInserted"
:dragover="handleDragover"
:drop="handleDrop"
:horizontal="false">
<vddl-draggable class="panel__body--item" v-for="(item, index) in list" :key="item.id"
:draggable="item"
:index="index"
:wrapper="list"
effect-allowed="move"
:selected="selectedEvent"
:dragstart="handleDragstart"
:dragend="handleDragend"
:canceled="handleCanceled"
:moved="handleMoved"
v-bind:class="{'selected': selected === item}">
{{item.label}}
</vddl-draggable>
<vddl-placeholder class="red">Custom placeholder</vddl-placeholder>
</vddl-list>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
data(){
return {
"selected": null,
"lists": {
"A": [
{
"id": 1,
"label": "Item A1"
},
{
"id": 2,
"label": "Item A2"
},
{
"id": 3,
"label": "Item A3"
},
{
"id": 4,
"label": "Item A4"
},
{
"id": 5,
"label": "Item A5"
}
],
"B": [
{
"id": 6,
"label": "Item B1"
},
{
"id": 7,
"label": "Item B2"
},
{
"id": 8,
"label": "Item B3"
},
{
"id": 9,
"label": "Item B4"
},
{
"id": 10,
"label": "Item B5"
}
],
"C": [
{
"id": 11,
"label": "Item C1"
},
{
"id": 12,
"label": "Item C2"
},
{
"id": 13,
"label": "Item C3"
},
{
"id": 14,
"label": "Item C4"
},
{
"id": 15,
"label": "Item C5"
}
]
}
}
},
methods: {
selectedEvent: function(item){
this.selected = item;
},
handleDragstart() {
console.log(':v-draggable: dragstart');
},
handleDragend() {
console.log(':v-draggable: dragend');
},
handleCanceled() {
console.log(':v-draggable: canceled');
},
handleInserted() {
console.log(':v-list: inserted');
},
handleDrop(data) {
console.log(':v-list: drop');
console.log(data);
const { index, list, item } = data;
// change the id
item.id = new Date().getTime();
list.splice(index, 0, item);
},
handleMoved(item) {
console.log(':v-draggable: moved');
console.log(item);
const { index, list } = item;
list.splice(index, 1);
},
handleDragover() {
console.log(':v-list: handleDragover');
},
},
};
</script>
<style lang="less">
@import '../styles/_var.less';
.simple .vddl-placeholder {
line-height: @item-height;
border-bottom: 1px solid #eee;
font-size: 14px;
padding-left: 15px;
}
.red {
color: red;
}
</style>