diff --git a/src/router/index.js b/src/router/index.js index 68257a6..e484db6 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -1,6 +1,7 @@ import { createRouter, createWebHistory } from "vue-router"; import TimetableView from "../views/TimetableView.vue"; import SubstitutionView from "../views/SubstitutionView.vue"; +import HistoryView from "../views/HistoryView.vue"; const router = createRouter({ history: createWebHistory(import.meta.env.BASE_URL), @@ -19,6 +20,11 @@ const router = createRouter({ name: "Substitutions", component: SubstitutionView, }, + { + path: "/history", + name: "History", + component: HistoryView, + }, ], }); diff --git a/src/store.js b/src/store.js index d207f82..04d8487 100644 --- a/src/store.js +++ b/src/store.js @@ -1,8 +1,17 @@ import { computed } from "@vue/reactivity"; import { ref } from "vue"; -export const timetable = ref([]); -export const substitutions = ref([]); +export const history = ref([]); + +export const historyOfDate = computed(() => { + const dates = {}; + for (const entry of history.value) { + const date = entry.date; + if (!dates[date]) dates[date] = []; + dates[entry.date].push(entry); + } + return dates; +}); export const substitutionsForDate = computed(() => { const dates = {}; diff --git a/src/util.js b/src/util.js new file mode 100644 index 0000000..1642924 --- /dev/null +++ b/src/util.js @@ -0,0 +1,26 @@ +import { substitutionTexts } from "./definitions"; + +export function getSubstitutionText(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; +} diff --git a/src/views/HistoryView.vue b/src/views/HistoryView.vue new file mode 100644 index 0000000..2fb7b86 --- /dev/null +++ b/src/views/HistoryView.vue @@ -0,0 +1,120 @@ + + + + + diff --git a/src/views/SubstitutionView.vue b/src/views/SubstitutionView.vue index ab78686..e13eb58 100644 --- a/src/views/SubstitutionView.vue +++ b/src/views/SubstitutionView.vue @@ -1,32 +1,8 @@