Support for different names

This commit is contained in:
Piotr Pekala
2019-11-14 00:42:22 -08:00
parent b6d74c58cb
commit f225de7467
4 changed files with 18 additions and 9 deletions

View File

@ -407,13 +407,16 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
this.subscriptions.push(onInterfaceLabelContextMenu);
this.mapChangeDetectorRef.detectChanges();
}
onNodeCreation(nodeAddedEvent: NodeAddedEvent) {
if(!nodeAddedEvent) {
return;
}
this.nodeService.createFromTemplate(this.server, this.project, nodeAddedEvent.template, nodeAddedEvent.x, nodeAddedEvent.y, 'local').subscribe(() => {
this.nodeService.createFromTemplate(this.server, this.project, nodeAddedEvent.template, nodeAddedEvent.x, nodeAddedEvent.y, 'local').subscribe((node: Node) => {
if (nodeAddedEvent.name !== nodeAddedEvent.template.name) {
node.name = nodeAddedEvent.name;
this.nodeService.updateNode(this.server, node).subscribe(()=>{});
}
this.projectService.nodes(this.server, this.project.project_id).subscribe((nodes: Node[]) => {
nodes.filter((node) => node.label.style === null).forEach((node) => {
@ -422,6 +425,12 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
});
this.nodesDataSource.set(nodes);
nodeAddedEvent.numberOfNodes--;
if (nodeAddedEvent.numberOfNodes > 0) {
nodeAddedEvent.x = nodeAddedEvent.x + 50 < this.project.scene_width/2 ? nodeAddedEvent.x + 50 : nodeAddedEvent.x;
nodeAddedEvent.y = nodeAddedEvent.y + 50 < this.project.scene_height/2 ? nodeAddedEvent.y + 50 : nodeAddedEvent.y;
this.onNodeCreation(nodeAddedEvent);
}
});
});
}