feat(schedule): better handling of hrefs

This commit is contained in:
Sarah Vaupel 2020-08-20 18:53:56 +02:00
parent 6245079465
commit 3254d34dc4
3 changed files with 12 additions and 6 deletions

View File

@ -57,7 +57,7 @@ weekSchedule uid _weekOffset = do
return (course, courseEvent)
tutorials <- liftHandler . runDB $ E.select $ E.from $ \(course `E.InnerJoin` tutorial) -> do
E.on $ course E.^. CourseId E.==. tutorial E.^. TutorialCourse
E.on $ course E.^. CourseId E.==. tutorial E.^. TutorialCourse
E.where_ $ (E.exists $ E.from $ \tutorialParticipant -> E.where_ $
tutorialParticipant E.^. TutorialParticipantTutorial E.==. tutorial E.^. TutorialId
E.&&. tutorialParticipant E.^. TutorialParticipantUser E.==. E.val uid
@ -164,6 +164,12 @@ weekSchedule uid _weekOffset = do
Left ExceptOccur{..} -> [whamlet| _{MsgScheduleOccur}: |] <> formatTimeRangeW SelFormatTime (LocalTime exceptDay exceptStart) (Just (LocalTime exceptDay exceptEnd))
Left ExceptNoOccur{} -> [whamlet| _{MsgScheduleNoOccur} |] -- <> formatTimeW SelFormatDateTime exceptTime
scheduleEntryToHref :: ScheduleEntry -> Route UniWorX
scheduleEntryToHref ScheduleEntry{seCourse=Entity _ Course{..},seType} = case seType of
SETCourseEvent{} -> CourseR courseTerm courseSchool courseShorthand CShowR -- TODO: link to events table? (TODO currently has no id)
SETTutorial{} -> CourseR courseTerm courseSchool courseShorthand CShowR -- TODO: link to table with id "tutorials"?
SETExam{..} -> CExamR courseTerm courseSchool courseShorthand seteName EShowR
$(widgetFile "widgets/schedule/week")

View File

@ -19,7 +19,7 @@ data ScheduleEntryType = SETCourseEvent { setceType :: CI Text } -- TOD
| SETTutorial { settType :: CI Text
, settName :: TutorialName
} -- TODO: TutorialType not possible here (comes from data family instance)
| SETExamOccurrence { seteoName :: ExamName }
| SETExam { seteName :: ExamName }
-- TODO: more?
deriving (Eq, Ord, Show, Read, Generic, Typeable)

View File

@ -18,8 +18,8 @@ $newline never
<div .table__td-content>
$maybe dayEvents <- Map.lookup day events
$maybe slotEvents <- Map.lookup slot dayEvents
$forall ScheduleEntry{seCourse=Entity _ Course{courseTerm,courseSchool,courseShorthand,courseName},seType,seRoom,seOccurrence} <- slotEvents
<a href=@{CourseR courseTerm courseSchool courseShorthand CShowR} .schedule--entry-link>
$forall se@ScheduleEntry{seCourse=Entity _ Course{courseName},seType,seRoom,seOccurrence} <- slotEvents
<a href=@{scheduleEntryToHref se} .schedule--entry-link>
<div .schedule--entry>
#{CI.original courseName}: #
$case seType
@ -28,8 +28,8 @@ $newline never
$of SETTutorial{..}
#{settName} #
(#{CI.original settType})
$of SETExamOccurrence{..}
#{seteoName}
$of SETExam{..}
#{seteName}
<br>
$maybe room <- seRoom