Skip to content

Commit

Permalink
New nodes takes the max ID automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
QubitPi committed Oct 3, 2023
1 parent ae6cd35 commit 9f6a078
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,20 @@ export class GraphEventHandlerModel {
}

onCanvasDblClicked(): void {
this.graph.addNodes([new NodeModel('New Node', [], {}, {})])
const maxId: number = Math.max(
...this.graph._nodes.map(node => parseInt(node.id))
)
const newId = maxId + 1

// TODO: make label, properties EDITABLE in followup PR's
this.graph.addNodes([
new NodeModel(
newId.toString(),
[],
{ name: 'New Node' },
{ name: 'string' }
)
])
this.visualization.update({ updateNodes: true, updateRelationships: true })

// this will persist node to Neo4J DB...
Expand Down

0 comments on commit 9f6a078

Please sign in to comment.