Skip to content
Snippets Groups Projects
Commit 11c9647e authored by jvanboxtel@wisc.edu's avatar jvanboxtel@wisc.edu
Browse files

ROENROLL-1874 working what if audits

parent be1a7b59
No related branches found
No related tags found
No related merge requests found
......@@ -78,7 +78,19 @@ export class DARSViewComponent implements OnInit {
this.dialog
.open<any, any, NewWhatIfAuditFields>(NewWhatIfAuditDialogComponent)
.afterClosed()
.subscribe(event => console.log(event));
// .subscribe(event => console.log(event));
.subscribe(event => {
if (event) {
return this.store.dispatch(
new StartSendingAudit({
darsInstitutionCode: event.darsInstitutionCode,
darsDegreeProgramCode: event.darsDegreeProgramCode,
degreePlannerPlanName: event.degreePlannerPlanName,
whichEnrolledCoursesIncluded: event.whichEnrolledCoursesIncluded,
}),
);
}
});
}
public openAudit(metadata: AuditMetadata) {
......
......@@ -30,7 +30,7 @@
<!-- Program Column -->
<ng-container matColumnDef="program">
<th mat-header-cell *matHeaderCellDef>Program of Study</th>
<td mat-cell *matCellDef="let audit">{{audit.darsDegreeProgramCode}}</td>
<td mat-cell *matCellDef="let audit">{{audit.darsDegreeProgramDescription}}</td>
</ng-container>
<!-- Honors Column -->
......@@ -49,8 +49,13 @@
<ng-container matColumnDef="status">
<th mat-header-cell *matHeaderCellDef>Status</th>
<td mat-cell *matCellDef="let audit">
<div>{{audit.darsStatusOfDegreeAuditRequest}}</div>
<div>Run {{audit.darsAuditRunDate | date:'short'}}</div>
<div *ngIf="audit.darsStatusOfDegreeAuditRequest == 'Done' || audit.darsStatusOfDegreeAuditRequest.indexOf('Failed') > -1; else loading">
<div>{{audit.darsStatusOfDegreeAuditRequest}}</div>
<div>Run {{audit.darsAuditRunDate | date:'short'}}</div>
</div>
<ng-template #loading>
<mat-progress-spinner mode="indeterminate" diameter="24"></mat-progress-spinner>
</ng-template>
</td>
</ng-container>
......
......@@ -35,9 +35,9 @@ const inclusiveRange = (from: number, to: number) => {
export interface NewWhatIfAuditFields {
darsInstitutionCode: string;
darsDegreeProgramCode: string;
roadmapId: number;
degreePlannerPlanName: string;
darsHonorsOptionCode: string;
includeCoursesFrom: string;
whichEnrolledCoursesIncluded: string;
fixedCredits: {
termCode: string;
subjectCode: string;
......@@ -122,35 +122,54 @@ export class NewWhatIfAuditDialogComponent implements OnInit {
);
const degreePlanFormControl = this.chosenAuditSettings.get('degreePlan');
if (degreePlanFormControl) {
degreePlanFormControl.valueChanges.subscribe(plan => {
this.chosenRoadmapId$.next(plan.roadmapId);
// if (degreePlanFormControl) {
// degreePlanFormControl.valueChanges.subscribe(plan => {
// this.chosenRoadmapId$.next(plan.roadmapId);
// });
// }
const includeCoursesFrom = this.chosenAuditSettings.get(
'includeCoursesFrom',
);
if (includeCoursesFrom && degreePlanFormControl) {
includeCoursesFrom.valueChanges.subscribe(selected => {
if (selected !== 'planned') {
degreePlanFormControl.reset();
degreePlanFormControl.disable();
} else {
degreePlanFormControl.enable();
degreePlanFormControl.valueChanges.subscribe(plan => {
this.chosenRoadmapId$.next(plan.roadmapId);
});
}
});
}
this.variableCreditCourses$ = this.chosenRoadmapId$.pipe(
distinctUntilChanged(),
flatMap(roadmapId => this.api.getAllCourses(roadmapId)),
map(courses => {
return courses.filter(course => {
return (
!!course.creditMin &&
!!course.creditMax &&
course.creditMax > course.creditMin
);
});
}),
map(courses =>
courses.map(course => ({
...course,
range: inclusiveRange(
course.creditMin as number,
course.creditMax as number,
),
})),
),
shareReplay(),
);
if (degreePlanFormControl) {
this.variableCreditCourses$ = this.chosenRoadmapId$.pipe(
distinctUntilChanged(),
flatMap(roadmapId => this.api.getAllCourses(roadmapId)),
map(courses => {
return courses.filter(course => {
return (
!!course.creditMin &&
!!course.creditMax &&
course.creditMax > course.creditMin
);
});
}),
map(courses =>
courses.map(course => ({
...course,
range: inclusiveRange(
course.creditMin as number,
course.creditMax as number,
),
})),
),
shareReplay(),
);
}
this.variableCreditCourses$.subscribe(courses => {
while (this.chosenCreditSettings.length !== 0) {
......@@ -200,7 +219,7 @@ export class NewWhatIfAuditDialogComponent implements OnInit {
return fallback;
}
}
// Don't think we need this
public roadmapId<T>(fallback: T): number | T {
const control = this.chosenAuditSettings.get('degreePlan');
if (control !== null) {
......@@ -210,6 +229,15 @@ export class NewWhatIfAuditDialogComponent implements OnInit {
}
}
public degreePlannerPlanName<T>(fallback: T): string | T {
const control = this.chosenAuditSettings.get('degreePlan');
if (control && control.value !== null) {
return control.value.name;
} else {
return fallback;
}
}
public darsHonorsOptionCode<T>(fallback: T): string | T {
const control = this.chosenAuditSettings.get('honorsOptions');
if (control !== null) {
......@@ -219,10 +247,16 @@ export class NewWhatIfAuditDialogComponent implements OnInit {
}
}
// If a degree plan name is included in the request we do not need this property
public includeCoursesFrom<T>(fallback: T): string | T {
const control = this.chosenAuditSettings.get('includeCoursesFrom');
if (control !== null) {
return control.value.toString();
const controlDegreePlan = this.chosenAuditSettings.get('degreePlan');
if (controlDegreePlan && controlDegreePlan.status === 'DISABLED') {
const control = this.chosenAuditSettings.get('includeCoursesFrom');
if (control !== null) {
return control.value.toString();
} else {
return fallback;
}
} else {
return fallback;
}
......@@ -245,9 +279,9 @@ export class NewWhatIfAuditDialogComponent implements OnInit {
this.dialogRef.close({
darsInstitutionCode: this.darsInstitutionCode(''),
darsDegreeProgramCode: this.darsDegreeProgramCode(''),
roadmapId: this.roadmapId(-1),
degreePlannerPlanName: this.degreePlannerPlanName(''),
darsHonorsOptionCode: this.darsHonorsOptionCode(''),
includeCoursesFrom: this.includeCoursesFrom(''),
whichEnrolledCoursesIncluded: this.includeCoursesFrom(''),
fixedCredits: this.fixedCredits(),
});
}
......
......@@ -77,11 +77,18 @@ export class DarsApiService {
public newAudit(
darsInstitutionCode: string,
darsDegreeProgramCode: string,
degreePlannerPlanName?: string,
whichEnrolledCoursesIncluded?: string,
): Observable<AuditMetadata> {
const url = `${environment.apiDarsUrl}/auditrequest`;
return this.http.post<AuditMetadata>(
url,
{ darsInstitutionCode, darsDegreeProgramCode },
{
darsInstitutionCode,
darsDegreeProgramCode,
degreePlannerPlanName,
whichEnrolledCoursesIncluded,
},
HTTP_OPTIONS,
);
}
......
......@@ -82,6 +82,8 @@ export class StartSendingAudit implements Action {
public payload: {
darsInstitutionCode: string;
darsDegreeProgramCode: string;
degreePlannerPlanName?: string;
whichEnrolledCoursesIncluded?: string;
},
) {}
}
......@@ -92,6 +94,8 @@ export class DoneSendingAudit implements Action {
public payload: {
darsInstitutionCode: string;
darsDegreeProgramCode: string;
degreePlannerPlanName?: string;
whichEnrolledCoursesIncluded?: string;
},
) {}
}
......
......@@ -108,7 +108,12 @@ export class DARSEffects {
flatMap((action: darsActions.StartSendingAudit) => {
const metadata = action.payload;
return this.api
.newAudit(metadata.darsInstitutionCode, metadata.darsDegreeProgramCode)
.newAudit(
metadata.darsInstitutionCode,
metadata.darsDegreeProgramCode,
metadata.degreePlannerPlanName,
metadata.whichEnrolledCoursesIncluded,
)
.pipe(
map(audit => {
return new darsActions.DoneSendingAudit(action.payload);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment