Skip to content

Commit 6c43164

Browse files
committed
feat:
BREAKING CHANGE: Use UUID for navigation. Old dimension/subdimesion/activityName will not work anymore
1 parent e3eefee commit 6c43164

File tree

3 files changed

+63
-9
lines changed

3 files changed

+63
-9
lines changed

src/app/component/activity-description/activity-description.component.ts

Lines changed: 60 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,7 @@ export class ActivityDescriptionComponent implements OnInit {
8383

8484
ngOnInit() {
8585
this.route.queryParams.subscribe(params => {
86-
this.currentActivity.dimension = params['dimension'];
87-
this.currentActivity.subDimension = params['subDimension'];
88-
this.currentActivity.level = 'level-' + params['level'];
89-
this.currentActivity.activityName = params['activityName'];
86+
this.currentActivity.uuid = params['uuid'];
9087
});
9188

9289
//gets value from sample file
@@ -103,10 +100,65 @@ export class ActivityDescriptionComponent implements OnInit {
103100
// Function sets data
104101
this.yaml.getJson().subscribe(data => {
105102
this.YamlObject = data;
106-
var data =
107-
this.YamlObject[this.currentActivity.dimension][
108-
this.currentActivity.subDimension
109-
][this.currentActivity.activityName];
103+
104+
var allDimensionNames = Object.keys(this.YamlObject);
105+
for (let i = 0; i < allDimensionNames.length; i++) {
106+
var subdimensionsInCurrentDimension = Object.keys(
107+
this.YamlObject[allDimensionNames[i]]
108+
);
109+
110+
for (let j = 0; j < subdimensionsInCurrentDimension.length; j++) {
111+
var temp: any = {
112+
Dimension: allDimensionNames[i],
113+
SubDimension: subdimensionsInCurrentDimension[j],
114+
};
115+
var activityInCurrentSubDimension: string[] = Object.keys(
116+
this.YamlObject[allDimensionNames[i]][
117+
subdimensionsInCurrentDimension[j]
118+
]
119+
);
120+
121+
for (let a = 0; a < activityInCurrentSubDimension.length; a++) {
122+
var currentActivityName = activityInCurrentSubDimension[a];
123+
124+
try {
125+
console.log(this.currentActivity.uuid, this.currentActivity.uuid);
126+
console.log(
127+
'uuid',
128+
this.YamlObject[allDimensionNames[i]][
129+
subdimensionsInCurrentDimension[j]
130+
][currentActivityName].uuid
131+
);
132+
console.log(
133+
'currentActivityName',
134+
this.YamlObject[allDimensionNames[i]][
135+
subdimensionsInCurrentDimension[j]
136+
][currentActivityName]
137+
);
138+
if (
139+
this.YamlObject[allDimensionNames[i]][
140+
subdimensionsInCurrentDimension[j]
141+
][currentActivityName].uuid == this.currentActivity.uuid
142+
) {
143+
data =
144+
this.YamlObject[allDimensionNames[i]][
145+
subdimensionsInCurrentDimension[j]
146+
][currentActivityName];
147+
this.currentActivity = data;
148+
this.currentActivity.dimension = allDimensionNames[i];
149+
this.currentActivity.subDimension =
150+
subdimensionsInCurrentDimension[j];
151+
this.currentActivity.activityName = currentActivityName;
152+
console.log('found');
153+
break;
154+
}
155+
} catch {
156+
console.log('Level for activity does not exist');
157+
}
158+
}
159+
}
160+
}
161+
110162
this.currentActivity.description = this.defineStringValues(
111163
data['description'],
112164
''

src/app/component/matrix/matrix.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
style="margin-bottom: 1em"
6868
(click)="
6969
navigate(
70+
YamlObject[element.Dimension][element.SubDimension][activity].uuid,
7071
element.Dimension,
7172
element.SubDimension,
7273
i + 1,

src/app/component/matrix/matrix.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,10 @@ export class MatrixComponent implements OnInit {
309309

310310
// activity description routing + providing parameters
311311

312-
navigate(dim: string, subdim: string, lvl: Number, activityName: string) {
312+
navigate(uuid: String, dim: string, subdim: string, lvl: Number, activityName: string) {
313313
let navigationExtras: NavigationExtras = {
314314
queryParams: {
315+
uuid: uuid,
315316
dimension: dim,
316317
subDimension: subdim,
317318
level: lvl,

0 commit comments

Comments
 (0)