@@ -40,7 +40,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
40
40
var _this = this ;
41
41
42
42
return function ( evtData ) {
43
- if ( _this . list !== null ) {
43
+ if ( _this . realList !== null ) {
44
44
_this [ 'onDrag' + evtName ] ( evtData ) ;
45
45
}
46
46
emit . call ( _this , evtName , evtData ) ;
@@ -61,6 +61,11 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
61
61
required : false ,
62
62
default : null
63
63
} ,
64
+ value : {
65
+ type : Array ,
66
+ required : false ,
67
+ default : null
68
+ } ,
64
69
clone : {
65
70
type : Function ,
66
71
default : function _default ( original ) {
@@ -123,6 +128,9 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
123
128
} ,
124
129
isCloning : function isCloning ( ) {
125
130
return ! ! this . options && this . options . group !== null && this . options . group . pull === 'clone' ;
131
+ } ,
132
+ realList : function realList ( ) {
133
+ return ! ! this . list ? this . list : this . value ;
126
134
}
127
135
} ,
128
136
@@ -134,7 +142,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
134
142
}
135
143
}
136
144
} ,
137
- list : function list ( ) {
145
+ realList : function realList ( ) {
138
146
this . computeIndexes ( ) ;
139
147
}
140
148
} ,
@@ -153,7 +161,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
153
161
} ,
154
162
getUnderlyingVm : function getUnderlyingVm ( htmlElt ) {
155
163
var index = computeVmIndex ( this . getChildrenNodes ( ) , htmlElt ) ;
156
- var element = this . list [ index ] ;
164
+ var element = this . realList [ index ] ;
157
165
return { index : index , element : element } ;
158
166
} ,
159
167
getUnderlyingPotencialDraggableComponent : function getUnderlyingPotencialDraggableComponent ( _ref ) {
@@ -171,23 +179,38 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
171
179
_this4 . $emit ( 'change' , evt ) ;
172
180
} ) ;
173
181
} ,
182
+ alterList : function alterList ( onList ) {
183
+ if ( ! ! this . list ) {
184
+ onList ( this . list ) ;
185
+ } else {
186
+ var newList = [ ] . concat ( _toConsumableArray ( this . value ) ) ;
187
+ onList ( newList ) ;
188
+ this . $emit ( 'input' , newList ) ;
189
+ }
190
+ } ,
174
191
spliceList : function spliceList ( ) {
175
- var _list ;
192
+ var _arguments = arguments ;
176
193
177
- ( _list = this . list ) . splice . apply ( _list , arguments ) ;
194
+ var spliceList = function spliceList ( list ) {
195
+ return list . splice . apply ( list , _arguments ) ;
196
+ } ;
197
+ this . alterList ( spliceList ) ;
178
198
} ,
179
199
updatePosition : function updatePosition ( oldIndex , newIndex ) {
180
- this . list . splice ( newIndex , 0 , this . list . splice ( oldIndex , 1 ) [ 0 ] ) ;
200
+ var updatePosition = function updatePosition ( list ) {
201
+ return list . splice ( newIndex , 0 , list . splice ( oldIndex , 1 ) [ 0 ] ) ;
202
+ } ;
203
+ this . alterList ( updatePosition ) ;
181
204
} ,
182
205
getRelatedContextFromMoveEvent : function getRelatedContextFromMoveEvent ( _ref2 ) {
183
- var to = _ref2 . to ,
184
- related = _ref2 . related ;
206
+ var to = _ref2 . to ;
207
+ var related = _ref2 . related ;
185
208
186
209
var component = this . getUnderlyingPotencialDraggableComponent ( to ) ;
187
210
if ( ! component ) {
188
211
return { component : component } ;
189
212
}
190
- var list = component . list ;
213
+ var list = component . realList ;
191
214
var context = { list : list , component : component } ;
192
215
if ( to !== related && list && component . getUnderlyingVm ) {
193
216
var destination = component . getUnderlyingVm ( related ) ;
@@ -250,7 +273,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
250
273
} ,
251
274
onDragMove : function onDragMove ( evt ) {
252
275
var onMove = this . move ;
253
- if ( ! onMove || ! this . list ) {
276
+ if ( ! onMove || ! this . realList ) {
254
277
return true ;
255
278
}
256
279
0 commit comments