It's nice to have a function like this
shouldMoveNode = (nextNode, prevNode) => {
return nextNode.node.is_enable ? true : false;
};
prevNode?Making some assumptions here, but:
The node itself should remain unchanged, but its parents (and path) will change. I'm pretty confident I could give info on this stuff for a shouldMoveNode API:
draggedNode // The node being moved
prevPath // the previous (current) location in the tree of the node
prevParentNode // the previous (current) parent node
nextPath // The potential next location in the tree of the node
nextParentNode // The potential next parent of the node
The behaviour of this API is the same as prevent the node being moved into deeper in the tree provide by the maxDepth options. I have found that involved with canDrop inside drag-and-drop-utils.js.
The shouldMoveNode being invoked during the node move should provide helpful information and we could have more flexible option moving nodes around.
Thank you for excellent tree component that hard to be found on the internet.
I like the idea with prevPath聽/ nextPath. May be useful.
This would be critical for my (probably unusual) application, I actually need to make an ajax call to the server to ensure the move doesn't violate a myriad of business rules before it's allowed to proceed.
One basic example of a rule is to make sure no "siblings" will have duplicate titles after the move proceeds. Others would be based on the business data associated with each node, spanning multiple tables in the DB, which explains the need for an ajax call.
So for us this would need to be called right after dropping as the check depends both on what node is being moved and where it's being moved to. Wouldn't want it to be disabled afterwards either as the user often will update their data to allow it to work the next time.
I just released the canDrop API with version 0.1.13. I think this should help you do what you're trying to do.
Most helpful comment
prevNode?Making some assumptions here, but:
The node itself should remain unchanged, but its parents (and path) will change. I'm pretty confident I could give info on this stuff for a
shouldMoveNodeAPI: