When droping an item I want to be able to perform an async call (e.g. check with backend for conflicts, collisions and so forth...) which returns true or false. If false, I want to "reverse" the drop so that the item appears in the original array.
I coulnd't find any references in the offical docs, so any pointers are appreciated on how to tackle this challenge.
For anyone else looking for this, here's one way to do it. It would be great if the move could somehow be told to wait for the result before reverting, but I couldn't figure out how to do it.
try{
//Move the value first
transferArrayItem(event.previousContainer.data,
event.container.data,
event.previousIndex,
event.currentIndex);
//Wait for the result and then roll back the change if required
this.openEdit(event.previousContainer.data[event.previousIndex]).subscribe((result:Updated) =>
{
if(result?.success !== 1){
transferArrayItem(event.container.data,
event.previousContainer.data,
event.currentIndex,
event.previousIndex);
}
});
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With