Skip to content

Commit a85c4d3

Browse files
committed
Add guard around undefined elements
1 parent b2b6132 commit a85c4d3

2 files changed

Lines changed: 68 additions & 60 deletions

File tree

src/app/component/mapping/mapping.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@
271271
</ng-container>
272272
</td>
273273
<td *ngFor="let key of allTeams">
274-
<ng-container>
274+
<ng-container *ngIf="item.teamImplementation">
275275
{{ item.teamImplementation[key] }}
276276
</ng-container>
277277
</td>

src/app/component/mapping/mapping.component.ts

Lines changed: 67 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -247,26 +247,29 @@ export class MappingComponent implements OnInit {
247247
ISO22: ISO22Array,
248248
samm2: '',
249249
};
250-
if (SAMMArray.length == 0) {
251-
this.allMappingDataSortedBySAMM.push(this.temporaryMappingElement);
252-
if (this.YamlObject[dim][subDim][activity]['isImplemented']) {
253-
this.performedMappingDataSortedBySAMM.push(
254-
this.temporaryMappingElement
255-
);
256-
} else {
257-
this.plannedMappingDataSortedBySAMM.push(this.temporaryMappingElement);
250+
251+
if (SAMMArray) {
252+
if (SAMMArray.length == 0) {
253+
this.allMappingDataSortedBySAMM.push(this.temporaryMappingElement);
254+
if (this.YamlObject[dim][subDim][activity]['isImplemented']) {
255+
this.performedMappingDataSortedBySAMM.push(
256+
this.temporaryMappingElement
257+
);
258+
} else {
259+
this.plannedMappingDataSortedBySAMM.push(this.temporaryMappingElement);
260+
}
258261
}
259-
}
260-
for (var i = 0; i < SAMMArray.length; i++) {
261-
const newTempElement = JSON.parse(
262-
JSON.stringify(this.temporaryMappingElement)
263-
);
264-
newTempElement['samm2'] = SAMMArray[i];
265-
this.allMappingDataSortedBySAMM.push(newTempElement);
266-
if (this.YamlObject[dim][subDim][activity]['isImplemented']) {
267-
this.performedMappingDataSortedBySAMM.push(newTempElement);
268-
} else {
269-
this.plannedMappingDataSortedBySAMM.push(newTempElement);
262+
for (var i = 0; i < SAMMArray.length; i++) {
263+
const newTempElement = JSON.parse(
264+
JSON.stringify(this.temporaryMappingElement)
265+
);
266+
newTempElement['samm2'] = SAMMArray[i];
267+
this.allMappingDataSortedBySAMM.push(newTempElement);
268+
if (this.YamlObject[dim][subDim][activity]['isImplemented']) {
269+
this.performedMappingDataSortedBySAMM.push(newTempElement);
270+
} else {
271+
this.plannedMappingDataSortedBySAMM.push(newTempElement);
272+
}
270273
}
271274
}
272275
//sorting by descending order
@@ -372,27 +375,29 @@ export class MappingComponent implements OnInit {
372375
};
373376

374377
console.log(this.temporaryMappingElement);
375-
if (ISOArray.length == 0) {
376-
this.allMappingDataSortedByISO17.push(this.temporaryMappingElement);
377-
if (this.YamlObject[dim][subDim][activity]['isImplemented']) {
378-
this.performedMappingDataSortedByISO17.push(
379-
this.temporaryMappingElement
380-
);
381-
} else {
382-
this.plannedMappingDataSortedByISO17.push(this.temporaryMappingElement);
378+
if (ISOArray) {
379+
if (ISOArray.length == 0) {
380+
this.allMappingDataSortedByISO17.push(this.temporaryMappingElement);
381+
if (this.YamlObject[dim][subDim][activity]['isImplemented']) {
382+
this.performedMappingDataSortedByISO17.push(
383+
this.temporaryMappingElement
384+
);
385+
} else {
386+
this.plannedMappingDataSortedByISO17.push(this.temporaryMappingElement);
387+
}
383388
}
384-
}
385-
for (var i = 0; i < ISOArray.length; i++) {
386-
const newTempElement = JSON.parse(
387-
JSON.stringify(this.temporaryMappingElement)
388-
);
389-
newTempElement['ISO17'] = ISOArray[i];
390-
//console.log(newTempElement);
391-
this.allMappingDataSortedByISO17.push(newTempElement);
392-
if (this.YamlObject[dim][subDim][activity]['isImplemented']) {
393-
this.performedMappingDataSortedByISO17.push(newTempElement);
394-
} else {
395-
this.plannedMappingDataSortedByISO17.push(newTempElement);
389+
for (var i = 0; i < ISOArray.length; i++) {
390+
const newTempElement = JSON.parse(
391+
JSON.stringify(this.temporaryMappingElement)
392+
);
393+
newTempElement['ISO17'] = ISOArray[i];
394+
//console.log(newTempElement);
395+
this.allMappingDataSortedByISO17.push(newTempElement);
396+
if (this.YamlObject[dim][subDim][activity]['isImplemented']) {
397+
this.performedMappingDataSortedByISO17.push(newTempElement);
398+
} else {
399+
this.plannedMappingDataSortedByISO17.push(newTempElement);
400+
}
396401
}
397402
}
398403
//sorting by descending order
@@ -429,27 +434,30 @@ export class MappingComponent implements OnInit {
429434
ISO22: '',
430435
samm2: SAMMArray,
431436
};
432-
if (ISO22Array.length == 0) {
433-
this.allMappingDataSortedByISO22.push(this.temporaryMappingElement);
434-
if (this.YamlObject[dim][subDim][activity]['isImplemented']) {
435-
this.performedMappingDataSortedByISO22.push(
436-
this.temporaryMappingElement
437-
);
438-
} else {
439-
this.plannedMappingDataSortedByISO22.push(this.temporaryMappingElement);
437+
438+
if (ISO22Array) {
439+
if (ISO22Array.length == 0) {
440+
this.allMappingDataSortedByISO22.push(this.temporaryMappingElement);
441+
if (this.YamlObject[dim][subDim][activity]['isImplemented']) {
442+
this.performedMappingDataSortedByISO22.push(
443+
this.temporaryMappingElement
444+
);
445+
} else {
446+
this.plannedMappingDataSortedByISO22.push(this.temporaryMappingElement);
447+
}
440448
}
441-
}
442-
for (var i = 0; i < ISO22Array.length; i++) {
443-
const newTempElement = JSON.parse(
444-
JSON.stringify(this.temporaryMappingElement)
445-
);
446-
newTempElement['ISO22'] = ISO22Array[i];
447-
//console.log(newTempElement);
448-
this.allMappingDataSortedByISO22.push(newTempElement);
449-
if (this.YamlObject[dim][subDim][activity]['isImplemented']) {
450-
this.performedMappingDataSortedByISO22.push(newTempElement);
451-
} else {
452-
this.plannedMappingDataSortedByISO22.push(newTempElement);
449+
for (var i = 0; i < ISO22Array.length; i++) {
450+
const newTempElement = JSON.parse(
451+
JSON.stringify(this.temporaryMappingElement)
452+
);
453+
newTempElement['ISO22'] = ISO22Array[i];
454+
//console.log(newTempElement);
455+
this.allMappingDataSortedByISO22.push(newTempElement);
456+
if (this.YamlObject[dim][subDim][activity]['isImplemented']) {
457+
this.performedMappingDataSortedByISO22.push(newTempElement);
458+
} else {
459+
this.plannedMappingDataSortedByISO22.push(newTempElement);
460+
}
453461
}
454462
}
455463
//sorting by descending order

0 commit comments

Comments
 (0)