ng2-tree
ng2-tree copied to clipboard
Empty folder node move
Hello!
I saw your demo and I noticed you cannot moved a folder or item into an empty folder. Is this the expected behaviour or a known bug? Do you plan to change this?
Hi! Thanks for the lib. I'm also interested if this is the expected behaviour. As a quick workaround, I've added a placeholder item for empty folders like this:
onNodeMoved(ev: NodeMovedEvent) {
if (ev.node.node.id == -1) {
ev.node.removeItselfFromParent()
}
var placeholder = new Tree(<TreeModel>{ id: -1, value: '- EMPTY GROUP -' });
if (ev.previousParent && ev.previousParent.children && ev.previousParent.children.length == 0) {
ev.previousParent.addChild(placeholder, 0);
}
if (ev.node.parent && ev.node.parent.children) {
var placeholders = ev.node.parent.children.filter(function (x) { return (<Tree>x).node.id === -1 });
if (placeholders) {
for (let item of placeholders) {
ev.node.parent.removeChild(item);
}
}
}
}
Hi!
I updated the package to latest version (2.0.0-alpha.8) and it seems there is some support for empty items/folders now. I am able to move an item into an empty folder, but not a folder. Also I noticed that tree models now have an ID property, which I was hoping for when I started using this library. I hope a further release will have this feature too (adding folders to empty folders), thanks and keep up the good work!
@HajbokRobert Thanks! Have a look at the new API (in order to support this API - ID prop was actually added :) ) https://github.com/valor-software/ng2-tree#gun-controller
I will have a look at the issue you've posted (but cause I don't have time - cannot say how much of it this change will take)
Hello,
Is there any progress on this subject? If you answer, I would be very happy. it is very important to me. can you help me?