fixed date calculation on home page + added multi Q support in units
This commit is contained in:
@@ -53,7 +53,7 @@ export class HomePage implements OnInit {
|
||||
this.lessons = timetable[scheduleDay].filter(lesson => lesson != undefined);
|
||||
}
|
||||
|
||||
if (this.dateIsPast(unitsData.date, new Date())) {
|
||||
if (this.dateIsPast(unitsData.date, this.today)) {
|
||||
unitsData = await this.units.getSubstitutionPlan("tomorrow");
|
||||
}
|
||||
this.subs = unitsData.substitutions?.filter(subs => subs.classes.includes(this.classData.class));
|
||||
@@ -65,7 +65,7 @@ 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);
|
||||
return first.setHours(0, 0, 0, 0) < second.setHours(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,8 +3,49 @@
|
||||
<ion-buttons slot="start">
|
||||
<ion-menu-button></ion-menu-button>
|
||||
</ion-buttons>
|
||||
<ion-title>Vertretungsplan {{data?.date.toLocaleDateString()}}</ion-title>
|
||||
<ion-title (click)="fakeModal.present()">Vertretungsplan {{data?.date.toLocaleDateString()}}</ion-title>
|
||||
</ion-toolbar>
|
||||
|
||||
<ion-modal #fakeModal (didDismiss)="addFakeSubstitution($event)">
|
||||
<ng-template>
|
||||
<ion-header>
|
||||
<ion-toolbar>
|
||||
<ion-buttons slot="start">
|
||||
<ion-button (click)="fakeModal.dismiss(null, 'cancel')">Abbrechen</ion-button>
|
||||
</ion-buttons>
|
||||
<ion-title>Fake Vertretung</ion-title>
|
||||
<ion-buttons slot="end">
|
||||
<ion-button (click)="fakeModal.dismiss({type: type.value, course: course.value, lessons: lessons.value, teacher: teacher.value}, 'confirm')">Fertig</ion-button>
|
||||
</ion-buttons>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
<ion-content class="ion-padding course-content">
|
||||
<ion-item>
|
||||
<ion-label position="stacked">Typ</ion-label>
|
||||
<ion-select aria-label="Typ" interface="action-sheet" value="Entfall" #type>
|
||||
<ion-select-option value="Entfall">Entfall</ion-select-option>
|
||||
<ion-select-option value="Stillarbeit">Stillarbeit</ion-select-option>
|
||||
</ion-select>
|
||||
</ion-item>
|
||||
<ion-item>
|
||||
<ion-label position="stacked">Kurs</ion-label>
|
||||
<ion-select aria-label="Kurs" interface="action-sheet" [value]="courses[0]" #course>
|
||||
<ion-select-option *ngFor="let course of courses" [value]="course">
|
||||
{{course}}
|
||||
</ion-select-option>
|
||||
</ion-select>
|
||||
</ion-item>
|
||||
<ion-item>
|
||||
<ion-label position="stacked">Stunden</ion-label>
|
||||
<ion-input aria-label="Stunden" type="text" #lessons/>
|
||||
</ion-item>
|
||||
<ion-item>
|
||||
<ion-label position="stacked">Lehrer</ion-label>
|
||||
<ion-input aria-label="Lehrer" type="text" #teacher/>
|
||||
</ion-item>
|
||||
</ion-content>
|
||||
</ng-template>
|
||||
</ion-modal>
|
||||
</ion-header>
|
||||
|
||||
<ion-content [fullscreen]="true">
|
||||
|
||||
@@ -3,7 +3,7 @@ import {CommonModule} from '@angular/common';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {AlertController, IonicModule} from '@ionic/angular';
|
||||
import {UnitsService} from "../../api/units.service";
|
||||
import {UnitsData} from "../../entities/substitution";
|
||||
import {Substitution, UnitsData} from "../../entities/substitution";
|
||||
import {IServService} from "../../api/iserv.service";
|
||||
import {SubstitutionComponent} from "../../components/substitution/substitution.component";
|
||||
import {StorageService} from "../../api/storage.service";
|
||||
@@ -85,4 +85,23 @@ export class SubstitutionPage implements OnInit {
|
||||
return this.courses.includes(course);
|
||||
}
|
||||
|
||||
public addFakeSubstitution(event: any) {
|
||||
if (event.detail.role != "confirm") return;
|
||||
const data = event.detail.data as {course: string, type: string, lessons: string, teacher: string};
|
||||
const sub: Substitution = {
|
||||
classes: [this.currentClass],
|
||||
lesson: data.course,
|
||||
times: data.lessons.split(" - ").map(Number),
|
||||
type: data.type,
|
||||
teacher: data.teacher,
|
||||
representative: "",
|
||||
newLesson: "",
|
||||
room: "---",
|
||||
description: ""
|
||||
};
|
||||
|
||||
this.data.substitutions.push(sub);
|
||||
this.data.substitutions.sort((a, b) => a.times[0] < b.times[0] ? -1 : 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user