ng2-tree icon indicating copy to clipboard operation
ng2-tree copied to clipboard

Empty folder node move

Open RobertHajbok opened this issue 6 years ago • 4 comments

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?

RobertHajbok avatar Aug 05 '17 14:08 RobertHajbok

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);
    }
  }
}
}

attilabicsko avatar Aug 13 '17 20:08 attilabicsko

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!

RobertHajbok avatar Aug 14 '17 19:08 RobertHajbok

@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)

rychkog avatar Aug 28 '17 05:08 rychkog

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?

manselman avatar Dec 08 '20 11:12 manselman