From cd9acff44bd64305284b714a5d712c0e386b50fd Mon Sep 17 00:00:00 2001 From: Maximilian Giller <m.giller@tu-bs.de> Date: Sun, 19 Jun 2022 18:45:43 +0200 Subject: [PATCH] Adding artificial node type ids for now --- src/editor/js/structures/graph/graph.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/editor/js/structures/graph/graph.ts b/src/editor/js/structures/graph/graph.ts index 0307c21..c7df259 100644 --- a/src/editor/js/structures/graph/graph.ts +++ b/src/editor/js/structures/graph/graph.ts @@ -305,7 +305,12 @@ export class Graph extends ManagedData { // No need to replace node ids with proper node objects, since that should be done in the graph itself. Only have to prepare valid GraphData }); - // Collect all node types + // Collect all node types and give id of none given yet + let typeId: number = undefined; + if (data.nodes[0].type.id === undefined) { + typeId = 0; + } + // TODO: Remove, when types are directly parsed and not just implicit data.nodes.forEach((node) => { const sharedType: NodeType = data.types.find( @@ -318,6 +323,11 @@ export class Graph extends ManagedData { return; } + if (typeId !== undefined) { + node.type.id = typeId; + typeId += 1; + } + // Doesn't exist in list yet, so add data.types.push(node.type); }); -- GitLab