Skip to content
Snippets Groups Projects
Commit 9728a7c9 authored by Matthias Konitzny's avatar Matthias Konitzny :fire:
Browse files

Changed default object group behavior.

parent 73570cd3
No related branches found
No related tags found
No related merge requests found
Pipeline #57006 passed
...@@ -40,7 +40,6 @@ export class Graph ...@@ -40,7 +40,6 @@ export class Graph
public nodes: Node[]; public nodes: Node[];
public links: Link[]; public links: Link[];
public objectGroups: NodeType[]; public objectGroups: NodeType[];
private defaultGroup: NodeType;
public initialized: boolean; public initialized: boolean;
public idToObjectGroup: Map<number, NodeType>; public idToObjectGroup: Map<number, NodeType>;
...@@ -140,18 +139,17 @@ export class Graph ...@@ -140,18 +139,17 @@ export class Graph
return this; return this;
} }
/**
* Makes sure a default object group exists, if there is no object group.
* @private
*/
private createDefaultObjectGroupIfNeeded() { private createDefaultObjectGroupIfNeeded() {
const defaultGroup = this.objectGroups.find( if (this.objectGroups.length == 0) {
(group) => group.name == "Default" this.createObjectGroup({
);
if (defaultGroup == undefined) {
this.defaultGroup = this.createObjectGroup({
id: ++this.nextObjectGroupId, id: ++this.nextObjectGroupId,
name: "Default", name: "Default",
color: "#000000", color: "#000000",
}); });
} else {
this.defaultGroup = defaultGroup;
} }
} }
...@@ -204,7 +202,7 @@ export class Graph ...@@ -204,7 +202,7 @@ export class Graph
const node = new Node(); const node = new Node();
node.fromSerializedObject(data); node.fromSerializedObject(data);
const group = this.idToObjectGroup.get(data.type); const group = this.idToObjectGroup.get(data.type);
node.type = group != undefined ? group : this.defaultGroup; node.type = group != undefined ? group : this.objectGroups[0];
node.neighbors = []; node.neighbors = [];
node.links = []; node.links = [];
this.addNode(node); this.addNode(node);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment