Using vue I am trying to change/update an array (draggables) based on the logic that if the object exists in another array of arrays (drozones) it will be removed from draggables
Each draggable would only be found in the index of the multi-dimensional array that matches the draggables dropID.
Every approach I have tried either returns all draggable items, no draggable items or the incorrect draggable items is being removed.
// In this example I have three droppable and two drop areas, the first drop area can handle two droppable and the last area only one.
<div id="app">
<ul>
<li v-for="item in draggables">Item ID: {{item.id}} - Dropzone ID: {{item.dropID}}</li>
</ul>
</div>
data: {
draggableItems: [{id: 0, dropID: 0 }, {id: 1, dropID: 0 }, {id: 2, dropID: 1 }],
dropzones: [[{id: 1, dropID: 0 }], []]
},
computed : () {
draggables () {
return this.draggableItems.filter((item, index) => {
console.log('item', item)
return this.dropzones.filter((zone,i) => {
if (zone.length === 0) return
return item.id !== zone[i].id
})
})
}
}
Here is a fiddle of some of my attempts but with no luck yet. Thanks for your help