diff --git a/src/app/dars/new-audit-options/new-audit-options.component.html b/src/app/dars/new-audit-options/new-audit-options.component.html index 8b39b8212d594571d6cb740c4f2bd44b9370bff2..4b9dcd70e55cacbf46ed01d68b1514941e5f2022 100644 --- a/src/app/dars/new-audit-options/new-audit-options.component.html +++ b/src/app/dars/new-audit-options/new-audit-options.component.html @@ -64,7 +64,7 @@ <div class="step-buttons-group"> <button mat-button matStepperPrevious color="primary">Back</button> - <button mat-button matStepperNext mat-stroked-button color="primary" (click)="getPlansList()">Next</button> + <button mat-button matStepperNext mat-stroked-button color="primary">Next</button> </div> </mat-step> @@ -79,10 +79,7 @@ <mat-form-field class="audit-settings-option"> <mat-label>Include Courses From</mat-label> <mat-select formControlName="includeCoursesFrom" placeholder="Include Courses From" aria-label="Include Courses From" [disableOptionCentering]="true"> - <mat-option value="future">Previous, current, future, and planned terms</mat-option> - <mat-option value="future">Previous, current, future</mat-option> - <mat-option value="current">Previous, current</mat-option> - <mat-option value="previous">Previous</mat-option> + <mat-option *ngFor="let term of termsToInclude" [value]='term' id="{{ term.id }}">{{ term.name }}</mat-option> </mat-select> </mat-form-field> @@ -90,7 +87,7 @@ <mat-form-field class="audit-settings-option"> <mat-label>Degree Plan</mat-label> <mat-select formControlName="runAgainst" placeholder="Degree Plan" aria-label="Degree Plan" [disableOptionCentering]="true"> - <mat-option *ngFor="let degreePlan of (degreePlans$ | async)" value="{{ degreePlan.roadmapId }}">{{ degreePlan.name }}</mat-option> + <mat-option *ngFor="let degreePlan of degreePlans" value="{{ degreePlan.roadmapId }}">{{ degreePlan.name }}</mat-option> </mat-select> </mat-form-field> <div class="step-buttons-group"> diff --git a/src/app/dars/new-audit-options/new-audit-options.component.ts b/src/app/dars/new-audit-options/new-audit-options.component.ts index 72f74fd0ff4a450d32dcfc64e8afb14d0441b02d..cce821492d680d8e9ecce85d1122d35b2a007eea 100644 --- a/src/app/dars/new-audit-options/new-audit-options.component.ts +++ b/src/app/dars/new-audit-options/new-audit-options.component.ts @@ -34,10 +34,14 @@ export class NewAuditOptionsComponent implements OnInit { public courses: any; public variableCreditCourses: any; public degreePlans$: Observable<DARSState['degreePlans']>; + public degreePlans: any[]; + public primaryPlan: any[]; + public primaryPlanId: string; public hasVariableCredits: boolean; public creditsRange: any[]; public isLoaded: boolean; public selectedAuditType: string; + public termsToInclude: any[]; get formArray(): AbstractControl | null { return this.newAuditForm.get('formArray'); } @@ -54,9 +58,32 @@ export class NewAuditOptionsComponent implements OnInit { }, ) { this.selectedAuditType = data.selectedAuditType; + this.termsToInclude = [ + { + name: 'Previous, current, future, and planned terms', + id: 'future-whatif', + value: 'future', + }, + { + name: 'Previous, current, future', + id: 'future-degree', + value: 'future', + }, + { name: 'Previous, current', id: 'current', value: 'current' }, + { name: 'Previous', id: 'previous', value: 'previous' }, + ]; } ngOnInit() { + // Get Degree plans + this.degreePlans$ = this.store.pipe(select(selectors.degreePlans)); + this.degreePlans$.subscribe(plans => { + this.degreePlans = plans; + this.primaryPlan = plans.filter(function(plan) { + return plan.primary === true; + }); + this.primaryPlanId = this.primaryPlan[0].roadmapId.toString(); + }); // Get student degree programs this.api.getStudentDegreePrograms().subscribe(studentDegreeProgram => { this.studentDegreeProgram = studentDegreeProgram; @@ -81,7 +108,6 @@ export class NewAuditOptionsComponent implements OnInit { } } }); - this.newAuditForm = this.fb.group({ formArray: this.fb.array([ this.fb.group({ @@ -94,8 +120,12 @@ export class NewAuditOptionsComponent implements OnInit { }), this.fb.group({ honors: new FormControl('Keep current status'), - includeCoursesFrom: new FormControl('future'), - runAgainst: new FormControl(''), + includeCoursesFrom: new FormControl( + this.selectedAuditType === 'degree' + ? this.termsToInclude[1] + : this.termsToInclude[0], + ), + runAgainst: new FormControl(this.primaryPlanId), }), this.fb.group({ credits: new FormControl(''), @@ -104,10 +134,6 @@ export class NewAuditOptionsComponent implements OnInit { }); } - public getPlansList() { - this.degreePlans$ = this.store.pipe(select(selectors.degreePlans)); - } - public getCoursesList(roadmapId) { this.isLoaded = false;