🏗️ Merge substitution filter and timetable filter
This commit is contained in:
28
src/store.js
28
src/store.js
@ -5,25 +5,13 @@ import router from "./router";
|
|||||||
export const lastRoute = ref();
|
export const lastRoute = ref();
|
||||||
export const loading = ref(false);
|
export const loading = ref(false);
|
||||||
|
|
||||||
export const substitutionFilter = ref(
|
export const classFilter = ref(localStorage.getItem("classFilter") || "none");
|
||||||
localStorage.getItem("substitutionFilter") || "all"
|
|
||||||
);
|
|
||||||
export const timetableClass = ref(
|
|
||||||
localStorage.getItem("timetableClass") || "none"
|
|
||||||
);
|
|
||||||
export const timetableGroups = ref(
|
export const timetableGroups = ref(
|
||||||
JSON.parse(localStorage.getItem("timetableGroups") || "[]")
|
JSON.parse(localStorage.getItem("timetableGroups") || "[]")
|
||||||
);
|
);
|
||||||
|
|
||||||
watch(substitutionFilter, (newValue) => {
|
watch(classFilter, (newValue) => {
|
||||||
if (newValue == "other") {
|
localStorage.setItem("classFilter", newValue);
|
||||||
newValue = prompt("Please enter a class to filter (e.g. 9C)");
|
|
||||||
}
|
|
||||||
localStorage.setItem("substitutionFilter", newValue);
|
|
||||||
fetchData();
|
|
||||||
});
|
|
||||||
watch(timetableClass, (newValue) => {
|
|
||||||
localStorage.setItem("timetableClass", newValue);
|
|
||||||
fetchData();
|
fetchData();
|
||||||
});
|
});
|
||||||
watch(timetableGroups, (newValue) => {
|
watch(timetableGroups, (newValue) => {
|
||||||
@ -126,7 +114,7 @@ export async function fetchClassList() {
|
|||||||
|
|
||||||
export async function fetchTimetable() {
|
export async function fetchTimetable() {
|
||||||
const timetableResponse = await fetch(
|
const timetableResponse = await fetch(
|
||||||
`${baseUrl}/timetable?class=${timetableClass.value}`
|
`${baseUrl}/timetable?class=${classFilter.value}`
|
||||||
);
|
);
|
||||||
const timetableData = await timetableResponse.json();
|
const timetableData = await timetableResponse.json();
|
||||||
if (timetableData.error) {
|
if (timetableData.error) {
|
||||||
@ -138,9 +126,9 @@ export async function fetchTimetable() {
|
|||||||
export async function fetchSubstitutions() {
|
export async function fetchSubstitutions() {
|
||||||
const requestDate = `?date=${selectedDate.value.getTime()}`;
|
const requestDate = `?date=${selectedDate.value.getTime()}`;
|
||||||
const substitutionResponse = await fetch(
|
const substitutionResponse = await fetch(
|
||||||
substitutionFilter.value == "all"
|
classFilter.value == "none"
|
||||||
? `${baseUrl}/substitutions${requestDate}`
|
? `${baseUrl}/substitutions${requestDate}`
|
||||||
: `${baseUrl}/substitutions${requestDate}&class=${substitutionFilter.value}`
|
: `${baseUrl}/substitutions${requestDate}&class=${classFilter.value}`
|
||||||
);
|
);
|
||||||
const substitutionData = await substitutionResponse.json();
|
const substitutionData = await substitutionResponse.json();
|
||||||
substitutions.value = substitutionData;
|
substitutions.value = substitutionData;
|
||||||
@ -149,9 +137,9 @@ export async function fetchSubstitutions() {
|
|||||||
export async function fetchHistory() {
|
export async function fetchHistory() {
|
||||||
const requestDate = `?date=${selectedDate.value.getTime()}`;
|
const requestDate = `?date=${selectedDate.value.getTime()}`;
|
||||||
const historyResponse = await fetch(
|
const historyResponse = await fetch(
|
||||||
substitutionFilter.value == "all"
|
classFilter.value == "all"
|
||||||
? `${baseUrl}/history${requestDate}`
|
? `${baseUrl}/history${requestDate}`
|
||||||
: `${baseUrl}/history${requestDate}&class=${substitutionFilter.value}`
|
: `${baseUrl}/history${requestDate}&class=${classFilter.value}`
|
||||||
);
|
);
|
||||||
const historyData = await historyResponse.json();
|
const historyData = await historyResponse.json();
|
||||||
if (historyData.error) console.warn("API Error: " + historyData.error);
|
if (historyData.error) console.warn("API Error: " + historyData.error);
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import {
|
import {
|
||||||
classList,
|
classList,
|
||||||
|
classFilter,
|
||||||
possibleTimetableGroups,
|
possibleTimetableGroups,
|
||||||
substitutionFilter,
|
|
||||||
timetableClass,
|
|
||||||
timetableGroups,
|
timetableGroups,
|
||||||
} from "../store";
|
} from "../store";
|
||||||
|
|
||||||
@ -13,38 +12,24 @@ const gitHash = GITVERSION;
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="settings">
|
<div class="settings">
|
||||||
<h2>Substitution Plan</h2>
|
<h2>Filtering</h2>
|
||||||
<p>
|
<p>
|
||||||
If a class is selected, only entries that are relevant for this class are
|
Select a class here so the correct timetable is used and only relevant
|
||||||
shown in the substitution plan.
|
substitutions are shown.
|
||||||
</p>
|
</p>
|
||||||
<select v-model="substitutionFilter">
|
<select v-model="classFilter">
|
||||||
<option value="all">All (No filter)</option>
|
<option value="none">Select a class</option>
|
||||||
<option v-for="option in classList" :value="option" :key="option">
|
<option v-for="option in classList" :value="option" :key="option">
|
||||||
{{ option }}
|
{{ option }}
|
||||||
</option>
|
</option>
|
||||||
<option value="other">Other</option>
|
<option value="other">Other</option>
|
||||||
</select>
|
</select>
|
||||||
<div class="spacer"></div>
|
<div class="spacer"></div>
|
||||||
<h2>Timetable</h2>
|
|
||||||
<p>
|
|
||||||
The timetable of the selected class is displayed on the timetable tab and
|
|
||||||
available substitutions are merged into it. If no class is selected or no
|
|
||||||
timetable data is available for the selected class, this functionality
|
|
||||||
will be disabled.
|
|
||||||
</p>
|
|
||||||
<select v-model="timetableClass">
|
|
||||||
<option value="none">None</option>
|
|
||||||
<option v-for="option in classList" :value="option" :key="option">
|
|
||||||
{{ option }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
<div class="spacer"></div>
|
|
||||||
<h2>Timetable Groups</h2>
|
<h2>Timetable Groups</h2>
|
||||||
<p>
|
<p>
|
||||||
The a timetable group defines, which lesson should be displayed, and for
|
A timetable group defines, which lesson should be displayed, and which
|
||||||
which substitution should be shown if there are multiple possibilities for
|
substitution should be shown if there are multiple possibilities for a
|
||||||
a single lesson within one class.
|
single lesson within one class.
|
||||||
</p>
|
</p>
|
||||||
<select v-model="timetableGroups" multiple>
|
<select v-model="timetableGroups" multiple>
|
||||||
<option value="none">None</option>
|
<option value="none">None</option>
|
||||||
|
Reference in New Issue
Block a user