@@ -37,7 +37,7 @@ export interface activityDescription {
3737 assessment : string ;
3838 comments : string ;
3939 isImplemented : boolean ;
40- teamsImplemented : Object ;
40+ teamsImplemented : Record < string , any > ;
4141}
4242
4343@Component ( {
@@ -255,34 +255,41 @@ export class ActivityDescriptionComponent implements OnInit {
255255 data [ 'isImplemented' ] ,
256256 false
257257 ) ;
258- const dataFromLocalStorage = localStorage . getItem ( 'dataset' ) ;
258+ let combinedTeamsImplemented : any = { } ;
259+ const dataFromLocalStorage : string | null =
260+ localStorage . getItem ( 'dataset' ) ;
259261 if ( dataFromLocalStorage !== null ) {
260- var parsedDataFromLocalStorage = JSON . parse ( dataFromLocalStorage ) ;
261- var index = - 1 ;
262- for ( var i = 0 ; i < parsedDataFromLocalStorage . length ; i ++ ) {
263- for (
264- var j = 0 ;
265- j < parsedDataFromLocalStorage [ i ] [ 'Activity' ] . length ;
266- j ++
267- ) {
268- if (
269- parsedDataFromLocalStorage [ i ] [ 'Activity' ] [ j ] [ 'uuid' ] ===
270- data [ 'uuid' ]
271- ) {
272- console . log ( 'test' , parsedDataFromLocalStorage [ i ] [ 'Activity' ] [ j ] ) ;
273-
274- index = i ;
275- this . currentActivity . teamsImplemented =
276- parsedDataFromLocalStorage [ i ] [ 'Activity' ] [ j ] [
277- 'teamsImplemented'
278- ] ;
262+ let localData = JSON . parse ( dataFromLocalStorage ) ;
263+ let localDataActivity = null ;
279264
265+ // Find the activity with the correct uuid
266+ for ( let subdim of localData ) {
267+ for ( let activity of subdim ?. Activity ) {
268+ if ( activity ?. uuid === data ?. uuid ) {
269+ console . log ( 'Found' , activity ) ;
270+ localDataActivity = activity ;
280271 break ;
281272 }
282273 }
274+ if ( localDataActivity ) break ;
283275 }
284- // this.currentActivity.teamsEvidence = this.defineEvidenceObject();
285- } else this . currentActivity . teamsImplemented = data [ 'teamsImplemented' ] ;
276+
277+ // Combine teams status from local storage and loaded yaml file
278+ combinedTeamsImplemented = Object . assign (
279+ { } ,
280+ localDataActivity ?. teamsImplemented ,
281+ this . currentActivity ?. teamsImplemented
282+ ) ;
283+ } else {
284+ combinedTeamsImplemented = data [ 'teamsImplemented' ] ;
285+ }
286+
287+ // Only keep genuine teams
288+ this . currentActivity . teamsImplemented = { } ;
289+ for ( let team of this . TeamList ) {
290+ this . currentActivity . teamsImplemented [ team ] =
291+ combinedTeamsImplemented [ team ] ;
292+ }
286293
287294 this . currentActivity . teamsEvidence = this . defineEvidenceObject (
288295 data [ 'teamsEvidence' ]
0 commit comments