[M] Rename assignments to rawAssignments

This commit is contained in:
Hykilpikonna
2019-11-06 19:12:24 -05:00
parent e7563fcfb5
commit 79bb10b14e
2 changed files with 8 additions and 7 deletions
+1 -1
View File
@@ -155,7 +155,7 @@ export default class App extends Vue
}); });
// Wait for assignments to be ready. // Wait for assignments to be ready.
pWaitFor(() => this.courses.every(c => c.assignments != null)).then(() => pWaitFor(() => this.courses.every(c => c.rawAssignments != null)).then(() =>
{ {
// Filter courses // Filter courses
this.filteredCourses = this.courses.filter(c => c.isGraded); this.filteredCourses = this.courses.filter(c => c.isGraded);
+7 -6
View File
@@ -1,8 +1,9 @@
import {Assignment} from '@/components/app/app'; import App, {Assignment} from '@/components/app/app';
import JsonUtils from '@/utils/json-utils'; import JsonUtils from '@/utils/json-utils';
import Constants from '@/constants'; import Constants from '@/constants';
import {FormatUtils} from '@/utils/format-utils'; import {FormatUtils} from '@/utils/format-utils';
import {CourseUtils} from '@/utils/course-utils'; import {CourseUtils} from '@/utils/course-utils';
import Navigation from '@/components/navigation/navigation';
export default class Course export default class Course
{ {
@@ -11,7 +12,7 @@ export default class Course
name: string; name: string;
teacherName: string; teacherName: string;
status: string; status: string;
assignments: Assignment[]; rawAssignments: Assignment[];
letterGrade?: string; letterGrade?: string;
numericGrade?: number; numericGrade?: number;
@@ -68,19 +69,19 @@ export default class Course
{ {
// Load assignments // Load assignments
// Parse json and filter it // Parse json and filter it
this.assignments = JsonUtils.filterAssignments(data); this.rawAssignments = JsonUtils.filterAssignments(data);
// Sort by date (Latest is at 0) // Sort by date (Latest is at 0)
this.assignments.sort((a, b) => b.date.getTime() - a.date.getTime()); this.rawAssignments.sort((a, b) => b.date.getTime() - a.date.getTime());
// Filter assignments into terms // Filter assignments into terms
let termAssignments: Assignment[][] = [[], [], [], []]; let termAssignments: Assignment[][] = [[], [], [], []];
let currentTerm = 0; let currentTerm = 0;
// Loop through it by time order // Loop through it by time order
for (let i = this.assignments.length - 1; i >= 0; i--) for (let i = this.rawAssignments.length - 1; i >= 0; i--)
{ {
let a = this.assignments[i]; let a = this.rawAssignments[i];
// On to the next term // On to the next term
if (currentTerm < 3 && a.date > Constants.TERMS[currentTerm + 1]) if (currentTerm < 3 && a.date > Constants.TERMS[currentTerm + 1])