|
@@ -167,11 +167,16 @@ class Tree extends Graph {
|
|
|
};
|
|
|
}
|
|
|
|
|
|
- import(data, nodeType = TreeNode) {
|
|
|
+ import(data, nodeType = TreeNode, parentNode) {
|
|
|
let { levels, rootId, ...rest } = data;
|
|
|
super.import(data, nodeType);
|
|
|
- this.root = super.getNode(rootId);
|
|
|
- this.levels = levels.map(setArray => new Set(setArray));
|
|
|
+ if(!parentNode) {
|
|
|
+ this.root = super.getNode(rootId);
|
|
|
+ this.levels = levels.map(setArray => new Set(setArray));
|
|
|
+ } else {
|
|
|
+ this.linkNodes(parentNode, rootId);
|
|
|
+ this.updateLevels(parentNode);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|