diff --git a/src/Utils/Schedule/Week.hs b/src/Utils/Schedule/Week.hs index e7eddf686..e4a879165 100644 --- a/src/Utils/Schedule/Week.hs +++ b/src/Utils/Schedule/Week.hs @@ -80,14 +80,14 @@ weekSchedule uid dayOffset = do events' :: Map Day (Map TimeSlot [ScheduleEntry]) events' = Map.fromList $ week <&> \day -> ( day - , Map.fromList $ timeSlotsToDisplay <&> \slot -> + , Map.fromList $ allTimeSlots <&> \slot -> ( slot - , filter (seIsInSlot tz day slot) $ join $ - (courseEventToScheduleEntries <$> courseEvents) - <> (tutorialToScheduleEntries <$> tutorials) - <> pure (examOccurrenceToScheduleEntry <$> (joinParallelExamOccurrences examOccurrences)) + , filter (seIsInSlot tz day slot) scheduleEntries ) - ) + ) where + scheduleEntries = join $ (courseEventToScheduleEntries <$> courseEvents) + <> (tutorialToScheduleEntries <$> tutorials) + <> pure (examOccurrenceToScheduleEntry <$> (joinParallelExamOccurrences examOccurrences)) events :: Map Day (Map TimeSlot [ScheduleEntry]) events = events' <&> \slotsPerDay -> slotsPerDay <&> \occurrencesInSlot -> @@ -118,8 +118,14 @@ weekSchedule uid dayOffset = do firstDay = toEnum $ fromEnum Monday + fromInteger (fromMaybe 0 dayOffset) -- TODO: make this configurable - timeSlotsToDisplay :: [TimeSlot] - timeSlotsToDisplay = timeSlot <$> [8,10..18] + timeSlotsDefaultDisplay :: Set TimeSlot + timeSlotsDefaultDisplay = Set.fromList $ timeSlot <$> [8,10..18] + + allTimeSlots :: [TimeSlot] + allTimeSlots = timeSlot <$> [0,2..24] + + timeSlotIsEmpty :: TimeSlot -> Bool + timeSlotIsEmpty slot = foldr (\day acc -> acc && maybe True null (day Map.!? slot)) True events $(widgetFile "widgets/schedule/week") diff --git a/templates/widgets/schedule/week.hamlet b/templates/widgets/schedule/week.hamlet index 678245e11..7cc1da029 100644 --- a/templates/widgets/schedule/week.hamlet +++ b/templates/widgets/schedule/week.hamlet @@ -9,37 +9,38 @@ $newline never ^{formatTimeW SelFormatDate day} - $forall slot <- timeSlotsToDisplay - - - ^{formatTimeSlotW slot} - $forall day <- week + $forall slot <- allTimeSlots + $if Set.member slot timeSlotsDefaultDisplay || not (timeSlotIsEmpty slot) + -
- $maybe dayEvents <- Map.lookup day events - $maybe slotEvents <- Map.lookup slot dayEvents - $forall scheduleEntry <- slotEvents - -
- $case scheduleEntry - $of ScheduleCourseEvent{sceCourse=Entity _ Course{courseName},sceType,sceRoom,sceOccurrence} - #{CI.original courseName}: #{CI.original sceType}
- _{MsgScheduleRoom}: #{sceRoom}
- ^{formatEitherOccurrenceW sceOccurrence} - $of ScheduleTutorial{stCourse=Entity _ Course{courseName},stName,stType,stRoom,stOccurrence} - #{CI.original courseName}: #{stName} (#{CI.original stType})
- _{MsgScheduleRoom}: #{stRoom}
- ^{formatEitherOccurrenceW stOccurrence} - $of ScheduleExamOccurrence{seoCourse=Entity _ Course{courseName},seoExamName,seoRooms,seoStart,seoEnd} - #{CI.original courseName}: #{seoExamName}
- $case toList seoRooms - $of [room] - _{MsgScheduleRoom}: #{room} - $of more - _{MsgScheduleRooms}: #{intercalate ", " more} -
- _{MsgScheduleOccur}: # - $if Just (utctDay seoStart) == fmap utctDay seoEnd - ^{formatTimeRangeW SelFormatTime seoStart seoEnd} - $else - ^{formatTimeRangeW SelFormatDateTime seoStart seoEnd} + ^{formatTimeSlotW slot} + $forall day <- week + +
+ $maybe dayEvents <- Map.lookup day events + $maybe slotEvents <- Map.lookup slot dayEvents + $forall scheduleEntry <- slotEvents + +
+ $case scheduleEntry + $of ScheduleCourseEvent{sceCourse=Entity _ Course{courseName},sceType,sceRoom,sceOccurrence} + #{CI.original courseName}: #{CI.original sceType}
+ _{MsgScheduleRoom}: #{sceRoom}
+ ^{formatEitherOccurrenceW sceOccurrence} + $of ScheduleTutorial{stCourse=Entity _ Course{courseName},stName,stType,stRoom,stOccurrence} + #{CI.original courseName}: #{stName} (#{CI.original stType})
+ _{MsgScheduleRoom}: #{stRoom}
+ ^{formatEitherOccurrenceW stOccurrence} + $of ScheduleExamOccurrence{seoCourse=Entity _ Course{courseName},seoExamName,seoRooms,seoStart,seoEnd} + #{CI.original courseName}: #{seoExamName}
+ $case toList seoRooms + $of [room] + _{MsgScheduleRoom}: #{room} + $of more + _{MsgScheduleRooms}: #{intercalate ", " more} +
+ _{MsgScheduleOccur}: # + $if Just (utctDay seoStart) == fmap utctDay seoEnd + ^{formatTimeRangeW SelFormatTime seoStart seoEnd} + $else + ^{formatTimeRangeW SelFormatDateTime seoStart seoEnd}