diff app/relation-type.ts @ 39:7578b21cdf2e

make relation types configurable. relations can have custom labels for incoming or outgoing direction.
author casties
date Sun, 14 Feb 2016 19:40:07 +0100
parents
children 896ae7eefb33
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/relation-type.ts	Sun Feb 14 19:40:07 2016 +0100
@@ -0,0 +1,38 @@
+
+export var invLabelPrefix = '<- ';
+export var invNamePrefix = '-';
+export var rawLabelPrefix = '(';
+export var rawLabelPostfix = ')';
+
+export class RelationType {
+    public name: string;
+    public label: string;
+    public outgoing: boolean;
+    
+    constructor (name: string, isOutgoing: boolean, label?:string) {
+        this.name = name;
+        this.outgoing = isOutgoing;
+        if (label != null) {
+            this.label = label;
+        } else {
+            // create label using name
+            if (isOutgoing) {
+                this.label = rawLabelPrefix + name + rawLabelPostfix;
+            } else {
+                this.label = rawLabelPrefix + invLabelPrefix + name + rawLabelPostfix;
+            }
+        }
+    }
+    
+    getLabel() {
+        return this.label;
+    }
+
+    getName() {
+        return this.name;
+    }
+    
+    isOutgoing() {
+        return this.outgoing;
+    }
+}