Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty folder node move #117

Open
RobertHajbok opened this issue Aug 5, 2017 · 4 comments
Open

Empty folder node move #117

RobertHajbok opened this issue Aug 5, 2017 · 4 comments

Comments

@RobertHajbok
Copy link

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?

@attilabicsko
Copy link

attilabicsko commented Aug 13, 2017

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

@RobertHajbok
Copy link
Author

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!

@rychkog
Copy link
Contributor

rychkog commented Aug 28, 2017

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

@manselman
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants