CirclonGroup / angular-tree-component

A simple yet powerful tree component for Angular (>=2)
https://angular2-tree.readme.io/docs
MIT License
1.1k stars 492 forks source link

Disable drag feature for individual node? #863

Open kingbe01 opened 4 years ago

kingbe01 commented 4 years ago

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Feature request
[X ] Documentation issue or request

What is the current behavior?

I am not sure if this is possible but been looking for a way to disable drag or drop on certain nodes. Like if a user does not have write permissions on certain nodes. If this is possible is there any documentation on how to use it?

Expected behavior:

Minimal reproduction of the problem with instructions:

Version of affected browser(s),operating system(s), npm, node and angular-tree-component:

Other information:

tobiasengelhardt commented 4 years ago

Hi @kingbe01, it's possible to just enable/disable dragging for specific nodes. If you take a look into the docs for the dragging there is the option to set functions for allowDrag and allowDrop. In those functions you get the node and can test some node properties and enable/disable it based on that.

In our application we get a bool from the api if a node is draggable. If you want to base this on permissions you probably need to add a type property to the nodes and in the function check if the user has permission for that type.