Skip to content
Snippets Groups Projects
Commit d9faa0ae authored by Isaac Evavold's avatar Isaac Evavold
Browse files

add types to stepper

parent 07698876
No related branches found
No related tags found
No related merge requests found
import { HonorsOption } from './honors-option';
export interface DegreeProgram {
darsDegreeProgramCode: string;
darsInstitutionCode: string;
darsInstitutionCodeDescription: string;
darsDegreeProgramDescription: string;
}
export interface DegreePrograms {
[darsInstitutionCode: string]: {
darsInstitutionCode: string;
darsInstitutionCodeDescription: string;
programs: DegreeProgram[];
honorsOptions: HonorsOption[];
};
}
import { Component, OnInit, Inject } from '@angular/core';
import { MatDialogRef, MatSnackBar } from '@angular/material';
import { DarsApiService } from '../services/api.service';
import { DegreeProgram } from '../models/degree-program';
import { DegreeProgram, DegreePrograms } from '../models/degree-program';
import { StudentDegreeProgram } from '../models/student-degree-program';
import { Observable } from 'rxjs';
import { Store, select } from '@ngrx/store';
......@@ -13,10 +13,11 @@ import {
FormBuilder,
FormGroup,
FormControl,
Validators,
FormArray,
AbstractControl,
} from '@angular/forms';
import { HonorsOption } from '../models/honors-option';
import { DegreePlan } from '@app/core/models/degree-plan';
import { CourseBase } from '@app/core/models/course';
@Component({
selector: 'cse-new-audit-options',
......@@ -26,22 +27,21 @@ import {
export class NewAuditOptionsComponent implements OnInit {
public newAuditForm: FormGroup;
public degreeProgram: DegreeProgram;
public degreePrograms: any;
public degreePrograms: DegreePrograms;
public programOfStudy: string;
public studentDegreeProgram: StudentDegreeProgram[];
public DARSprograms: any;
public honorsOptions: any;
public courses: any;
public variableCreditCourses: any;
public DARSprograms: DegreeProgram[] = [];
public honorsOptions: HonorsOption[] = [];
public courses: { termCode: string; courses: CourseBase[] }[];
public degreePlans$: Observable<DARSState['degreePlans']>;
public degreePlans: any[];
public primaryPlan: any[];
public degreePlans: DegreePlan[];
public primaryPlan: DegreePlan[];
public primaryPlanId: string;
public hasVariableCredits: boolean;
public creditsRange: any[];
public creditsRange: (CourseBase & { creditRange: number[] })[];
public isLoaded: boolean;
public selectedAuditType: string;
public termsToInclude: any[];
public termsToInclude: { name: string; id: string; value: string }[];
get formArray(): AbstractControl | null {
return this.newAuditForm.get('formArray');
}
......@@ -91,21 +91,11 @@ export class NewAuditOptionsComponent implements OnInit {
this.api.getStaticData().subscribe(degreePrograms => {
this.degreePrograms = degreePrograms;
this.honorsOptions = [];
this.DARSprograms = [];
for (var school in this.degreePrograms) {
// Get program of study
this.programOfStudy = this.degreePrograms[
school
].darsInstitutionCodeDescription;
// Get honors options
if (this.degreePrograms[school].hasOwnProperty('honorsOptions')) {
this.honorsOptions.push(...this.degreePrograms[school].honorsOptions);
}
// Get DARS programs
if (this.degreePrograms[school].hasOwnProperty('programs')) {
this.DARSprograms.push(...this.degreePrograms[school].programs);
}
for (const institution of Object.values(degreePrograms)) {
this.programOfStudy = institution.darsInstitutionCodeDescription;
this.honorsOptions.push(...institution.honorsOptions);
this.DARSprograms.push(...institution.programs);
}
});
this.newAuditForm = this.fb.group({
......@@ -140,18 +130,22 @@ export class NewAuditOptionsComponent implements OnInit {
this.api.getAllCourses(roadmapId).subscribe(courses => {
this.courses = courses;
this.creditsRange = [];
this.courses ? (this.isLoaded = true) : (this.isLoaded = false);
this.courses.forEach(function(course) {
course.creditMin === course.creditMax
? (this.hasVariableCredits = false)
: (this.hasVariableCredits = true);
this.isLoaded = true;
this.hasVariableCredits = false;
// Build creditsRange array
course.creditsRange = [];
for (let i = course.creditMin; i <= course.creditMax; i++) {
course.creditsRange.push(i);
}
}, this);
courses.forEach(term => {
term.courses.forEach(course => {
const { creditMin: min, creditMax: max } = course;
if (min !== undefined && max !== undefined && min < max) {
this.hasVariableCredits = true;
const creditRange: number[] = [];
for (let i = min; i <= max; i++) {
creditRange.push(i);
}
this.creditsRange.push({ ...course, creditRange });
}
});
});
});
}
......
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable, of } from 'rxjs';
import { DegreeProgram } from '../models/degree-program';
import { DegreePrograms } from '../models/degree-program';
import { AuditMetadata } from '../models/audit-metadata';
import { StudentDegreeProgram } from '../models/student-degree-program';
import { environment } from './../../../environments/environment';
import { Audit } from '../models/audit/audit';
import { CourseBase } from '@app/core/models/course';
const auditResponse: any = require('../../../assets/mock-data/audit-response.json');
const degreeProgramsResponse: any = require('../../../assets/mock-data/degreeprograms-response.json');
const auditResponse: Audit = require('../../../assets/mock-data/audit-response.json');
const degreeProgramsResponse: DegreePrograms = require('../../../assets/mock-data/degreeprograms-response.json');
const HTTP_OPTIONS = {
headers: new HttpHeaders({
......@@ -24,12 +24,12 @@ export class DarsApiService {
* Get all degree programs, honors, and institution data.
*
*/
public getStaticData(): Observable<DegreeProgram[]> {
public getStaticData(): Observable<DegreePrograms> {
// Prevents errors locally
if (environment.production) {
const url =
'http://dev-enroll-app-data.s3-website-us-east-1.amazonaws.com/degreeprograms.json';
return this.http.get<DegreeProgram[]>(url, HTTP_OPTIONS);
return this.http.get<DegreePrograms>(url, HTTP_OPTIONS);
} else {
return of(degreeProgramsResponse);
}
......
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