✨ Add substitution plan
This commit is contained in:
@ -1 +1,12 @@
|
|||||||
export const dayNames = ["Monday", "Tuesday", "Wednesday", "Thursay", "Friday"];
|
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",
|
||||||
|
};
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { createRouter, createWebHistory } from "vue-router";
|
import { createRouter, createWebHistory } from "vue-router";
|
||||||
import TimetableView from "../views/TimetableView.vue";
|
import TimetableView from "../views/TimetableView.vue";
|
||||||
|
import SubstitutionView from "../views/SubstitutionView.vue";
|
||||||
|
|
||||||
const router = createRouter({
|
const router = createRouter({
|
||||||
history: createWebHistory(import.meta.env.BASE_URL),
|
history: createWebHistory(import.meta.env.BASE_URL),
|
||||||
@ -13,6 +14,11 @@ const router = createRouter({
|
|||||||
name: "Timetable",
|
name: "Timetable",
|
||||||
component: TimetableView,
|
component: TimetableView,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: "/substitutions",
|
||||||
|
name: "Substitutions",
|
||||||
|
component: SubstitutionView,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
11
src/store.js
11
src/store.js
@ -2,6 +2,17 @@ import { computed } from "@vue/reactivity";
|
|||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
|
|
||||||
export const timetable = ref([]);
|
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(() => {
|
export const parsedTimetable = computed(() => {
|
||||||
return timetable.value.map((day) => {
|
return timetable.value.map((day) => {
|
||||||
|
101
src/views/SubstitutionView.vue
Normal file
101
src/views/SubstitutionView.vue
Normal 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>
|
Reference in New Issue
Block a user