From 0cb55eaf6894d79d7928fa19b530b03a8eb38a88 Mon Sep 17 00:00:00 2001 From: minie4 Date: Sun, 27 Aug 2023 18:00:09 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20support=20for=20other=20subst?= =?UTF-8?q?itution=20types?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Store and display original substitution type text - Treat "eigenverantwortliches Arbeiten" as cancellation --- server/api/index.js | 1 + server/parser/index.js | 27 +++++++++++++++++---------- server/prisma/schema.prisma | 1 + src/components/history-list.vue | 7 +++++-- src/components/lesson-card.vue | 3 +++ src/components/substitution-list.vue | 9 ++++++--- 6 files changed, 33 insertions(+), 15 deletions(-) diff --git a/server/api/index.js b/server/api/index.js index 71f9a28..cfb2e7c 100644 --- a/server/api/index.js +++ b/server/api/index.js @@ -177,6 +177,7 @@ export async function getSubstitutions(req, res) { id: element.id, class: element.class, type: element.type, + rawType: element.rawType, lesson: element.lesson, date: new Date(element.date).getTime(), notes: element.notes, diff --git a/server/parser/index.js b/server/parser/index.js index 8fd1e9d..0f508db 100644 --- a/server/parser/index.js +++ b/server/parser/index.js @@ -96,15 +96,15 @@ export class Parser { // (Date, Type, Lesson, Classes and Subject need to be the same) const matchingSubstitutionId = knownSubstitutions.findIndex( (substitution) => { - return substitution.date == new Date(date).setUTCHours(0, 0, 0, 0) && - substitution.type == (change.type == "Entfall") - ? "cancellation" - : "change" && - substitution.lesson == change.lesson && - classes.sort().join(",") == - substitution.class.sort().join(",") && - substitution.changedSubject == change.subject && - substitution.teacher == (change.teacher || ""); + return ( + substitution.date.getTime() == + new Date(date).setUTCHours(0, 0, 0, 0) && + substitution.rawType == change.type && + substitution.lesson == change.lesson && + classes.sort().join(",") == substitution.class.sort().join(",") && + substitution.changedSubject == change.subject && + substitution.teacher == (change.teacher || "") + ); }, ); const matchingSubstitution = knownSubstitutions[matchingSubstitutionId]; @@ -115,7 +115,12 @@ export class Parser { data: { class: classes, date: new Date(date), - type: change.type == "Entfall" ? "cancellation" : "change", + type: + change.type == "Entfall" || + change.type == "eigenverantwortliches Arbeiten" + ? "cancellation" + : "change", + rawType: change.type, lesson: parseInt(change.lesson), teacher: change.teacher || "", changedTeacher: change.changedTeacher, @@ -133,6 +138,7 @@ export class Parser { changes: { class: classes, type: change.type == "Entfall" ? "cancellation" : "change", + rawType: change.type, lesson: parseInt(change.lesson), date: new Date(date), notes: change.notes, @@ -204,6 +210,7 @@ export class Parser { changes: { class: remainingSubstitution.class, type: remainingSubstitution.type, + rawType: remainingSubstitution.rawType, lesson: remainingSubstitution.lesson, date: remainingSubstitution.date.getTime(), notes: remainingSubstitution.notes, diff --git a/server/prisma/schema.prisma b/server/prisma/schema.prisma index c2223aa..5560417 100644 --- a/server/prisma/schema.prisma +++ b/server/prisma/schema.prisma @@ -27,6 +27,7 @@ model Substitution { class String[] date DateTime type String + rawType String @default("unknown") lesson Int teacher String changedTeacher String? diff --git a/src/components/history-list.vue b/src/components/history-list.vue index 8c368df..5ee7d79 100644 --- a/src/components/history-list.vue +++ b/src/components/history-list.vue @@ -79,8 +79,11 @@ const chars = { room: event.change.change.room, }, ) - }} - {{ $t("timetable.notes") }} {{ event.change.notes }} + }} + {{ event.change.rawType }} + + / {{ $t("timetable.notes") }} {{ event.change.notes }} diff --git a/src/components/lesson-card.vue b/src/components/lesson-card.vue index bffc0f4..1cad3e7 100644 --- a/src/components/lesson-card.vue +++ b/src/components/lesson-card.vue @@ -130,6 +130,9 @@ function getTime(index) { >, {{ $t("timetable.notes") }} {{ getNotes(lesson.substitution) }} + + {{ lesson.substitution.rawType }} +
{{ getTime(index).start }} - diff --git a/src/components/substitution-list.vue b/src/components/substitution-list.vue index c220612..299805e 100644 --- a/src/components/substitution-list.vue +++ b/src/components/substitution-list.vue @@ -60,8 +60,11 @@ const substitutionsForDate = computed(() => { }, ) }} - - {{ $t("timetable.notes") }} {{ substitution.notes }} + + {{ substitution.rawType }} + + / {{ $t("timetable.notes") }} {{ substitution.notes }}
@@ -98,7 +101,7 @@ const substitutionsForDate = computed(() => { word-wrap: break-word; } -.notes { +.detail { font-size: 13px; font-weight: 100; }