Skip to content

Commit fc991dc

Browse files
two list example
1 parent feba076 commit fc991dc

File tree

6 files changed

+146
-5
lines changed

6 files changed

+146
-5
lines changed

example/App.vue

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@
2020
aria-selected="true"
2121
>Simple</a>
2222
</li>
23+
24+
<li class="nav-item">
25+
<a
26+
class="nav-link"
27+
data-toggle="tab"
28+
href="#twoLists"
29+
role="tab"
30+
aria-controls="profile"
31+
aria-selected="false"
32+
>Two Lists</a>
33+
</li>
34+
2335
</ul>
2436
<div
2537
class="tab-content"
@@ -32,22 +44,35 @@
3244
role="tabpanel"
3345
aria-labelledby="profile-tab"
3446
>
35-
3647
<simple />
3748

3849
</div>
3950

51+
<div
52+
class="tab-pane show"
53+
id="twoLists"
54+
role="tabpanel"
55+
aria-labelledby="profile-tab"
56+
>
57+
<twoLists />
58+
59+
</div>
60+
61+
4062
</div>
4163
</div>
4264
</div>
4365
</template>
4466

4567
<script>
4668
import simple from "./components/simple";
69+
import twoLists from "./components/two-lists";
70+
4771
export default {
4872
name: "app",
4973
components: {
50-
simple
74+
simple,
75+
twoLists
5176
}
5277
};
5378
</script>

example/components/simple.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@
2020
</div>
2121
</div>
2222

23-
<div class="list-group col-6">
23+
<div class="col-6">
2424
<h2>Draggable {{draggingInfo}}</h2>
2525

2626
<draggable
2727
:list="list"
28+
class="list-group"
2829
@start="dragging=true"
2930
@end="dragging=false"
3031
>

example/components/two-lists.vue

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<template>
2+
<div class=" justify-content-center jumbotron">
3+
4+
<div class="row">
5+
<div class="col-3">
6+
<h3>Draggable for list 1</h3>
7+
<draggable
8+
class="dragArea list-group"
9+
:list="list1"
10+
:options="{group:'people'}"
11+
@change="log"
12+
>
13+
<div
14+
class="list-group-item"
15+
v-for="(element, index) in list1"
16+
:key="element.name"
17+
>
18+
{{element.name}} {{index}}
19+
</div>
20+
</draggable>
21+
</div>
22+
23+
<div class="col-3">
24+
<h3>Draggable for list 2</h3>
25+
<draggable
26+
class="dragArea list-group"
27+
:list="list2"
28+
:options="{group:'people'}"
29+
@change="log"
30+
>
31+
<div
32+
class="list-group-item"
33+
v-for="(element, index) in list2"
34+
:key="element.name"
35+
>
36+
{{element.name}} {{index}}
37+
</div>
38+
</draggable>
39+
</div>
40+
41+
<rawDisplayer
42+
class="col-3"
43+
:value="list1"
44+
title="List 1"
45+
/>
46+
47+
<rawDisplayer
48+
class="col-3"
49+
:value="list2"
50+
title="List 2"
51+
/>
52+
53+
</div>
54+
55+
</div>
56+
57+
</template>
58+
<script>
59+
import draggable from "@/components/Vuedraggable";
60+
import rawDisplayer from "./raw-displayer.vue";
61+
62+
export default {
63+
components: {
64+
draggable,
65+
rawDisplayer
66+
},
67+
data() {
68+
return {
69+
list1: [
70+
{ name: "John", id: 1 },
71+
{ name: "Joao", id: 2 },
72+
{ name: "Jean", id: 3 },
73+
{ name: "Gerard", id: 4 }
74+
],
75+
list2: [
76+
{ name: "Juan", id: 5 },
77+
{ name: "Edgard", id: 6 },
78+
{ name: "Johnson", id: 7 }
79+
]
80+
};
81+
},
82+
methods: {
83+
add: function() {
84+
this.list.push({ name: "Juan" });
85+
},
86+
replace: function() {
87+
this.list = [{ name: "Edgard" }];
88+
},
89+
clone: function(el) {
90+
return {
91+
name: el.name + " cloned"
92+
};
93+
},
94+
log: function(evt) {
95+
console.log(evt);
96+
}
97+
}
98+
};
99+
</script>
100+
<style>
101+
.dragArea {
102+
min-height: 10px;
103+
}
104+
</style>
105+

example/main.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import Vue from "vue";
22
import App from "./App.vue";
33
import "bootstrap/dist/css/bootstrap.min.css";
4+
require("bootstrap");
5+
46

57
Vue.config.productionTip = false;
68

package-lock.json

Lines changed: 8 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"test:unit": "vue-cli-service test:unit"
1313
},
1414
"dependencies": {
15-
"bootstrap": "^4.3.1",
1615
"sortablejs": "^1.8.3",
1716
"vue": "^2.5.22"
1817
},
@@ -26,9 +25,11 @@
2625
"babel-core": "7.0.0-bridge.0",
2726
"babel-eslint": "^10.0.1",
2827
"babel-jest": "^23.6.0",
28+
"bootstrap": "^4.3.1",
2929
"component-fixture": "^0.4.1",
3030
"eslint": "^5.8.0",
3131
"eslint-plugin-vue": "^5.0.0",
32+
"jquery": "^3.3.1",
3233
"vue-cli-plugin-component": "^1.10.5",
3334
"vue-template-compiler": "^2.5.21"
3435
},

0 commit comments

Comments
 (0)