alibaba / butterfly

🦋Butterfly,A JavaScript/React/Vue2 Diagramming library which concentrate on flow layout field. (基于JavaScript/React/Vue2的流程图组件)
https://butterfly-dag.gitee.io/butterfly-dag/home
MIT License
4.48k stars 603 forks source link

Missing function Group.addGroup / Group.addGroups #961

Open JensWinkler91 opened 1 year ago

JensWinkler91 commented 1 year ago

What problem does this feature solve?

The API allows us to manually add nodes to a group by using group.addNodes(nodes).

However, i can't find any function to add a subgroup to a group although the feature is supported (see includeGroups). I'd expect that there's a function like group.addGroups(groups).

Do i miss something?

noonnightstorm commented 1 year ago

I will support as soon as possible

noonnightstorm commented 1 year ago

I think you should call canvas.addGroup , but not Group.addGroups.

JensWinkler91 commented 1 year ago

But canvas.addGroup would add a new group to the canvas. That's not what i want to do.

I just want to change the parent of a group that already exist. Afterwards the subgroup should me moved when the parent group is moved.

noonnightstorm commented 1 year ago
canvas.addGroup({
  id: 'xxx',
  group: 'xxx' // you can pass group id
})
JensWinkler91 commented 1 year ago

@noonnightstorm

Your code sample would create a new subgroup, right? I'd like to turn an existing group into a subgroup.

Edited: I tried your code snippet. It doesn't work. I think the functions Group.addGroups and Group.removeGroups are really missing.

noonnightstorm commented 1 year ago

Maybe you can canvas.removeGroups and canvas.addGroups.

JensWinkler91 commented 1 year ago

I already tried it but it does not work.

When i use canvas.removeGroups and canvas.addGroups the nodes won't be part of the group anymore. That means that the nodes of the group don't move when i move the group itself.

JensWinkler91 commented 1 year ago

@noonnightstorm

I currently don't get the problem with that issue as the behavior already exists when you drag and drop a group into another group.

Could you please tell me what's the difficulty?

JensWinkler91 commented 1 year ago

@noonnightstorm

I would really appreciate your help in this case. Is there any chance to get a response?