Skip to content
Snippets Groups Projects
Commit 9d0181a8 authored by Scott Berg's avatar Scott Berg
Browse files

Update data structure for academic years to include terms without courses

parent 33fad499
No related branches found
No related tags found
No related merge requests found
Pipeline #28378 failed
...@@ -32,7 +32,12 @@ ...@@ -32,7 +32,12 @@
</mat-panel-title> </mat-panel-title>
</mat-expansion-panel-header> </mat-expansion-panel-header>
<div fxLayout="row" fxLayout.lt-md="column" fxLayoutGap="20px" fxLayoutAlign="start stretch"> <div fxLayout="row" fxLayout.lt-md="column" fxLayoutGap="20px" fxLayoutAlign="start stretch">
<app-term-container *ngFor="let term of termsByAcademicYear[year.key].terms" [term]="term" [courses]="getCoursesByTerm(term.termCode)" fxFlex="33%"></app-term-container> <app-term-container
*ngFor="let term of termsByAcademicYear[year.key].terms | keyvalue"
[term]="termsByAcademicYear[year.key].terms[term.key]"
[courses]="getCoursesByTerm(year.key + term.key)"
fxFlex="33%"
></app-term-container>
</div> </div>
</mat-expansion-panel> </mat-expansion-panel>
</mat-accordion> </mat-accordion>
......
...@@ -33,18 +33,31 @@ export class DegreePlannerComponent { ...@@ -33,18 +33,31 @@ export class DegreePlannerComponent {
this.dataService.getTerms() this.dataService.getTerms()
.subscribe(terms => { .subscribe(terms => {
this.terms = terms; this.terms = terms;
// Create an empty object to store term data in
this.termsByAcademicYear = {}; this.termsByAcademicYear = {};
// Loop through each term
this.terms.forEach(term => { this.terms.forEach(term => {
// Get the 3 digit year code and 1 digit term code
const year = term.termCode.substring(0, 3); const year = term.termCode.substring(0, 3);
const termCode = term.termCode.substring(3);
if (this.termsByAcademicYear[year]) { // If this year does not exsist in the "termsByAcademicYear" create a new year
this.termsByAcademicYear[year].terms.push(term); // This year has placeholder data for each term in the year
} else { if (!this.termsByAcademicYear[year]) {
this.termsByAcademicYear[year] = { this.termsByAcademicYear[year] = {
year: year, year: year,
terms: [term] terms: {
2: { termCode: `${year}2`},
4: { termCode: `${year}4`},
6: { termCode: `${year}6`}
}
}; };
} }
// Overwrite the default term with the current term
this.termsByAcademicYear[year].terms[termCode] = term;
}); });
}); });
} }
......
<div class="course-item"> <div class="course-item {{status}}" [ngClass]="{'disabled': course.pastTerm}">
<div class="course-row course-info"> <div class="course-row course-info">
<div class="icon-number-wrapper"> <div class="icon-number-wrapper">
<p class="course-number"> <p class="course-number">
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
<i *ngSwitchCase="'waitlist'" class="material-icons problem-icon">report_problem</i> <i *ngSwitchCase="'waitlist'" class="material-icons problem-icon">report_problem</i>
<i *ngSwitchCase="'incomplete'" class="material-icons error-icon">error</i> <i *ngSwitchCase="'incomplete'" class="material-icons error-icon">error</i>
<i *ngSwitchCase="'likely-offered'" class="material-icons help-icon">help</i> <i *ngSwitchCase="'likely-offered'" class="material-icons help-icon">help</i>
<i *ngSwitchCase="'not-offered'" class="material-icons not-offered">remove</i>
<i *ngSwitchCase="'favorite'" class="material-icons favorite-icon">favorite_border</i> <i *ngSwitchCase="'favorite'" class="material-icons favorite-icon">favorite_border</i>
</div> </div>
</div> </div>
......
...@@ -70,4 +70,13 @@ ...@@ -70,4 +70,13 @@
.icon-number-wrapper { .icon-number-wrapper {
display: flex; display: flex;
align-items: center; align-items: center;
}
.not-offered {
.course-number,
.course-credits,
.course-title {
text-decoration: line-through;
opacity: .5;
}
} }
\ No newline at end of file
<mat-card class="term-container"> <mat-card class="term-container">
<div fxLayout="row" fxLayoutAlign="space-between stretch"> <div fxLayout="row" fxLayoutAlign="space-between stretch">
<h2>{{ term.termCode | getTermDescription }}</h2><p class="text-right semi-bold credits">Credits: 13</p> <h2>{{ term.termCode | getTermDescription }}</h2><p class="text-right semi-bold credits">{{getTotalCredits()}} Credits</p>
</div> </div>
<div cdkDropList> <div cdkDropList>
<app-course-item *ngFor="let course of courses" [course]="course" [status]="'complete'" cdkDrag></app-course-item> <app-course-item *ngFor="let course of courses" [course]="course" [status]="'complete'" cdkDrag></app-course-item>
......
...@@ -15,4 +15,15 @@ export class TermContainerComponent { ...@@ -15,4 +15,15 @@ export class TermContainerComponent {
terms: any[]; terms: any[];
constructor() {} constructor() {}
getTotalCredits() {
if (!this.courses) {
return '0';
}
let total = 0;
for (const course of this.courses) {
total += course.credits;
}
return total;
}
} }
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