Archived
Private
Public Access
1
0

Added substitution date + default courses

This commit is contained in:
2023-05-01 12:54:05 +02:00
parent 0d83e9d75e
commit e55cbfe4c6
11 changed files with 98 additions and 6 deletions

View File

@@ -26,6 +26,7 @@ export class HomePage implements OnInit {
public today: Date;
public dayName: string;
public subs: Substitution[];
public subsDate: Date;
public classData: {class: string, courses: Course[]};
public lessons: Lesson[];
@@ -43,7 +44,13 @@ export class HomePage implements OnInit {
this.unreadMails = (await mailPromise).filter(mail => !mail.read);
this.classData = await classPromise;
this.subs = (await subsPromise).substitutions.filter(subs => subs.classes.includes(this.classData.class));
let unitsData = await subsPromise;
if (this.dateIsPast(unitsData.date, new Date())) {
unitsData = await this.units.getSubstitutionPlan("tomorrow");
}
this.subs = unitsData.substitutions?.filter(subs => subs.classes.includes(this.classData.class));
this.subsDate = unitsData.date;
if (this.classData.class.startsWith("Q")) {
this.subs = this.subs.filter(subs => this.classData.courses.filter(course => course.id == subs.lesson).length > 0);
@@ -54,4 +61,8 @@ export class HomePage implements OnInit {
}
}
private dateIsPast(first: Date, second: Date): boolean {
return first.setHours(0, 0, 0, 0) <= second.setHours(0, 0, 0, 0);
}
}