refactor(schedule): enhance course schedule opt toggle

This commit is contained in:
Sarah Vaupel 2021-05-06 10:35:40 +02:00
parent a4a26afa7a
commit 4a726f09fb
2 changed files with 10 additions and 3 deletions

View File

@ -302,6 +302,13 @@ getCShowR tid ssh csh = do
mayCreateEvents <- hasWriteAccessTo $ CourseR tid ssh csh CEventsNewR
mayEdit <- hasWriteAccessTo $ CourseR tid ssh csh CEditR
let courseScheduleOptToggleValue User{userScheduleOccurrenceDisplayDefault} = maybe
( userScheduleOccurrenceDisplayDefault
&& ( is _Just registration )
)
(courseScheduleOptOpt . entityVal)
mCourseScheduleOpt
let heading = [whamlet|
$newline never
^{courseName course}

View File

@ -340,12 +340,12 @@ $# $if NTop (Just 0) < NTop (courseCapacity course)
<dd .deflist__dd>
^{tutorialTable}
$maybe (_, User{userScheduleOccurrenceDisplayDefault}) <- mbAuth
$maybe (_, user) <- mbAuth
<dt .deflist__dt>
_{MsgScheduleOptActions}
<dd .deflist__dd>
<a .btn .btn-primary href=@{CourseR tid ssh csh (CScheduleOptSetR (not (maybe ((is _Just registration) && userScheduleOccurrenceDisplayDefault) (courseScheduleOptOpt . entityVal) mCourseScheduleOpt)))}>
_{bool MsgCourseScheduleOptIn MsgCourseScheduleOptOut (maybe ((is _Just registration) && userScheduleOccurrenceDisplayDefault) (courseScheduleOptOpt . entityVal) mCourseScheduleOpt)}
<a .btn .btn-primary href=@{CourseR tid ssh csh (CScheduleOptSetR (not (courseScheduleOptToggleValue user)))}>
_{bool MsgCourseScheduleOptIn MsgCourseScheduleOptOut (courseScheduleOptToggleValue user)}
$if is _Just mCourseScheduleOpt
<a .btn .btn-primary href=@{CourseR tid ssh csh CScheduleOptDelR}>
_{MsgCourseScheduleOptDelete}