Implement timetable editing

This commit is contained in:
2023-06-18 23:43:08 +02:00
parent 46b235ba91
commit 4d4a92bff3
10 changed files with 532 additions and 49 deletions

View File

@ -34,9 +34,13 @@ watch(
},
{ deep: true }
);
watch(localTimetables, (newValue) => {
localStorage.setItem("timetables", JSON.stringify(newValue));
});
watch(
localTimetables,
(newValue) => {
localStorage.setItem("timetables", JSON.stringify(newValue));
},
{ deep: true }
);
watch(theme, (newValue) => {
localStorage.setItem("theme", newValue);
});
@ -186,7 +190,7 @@ export const parsedTimetable = computed(() => {
let usedLesson = { ...lesson };
// Check if lesson has multiple options
// (timetable groups)
if (Array.isArray(lesson)) {
if (Array.isArray(lesson) && lesson.length > 1) {
let matchingLesson = lesson.find((e) =>
timetableGroups.value.includes(e.group)
);
@ -200,6 +204,8 @@ export const parsedTimetable = computed(() => {
};
}
usedLesson = { ...matchingLesson };
} else if (Array.isArray(lesson)) {
usedLesson = { ...lesson[0] };
}
// Duplicate the lesson if its length is > 1 for it
// to show up multiple times in the timetable view
@ -220,7 +226,7 @@ export const possibleTimetableGroups = computed(() => {
for (const lesson of day) {
if (Array.isArray(lesson)) {
for (const group of lesson) {
if (!foundTimetableGroups.includes(group.group)) {
if (group.group && !foundTimetableGroups.includes(group.group)) {
foundTimetableGroups.push(group.group);
}
}