From 5b902171c86bda8bf3ca09d179d5e2dfdf9be55a Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Wed, 6 Nov 2019 17:26:44 -0500 Subject: [PATCH] [+] Filter assignments into terms --- src/components/app/app.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/components/app/app.ts b/src/components/app/app.ts index dda7805..4e8051f 100644 --- a/src/components/app/app.ts +++ b/src/components/app/app.ts @@ -187,6 +187,19 @@ export default class App extends Vue // Sort by date course.assignments.sort((a, b) => a.date.getTime() - b.date.getTime()); + + // Filter assignments into terms + let termAssignments: Assignment[][] = [[], [], [], []]; + let currentTerm = 0; + course.assignments.forEach(a => + { + // On to the next term + if (currentTerm < 3 && a.date > Constants.TERMS[currentTerm + 1]) + currentTerm ++; + + // Push data + termAssignments[currentTerm].push(a); + }); } else throw new Error(response.data); })