| 433 | } |
| 434 | |
| 435 | createOrUpdateNode(id, data, parent, domNode) { |
| 436 | let oldNodePath = id; |
| 437 | if (parent?.path != '/browser') { |
| 438 | oldNodePath = parent.path + '/' + id; |
| 439 | } |
| 440 | const oldNode = this.findNode(oldNodePath); |
| 441 | if (oldNode !== null) { |
| 442 | oldNode.data = data; |
| 443 | oldNode.domNode = domNode; |
| 444 | return oldNode; |
| 445 | } |
| 446 | |
| 447 | const node = new TreeNode(id, data, domNode, parent); |
| 448 | if (parent === this.rootNode) { |
| 449 | node.parentNode = null; |
| 450 | } |
| 451 | |
| 452 | if (parent !== null && parent !== undefined) |
| 453 | parent.children.push(node); |
| 454 | return node; |
| 455 | } |
| 456 | |
| 457 | async updateAndReselectNode(item, data) { |
| 458 | await this.update(item, data); |