Skip to content

Commit

Permalink
Handle substitutions special case
Browse files Browse the repository at this point in the history
  • Loading branch information
PetJer committed Nov 4, 2024
1 parent 02d042f commit 95fd5a7
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion website/src/components/TimetableDisplay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,25 @@ function filterForTargetDay(lessonsTime: MergedLesson[][]) {
if (typeof targetDay !== 'undefined') return [lessonsTime[targetDay]]
return lessonsTime
}
function handleSubstitutionsSpacialCase(lessonsTimeDay: MergedLesson[]) {
if (lessonsTimeDay.length > 1) {
for (const lesson of lessonsTimeDay) {
if (lesson.isSubstitution && lesson.substitutionSubject !== lesson.subject) {
const sharedSubstitutionLesson = lesson
sharedSubstitutionLesson.subject = ''
sharedSubstitutionLesson.teacher = ''
sharedSubstitutionLesson.classroom = ''
sharedSubstitutionLesson.notes ??= 'ves razred'
lessonsTimeDay = [sharedSubstitutionLesson]
}
}
}
return lessonsTimeDay
}
</script>

<template>
Expand Down Expand Up @@ -122,7 +141,7 @@ function filterForTargetDay(lessonsTime: MergedLesson[][]) {
class="w-100"
>
<tr
v-for="lesson in lessonsTimeDay"
v-for="lesson in handleSubstitutionsSpacialCase(lessonsTimeDay)"
:key="`${lesson.time}-${lesson.day}-${lesson.class}-${lesson.teacher}-${lesson.classroom}`"
>
<TimetableLesson :lesson="lesson" />
Expand Down

0 comments on commit 95fd5a7

Please sign in to comment.