Add substitution plan

This commit is contained in:
2022-04-30 15:01:07 +02:00
parent 3599b31ab5
commit 4fef04d2a4
4 changed files with 129 additions and 0 deletions

View File

@ -1 +1,12 @@
export const dayNames = ["Monday", "Tuesday", "Wednesday", "Thursay", "Friday"];
export const substitutionTexts = {
subjectChange: "Unterrichtsänderung im Fach",
teacherChange: "Vertretung mit",
teacherChangePartial: "mit",
roomChange: "Raumvertretung in Raum",
roomChangePartial: "in Raum",
cancellation: "Ausfall",
};
export const uiTexts = {
substitutionNotes: "Notes",
};

View File

@ -1,5 +1,6 @@
import { createRouter, createWebHistory } from "vue-router";
import TimetableView from "../views/TimetableView.vue";
import SubstitutionView from "../views/SubstitutionView.vue";
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
@ -13,6 +14,11 @@ const router = createRouter({
name: "Timetable",
component: TimetableView,
},
{
path: "/substitutions",
name: "Substitutions",
component: SubstitutionView,
},
],
});

View File

@ -2,6 +2,17 @@ import { computed } from "@vue/reactivity";
import { ref } from "vue";
export const timetable = ref([]);
export const substitutions = ref([]);
export const substitutionsForDate = computed(() => {
const dates = {};
for (const substitution of substitutions.value) {
const date = substitution.date;
if (!dates[date]) dates[date] = [];
dates[substitution.date].push(substitution);
}
return dates;
});
export const parsedTimetable = computed(() => {
return timetable.value.map((day) => {

View File

@ -0,0 +1,101 @@
<script setup>
import { substitutionsForDate } from "../store";
import dayjs from "dayjs";
import { dayNames, substitutionTexts, uiTexts } from "../definitions";
function getText(substitution) {
var text = "";
if (substitution.type == "change") {
const change = substitution.change;
if (change.subject) {
text += substitutionTexts.subjectChange + " " + change.subject;
}
if (change.teacher && text == "") {
text += substitutionTexts.teacherChange + " " + change.teacher;
} else if (change.teacher) {
text += " " + substitutionTexts.teacherChangePartial;
text += " " + change.teacher;
}
if (change.room && text == "") {
text += substitutionTexts.roomChange + " " + change.room;
} else if (change.room) {
text += " " + substitutionTexts.roomChangePartial;
text += " " + change.room;
}
} else if (substitution.type == "cancellation") {
text += substitutionTexts.cancellation;
}
return text;
}
</script>
<template>
<div class="substitutions">
<template v-for="(substitutions, date) of substitutionsForDate" :key="date">
<div class="title">
<span class="day">
{{ dayNames[new Date(parseInt(date)).getDay() - 1] }},
{{ dayjs(parseInt(date)).format("DD.MM.YYYY") }}
</span>
</div>
<template v-for="(substitution, index) in substitutions" :key="index">
<div class="substitution">
<span class="hour">{{ substitution.lesson }}</span>
<div class="infos">
<span class="text">{{ getText(substitution) }}</span>
<span class="notes">
{{ substitution.notes ? uiTexts.substitutionNotes + ": " : "" }}
{{ substitution.notes }}
</span>
</div>
</div>
</template>
</template>
</div>
</template>
<style scoped>
.substitutions {
padding: 65px 10px 80px 10px;
}
.title {
font-size: 18px;
}
.substitution {
display: grid;
background-color: #26272a;
min-height: 35px;
border-radius: 11px;
margin: 10px 0px;
padding: 10px;
grid-template-columns: max-content auto;
gap: 10px;
}
.hour {
font-size: 30px;
display: flex;
align-items: center;
}
.infos {
display: flex;
justify-content: center;
flex-direction: column;
}
.text {
font-size: 18px;
display: flex;
align-items: center;
font-weight: 100;
word-wrap: break-word;
}
.notes {
font-size: 13px;
}
</style>