Skip to content

Integrate MultiDrag plugin #1052

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b7aef22
create spec for multidrag plugin
divinespear Jun 7, 2021
ec7a745
add props and initialization for multidrag plugin
divinespear Jun 7, 2021
0d40b0c
add example component
divinespear Jun 7, 2021
18e11ba
improve test for initialized
divinespear Jun 7, 2021
cec476a
add multidrag event to emit
divinespear Jun 7, 2021
cdf358e
add prop check spec
divinespear Jun 7, 2021
729898a
remove mock code for run real code
divinespear Jun 7, 2021
76df629
add test for multi-select by multidrag plugin
divinespear Jun 7, 2021
f49f9d6
change event delegation hack to use jest.spyOn
divinespear Jun 8, 2021
09c7f99
clear prettier/prettier warning
divinespear Jun 8, 2021
cc3ddd4
add expect for newIndicies by multidrag plugin
divinespear Jun 8, 2021
a9972d5
implement multidrag
divinespear Jun 10, 2021
eb7b6f9
add more multidrag test and fix wrong codes
divinespear Jun 10, 2021
c0e5000
improve multi item drag and drop test
divinespear Jun 10, 2021
413f2e9
apply eslint prettier
divinespear Jun 11, 2021
2168b61
implements multi item add that drop from other
divinespear Jun 11, 2021
5ac1316
single quote javascript string
divinespear Jun 11, 2021
9f80400
implements multi item remove that drop to other
divinespear Jun 11, 2021
b1d90bc
improve update multi
divinespear Jun 11, 2021
948ad01
emit change to array for multi drag
divinespear Jun 11, 2021
940011f
enhance initialization
divinespear Jun 11, 2021
665dd3f
update README for multidrag plugin
divinespear Jun 11, 2021
047a4e4
clear source
divinespear Jun 17, 2021
a094566
just reuse optionsAdded instead additional options
divinespear Jun 17, 2021
e3b5726
make code clearer with codebeat
divinespear Jun 17, 2021
b994869
fixed bug on remove multiple item with v-model
divinespear Jul 8, 2021
405bc86
deselect selected nodes while remove
divinespear Jul 8, 2021
9a77b7e
fixed undefined $slots.header
divinespear Jul 8, 2021
20964c3
cleaning source
divinespear Jul 8, 2021
d5c5ce5
source cleanup
divinespear Jul 8, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,12 +300,33 @@ methods: {
}
```

#### multiDrag
Type: `boolean`<br>
Required: `false`<br>
Default: `false`<br>

Set `true` for activate [MultiDrag](https://github.com/SortableJS/Sortable/wiki/Dragging-Multiple-Items-in-Sortable) plugin.

#### multiDragKey
Type: `string`<br>
Required: `false`<br>
Default: `undefined`<br>

See "Selection key" part of [MultiDrag](https://github.com/SortableJS/Sortable/wiki/Dragging-Multiple-Items-in-Sortable) plugin.

#### selectedClass
Type: `string`<br>
Required: `false`<br>
Default: `sortable-selected` (from Sortable.js)<br>

The selected class is the HTML class that will be applied to the selected elements in the list.

### Events

* Support for Sortable events:

`start`, `add`, `remove`, `update`, `end`, `choose`, `unchoose`, `sort`, `filter`, `clone`<br>
Events are called whenever onStart, onAdd, onRemove, onUpdate, onEnd, onChoose, onUnchoose, onSort, onClone are fired by Sortable.js with the same argument.<br>
`start`, `add`, `remove`, `update`, `end`, `choose`, `unchoose`, `sort`, `filter`, `clone`, `select`, `deselect`<br>
Events are called whenever onStart, onAdd, onRemove, onUpdate, onEnd, onChoose, onUnchoose, onSort, onClone, onSelect, onDeselect are fired by Sortable.js with the same argument.<br>
[See here for reference](https://github.com/RubaXa/Sortable#event-object-demo)

Note that SortableJS OnMove callback is mapped with the [move prop](https://github.com/SortableJS/Vue.Draggable/blob/master/README.md#move)
Expand Down
102 changes: 102 additions & 0 deletions example/components/multidrag.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<template>
<div class="row">
<div class="col-3">
<h3>Draggable 1</h3>
<draggable
class="list-group"
v-model="list1"
group="people"
multi-drag
selected-class="selected"
@change="log"
@select="log"
@deselect="log"
>
<div
class="list-group-item"
v-for="(element, index) in list1"
:key="element.name"
>
{{ element.name }} {{ index }}
</div>
</draggable>
</div>

<div class="col-3">
<h3>Draggable 2</h3>
<draggable
class="list-group"
v-model="list2"
group="people"
multi-drag
selected-class="selected"
@change="log"
@select="log"
@deselect="log"
>
<div
class="list-group-item"
v-for="(element, index) in list2"
:key="element.name"
>
{{ element.name }} {{ index }}
</div>
</draggable>
</div>

<rawDisplayer class="col-3" :value="list1" title="List 1" />

<rawDisplayer class="col-3" :value="list2" title="List 2" />
</div>
</template>

<style scoped>
.selected {
color: red !important;
background-color: rgba(255, 0, 0, 0.2) !important;
}
</style>

<script>
import draggable from "@/vuedraggable";

export default {
name: "multi-drag",
display: "Multi Drag",
order: 18,
components: {
draggable
},
data() {
return {
list1: [
{ name: "John", id: 1 },
{ name: "Joao", id: 2 },
{ name: "Jean", id: 3 },
{ name: "Gerard", id: 4 }
],
list2: [
{ name: "Juan", id: 5 },
{ name: "Edgard", id: 6 },
{ name: "Johnson", id: 7 }
]
};
},
methods: {
add: function() {
this.list.push({ name: "Juan" });
},
replace: function() {
this.list = [{ name: "Edgard" }];
},
clone: function(el) {
return {
name: el.name + " cloned"
};
},
log: function(evt) {
window.console.log(evt);
}
}
};
</script>
4 changes: 4 additions & 0 deletions src/vuedraggable.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ declare module 'vuedraggable' {
tag?: string | null;
move: any;
componentData: any;
// plugin: multidrag
multiDrag?: boolean;
multiDragKey?: string;
selectedClass?: string;
}
>;

Expand Down
Loading