refactor(schedule): better template separation

This commit is contained in:
Sarah Vaupel 2020-08-20 17:25:04 +02:00
parent 9b78a5be12
commit 2ea234259b
6 changed files with 42 additions and 42 deletions

View File

@ -102,7 +102,7 @@ TermLectureEndTooltip: Meistens dauer das Sommersemester 14 Wochen und das Winte
TermActive: Aktiv
ScheduleHeadline: Terminübersicht
NewsHeadlineSchedule: Terminübersicht
ScheduleTableHeadTime: Zeit

View File

@ -102,7 +102,7 @@ TermLectureEndTooltip: Summer semesters are usually 14 weeks; winter semesters 1
TermActive: Active
ScheduleHeadline: Schedule
NewsHeadlineSchedule: Schedule
ScheduleTableHeadTime: Time

View File

@ -89,7 +89,7 @@ newsSystemMessages = do
-- TODO: persist default schedule in user settings, lookup default and choose schedule accordingly
-- TODO: add action to switch schedule (replace widget)
newsSchedule :: UserId -> Widget
newsSchedule = flip weekSchedule Nothing
newsSchedule uid = let schedule = weekSchedule uid Nothing in $(widgetFile "news/schedule")
newsUpcomingSheets :: UserId -> Widget

View File

@ -12,7 +12,6 @@ data ScheduleEntry = ScheduleEntry
{ seCourse :: Entity Course -- TODO: just course?; TODO: Maybe?
, seType :: ScheduleEntryType
, seRoom :: ScheduleEntryRoom
--, seOccurrences :: Occurrences -- TODO: will require converting exam occurrences to an ExceptOccur OccurrenceException
, seOccurrence :: ScheduleEntryOccurrence
}

View File

@ -0,0 +1,5 @@
$newline never
<section>
<h2>
_{MsgNewsHeadlineSchedule}
^{schedule}

View File

@ -1,41 +1,37 @@
$newline never
<section>
<h2>
_{MsgScheduleHeadline}
<div uw-hide-columns="schedule-week">
<table .table .table--striped .table--hover .schedule>
<thead>
<tr .table__row .table__row--head>
<th .table__th uw-hide-column-header="time">
_{MsgScheduleTableHeadTime}
$forall (_, weekDayTitle, weekDayIdent) <- weekDays
<th .table__th uw-hide-column-header=#{weekDayIdent}>
_{weekDayTitle}
<tbody>
$forall slot <- slotsToDisplay
<tr .table__row>
<div uw-hide-columns="schedule-week">
<table .table .table--striped .table--hover .schedule>
<thead>
<tr .table__row .table__row--head>
<th .table__th uw-hide-column-header="time">
_{MsgScheduleTableHeadTime}
$forall (_, weekDayTitle, weekDayIdent) <- weekDays
<th .table__th uw-hide-column-header=#{weekDayIdent}>
_{weekDayTitle}
<tbody>
$forall slot <- slotsToDisplay
<tr .table__row>
<td .table__td>
^{slotToDisplayTime slot}
$forall (day, _, _) <- weekDays
<td .table__td>
^{slotToDisplayTime slot}
$forall (day, _, _) <- weekDays
<td .table__td>
<div .table__td-content>
$maybe dayEvents <- Map.lookup day courseEvents
$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>
<div .schedule--entry>
#{CI.original courseName}: #
$case seType
$of SETCourseEvent{..}
#{CI.original setceType}
$of SETTutorial{..}
#{CI.original settType}
$of SETExamOccurrence{..}
#{seteoExamName}
<br>
<div .table__td-content>
$maybe dayEvents <- Map.lookup day courseEvents
$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>
<div .schedule--entry>
#{CI.original courseName}: #
$case seType
$of SETCourseEvent{..}
#{CI.original setceType}
$of SETTutorial{..}
#{CI.original settType}
$of SETExamOccurrence{..}
#{seteoExamName}
<br>
$maybe room <- seRoom
_{MsgScheduleRoom}: #{room} <br/>
^{formatOccurrenceW seOccurrence}
$maybe room <- seRoom
_{MsgScheduleRoom}: #{room} <br/>
^{formatOccurrenceW seOccurrence}