@@ -90,25 +90,23 @@ export class MaturityMainComponent implements OnInit {
9090 }
9191 }
9292 }
93-
94- // Check if a specific spec is requested via query parameter (e.g., ?spec=readiness-1)
95- if ( params [ 'spec' ] ) {
96- const specName = params [ 'spec' ] ;
97- try {
98- // Load spec from assets/maturity/{specName}.json
99- this . baseMaturityQuestions = await lastValueFrom (
100- this . http . get ( `assets/maturity/${ specName } .json` )
101- ) ;
102- this . initializeForm ( ) ;
103- return ;
104- } catch ( error ) {
105- console . error ( `Error loading spec "${ specName } " from assets:` , error ) ;
106- // Fall through to load default spec if specified spec fails
107- }
108- }
109-
110- // Load default spec if not in preview mode, no spec specified, or spec loading failed
111- this . baseMaturityQuestions = await lastValueFrom ( this . http . get ( 'assets/maturity/maturityLevels.json' ) ) ;
93+
94+ // Load default spec and always append readiness stakeholders at the end.
95+ const [ defaultSpec , readinessSpec ] = await Promise . all ( [
96+ lastValueFrom ( this . http . get < any > ( 'assets/maturity/maturityLevels.json' ) ) ,
97+ lastValueFrom ( this . http . get < any > ( 'assets/maturity/readiness-1.json' ) )
98+ ] ) ;
99+
100+ const defaultStakeholders = Array . isArray ( defaultSpec ?. stakeHolders ) ? defaultSpec . stakeHolders : [ ] ;
101+ const readinessStakeholders = Array . isArray ( readinessSpec ?. stakeHolders ) ? readinessSpec . stakeHolders : [ ] ;
102+ const existingIds = new Set ( defaultStakeholders . map ( ( stakeholder : any ) => stakeholder . id ) ) ;
103+ const stakeholdersToAppend = readinessStakeholders . filter ( ( stakeholder : any ) => ! existingIds . has ( stakeholder . id ) ) ;
104+
105+ this . baseMaturityQuestions = {
106+ ...defaultSpec ,
107+ stakeHolders : [ ...defaultStakeholders , ...stakeholdersToAppend ]
108+ } ;
109+
112110 this . initializeForm ( ) ;
113111 // Flatten all questions into one array for one-at-a-time display
114112 // this.flattenQuestions();
0 commit comments