Mercurial > hg > ng2-query-ismi
comparison 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 |
comparison
equal
deleted
inserted
replaced
38:313a5360c2d3 | 39:7578b21cdf2e |
---|---|
1 | |
2 export var invLabelPrefix = '<- '; | |
3 export var invNamePrefix = '-'; | |
4 export var rawLabelPrefix = '('; | |
5 export var rawLabelPostfix = ')'; | |
6 | |
7 export class RelationType { | |
8 public name: string; | |
9 public label: string; | |
10 public outgoing: boolean; | |
11 | |
12 constructor (name: string, isOutgoing: boolean, label?:string) { | |
13 this.name = name; | |
14 this.outgoing = isOutgoing; | |
15 if (label != null) { | |
16 this.label = label; | |
17 } else { | |
18 // create label using name | |
19 if (isOutgoing) { | |
20 this.label = rawLabelPrefix + name + rawLabelPostfix; | |
21 } else { | |
22 this.label = rawLabelPrefix + invLabelPrefix + name + rawLabelPostfix; | |
23 } | |
24 } | |
25 } | |
26 | |
27 getLabel() { | |
28 return this.label; | |
29 } | |
30 | |
31 getName() { | |
32 return this.name; | |
33 } | |
34 | |
35 isOutgoing() { | |
36 return this.outgoing; | |
37 } | |
38 } |