feat(schedule-week): account for weekdays to hide
This commit is contained in:
parent
6f4891bb90
commit
61545cade0
@ -81,8 +81,8 @@ weekSchedule (Entity uid User{userScheduleWeekDays=ScheduleWeekDays userSchedule
|
||||
seoEnd = examOccurrenceEnd occ -- so taking the timestamps of the first occurrence suffices
|
||||
in ScheduleExamOccurrence{..}
|
||||
|
||||
events' :: Map Day (Map TimeSlot [ScheduleEntry])
|
||||
events' = Map.fromList $ week <&> \d ->
|
||||
events'' :: Map Day (Map TimeSlot [ScheduleEntry])
|
||||
events'' = Map.fromList $ week <&> \d ->
|
||||
( d
|
||||
, Map.fromList $ allTimeSlots <&> \slot ->
|
||||
( slot
|
||||
@ -93,8 +93,8 @@ weekSchedule (Entity uid User{userScheduleWeekDays=ScheduleWeekDays userSchedule
|
||||
<> (tutorialToScheduleEntries <$> tutorials)
|
||||
<> pure (examOccurrenceToScheduleEntry <$> (joinParallelExamOccurrences examOccurrences))
|
||||
|
||||
events :: Map Day (Map TimeSlot [ScheduleEntry])
|
||||
events = events' <&> \slotsPerDay -> slotsPerDay <&> \occurrencesInSlot ->
|
||||
events' :: Map Day (Map TimeSlot [ScheduleEntry])
|
||||
events' = events'' <&> \slotsPerDay -> slotsPerDay <&> \occurrencesInSlot ->
|
||||
let
|
||||
isRegularWithoutException :: ScheduleEntry -> Bool
|
||||
isRegularWithoutException =
|
||||
@ -112,10 +112,15 @@ weekSchedule (Entity uid User{userScheduleWeekDays=ScheduleWeekDays userSchedule
|
||||
_ -> True
|
||||
in filter isRegularWithoutException occurrencesInSlot
|
||||
|
||||
-- TODO: perform this filtering asap, in DB fetch if possible
|
||||
events :: Map Day (Map TimeSlot [ScheduleEntry])
|
||||
events = Map.filterWithKey shouldBeDisplayedOrHasEvents events' where
|
||||
shouldBeDisplayedOrHasEvents d entries = dayOfWeek d `elem` userScheduleWeekDays || any (not . null) entries
|
||||
|
||||
week :: [Day]
|
||||
week = go dayNowOffset
|
||||
where go d
|
||||
| dayOfWeek d == firstDay = filter (flip elem userScheduleWeekDays . dayOfWeek) [d .. toEnum (fromEnum d + 6)]
|
||||
| dayOfWeek d == firstDay = [d .. toEnum (fromEnum d + 6)]
|
||||
| otherwise = go $ pred d
|
||||
firstDay = toEnum $ fromEnum userWeekStart + dayOffset
|
||||
|
||||
|
||||
@ -6,8 +6,9 @@ $newline never
|
||||
<th .table__th uw-hide-column-header="time">
|
||||
_{MsgScheduleTableHeadTime}
|
||||
$forall day <- week
|
||||
<th .table__th uw-hide-column-header=#{dayTableHeadIdent day}>
|
||||
^{formatTimeW SelFormatDate day}
|
||||
$if is _Just (Map.lookup day events)
|
||||
<th .table__th uw-hide-column-header=#{dayTableHeadIdent day}>
|
||||
^{formatTimeW SelFormatDate day}
|
||||
<tbody>
|
||||
$forall slot <- allTimeSlots
|
||||
$if Set.member slot timeSlotsDefaultDisplay || not (timeSlotIsEmpty slot)
|
||||
@ -15,10 +16,10 @@ $newline never
|
||||
<td .table__td>
|
||||
^{formatTimeSlotW slot}
|
||||
$forall day <- week
|
||||
<td .table__td>
|
||||
<div .table__td-content>
|
||||
$maybe dayEvents <- Map.lookup day events
|
||||
$maybe slotEvents <- Map.lookup slot dayEvents
|
||||
$maybe dayEvents <- Map.lookup day events
|
||||
$maybe slotEvents <- Map.lookup slot dayEvents
|
||||
<td .table__td>
|
||||
<div .table__td-content>
|
||||
$forall scheduleEntry <- slotEvents
|
||||
<a href=@{scheduleEntryToHref scheduleEntry} .schedule--entry-link>
|
||||
<div .schedule--entry>
|
||||
|
||||
Reference in New Issue
Block a user