From 231cc00fe9856ce4d3975614513c14ec00db519c Mon Sep 17 00:00:00 2001 From: Steffen Jost Date: Mon, 15 May 2023 07:51:41 +0000 Subject: [PATCH] chore(lms): consistent lms status cells all tables --- src/Handler/LMS.hs | 5 +++-- src/Handler/Qualification.hs | 2 +- src/Handler/Utils/Table/Cells.hs | 17 +++++------------ 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/Handler/LMS.hs b/src/Handler/LMS.hs index 2fbb562bc..ecfaca1ae 100644 --- a/src/Handler/LMS.hs +++ b/src/Handler/LMS.hs @@ -585,7 +585,8 @@ postLmsR sid qsh = do , sortable (Just "ident") (i18nCell MsgTableLmsIdent) $ \(view $ resultLmsUser . _entityVal . _lmsUserIdent . _getLmsIdent -> lid) -> textCell lid , sortable (Just "pin") (i18nCell MsgTableLmsPin & cellAttrs <>~ [("uw-hide-column-default-hidden",mempty)] ) $ \(view $ resultLmsUser . _entityVal . _lmsUserPin -> pin) -> textCell pin - , sortable (Just "status") (i18nCell MsgTableLmsStatus) $ \(view $ resultLmsUser . _entityVal . _lmsUserStatus -> status) -> foldMap lmsStatusCell status + , sortable (Just "status") (i18nCell MsgTableLmsStatus & cellTooltipWgt Nothing (lmsStatusInfoCell isAdmin $ qent ^. _entityVal . _qualificationAuditDuration)) + $ \(view $ resultLmsUser . _entityVal -> lmsUserVal) -> lmsStatusCell isAdmin Nothing lmsUserVal , sortable (Just "started") (i18nLms MsgTableLmsStarted) $ \(view $ resultLmsUser . _entityVal . _lmsUserStarted -> d) -> dateTimeCell d , sortable (Just "datepin") (i18nLms MsgTableLmsDatePin) $ \(view $ resultLmsUser . _entityVal . _lmsUserDatePin -> d) -> dateTimeCell d , sortable (Just "received") (i18nLms MsgTableLmsReceived) $ \(view $ resultLmsUser . _entityVal . _lmsUserReceived -> d) -> foldMap dateTimeCell d @@ -703,7 +704,7 @@ postLmsR sid qsh = do getLmsIdentR :: SchoolId -> QualificationShorthand -> LmsIdent -> Handler Html getLmsIdentR sid qid ident = redirect (LmsR sid qid, [("lms-ident", toPathPiece ident)]) --- intended to be viewed primarily in a modal, wie lmsStatusPlusCell +-- intended to be viewed primarily in a modal, wie lmsStatusCell getLmsUserR :: CryptoUUIDUser -> Handler Html getLmsUserR uuid = do uid <- decrypt uuid diff --git a/src/Handler/Qualification.hs b/src/Handler/Qualification.hs index faa429ba9..9d57be2b9 100644 --- a/src/Handler/Qualification.hs +++ b/src/Handler/Qualification.hs @@ -520,7 +520,7 @@ postQualificationR sid qsh = do , sortable (Just "schedule-renew")(i18nCell MsgTableQualificationNoRenewal & cellTooltip MsgTableQualificationNoRenewalTooltip ) $ \( view $ resultQualUser . _entityVal . _qualificationUserScheduleRenewal -> b) -> ifIconCell (not b) IconNoNotification , sortable (Just "lms-status-plus")(i18nCell MsgTableLmsStatus & cellTooltipWgt Nothing (lmsStatusInfoCell isAdmin auditMonths)) - $ \(preview $ resultLmsUser . _entityVal -> lu) -> foldMap (lmsStatusPlusCell linkLmsUser) lu + $ \(preview $ resultLmsUser . _entityVal -> lu) -> foldMap (lmsStatusCell isAdmin linkLmsUser) lu , sortable (Just "last-notified") (i18nCell MsgTableQualificationLastNotified) $ \( view $ resultQualUser . _entityVal . _qualificationUserLastNotified -> d) -> dateTimeCell d ] psValidator = def & defaultSorting [SortDescBy "last-refresh"] diff --git a/src/Handler/Utils/Table/Cells.hs b/src/Handler/Utils/Table/Cells.hs index c4fb8ea02..f45b07508 100644 --- a/src/Handler/Utils/Table/Cells.hs +++ b/src/Handler/Utils/Table/Cells.hs @@ -13,7 +13,7 @@ import Handler.Utils.Table.Pagination import Handler.Utils.DateTime import Handler.Utils.Widgets import Handler.Utils.Occurrences -import Handler.Utils.LMS (lmsUserStatusWidget, lmsStatusIcon) +import Handler.Utils.LMS (lmsUserStatusWidget) type CourseLink = (TermId, SchoolId, CourseShorthand) -- TODO: Refactor with WithHoles ! @@ -364,18 +364,11 @@ roomReferenceCell = cell . roomReferenceWidget cryptoidCell :: (IsDBTable m a, PathPiece cid) => cid -> DBCell m a cryptoidCell = addCellClass ("cryptoid" :: Text) . textCell . toPathPiece -lmsStatusCell :: IsDBTable m a => LmsStatus -> DBCell m a -lmsStatusCell ls = iconCell (lmsStatusIcon ls) <> spacerCell <> dayCell (lmsStatusDay ls) - --- lmsStatusPlusCell :: IsDBTable m a => LmsUser -> DBCell m a --- lmsStatusPlusCell LmsUser{lmsUserStatus=Just lStat} = lmsStatusCell lStat --- lmsStatusPlusCell LmsUser{lmsUserStarted} = iconCell IconWaitingForUser <> spacerCell <> dateCell lmsUserStarted - -lmsStatusPlusCell :: IsDBTable m a => Maybe (CryptoUUIDUser -> Route UniWorX) -> LmsUser -> DBCell m a -lmsStatusPlusCell Nothing lu = wgtCell $ lmsUserStatusWidget False lu -lmsStatusPlusCell (Just toLink) lu = cell $ do +lmsStatusCell :: IsDBTable m a => Bool -> Maybe (CryptoUUIDUser -> Route UniWorX) -> LmsUser -> DBCell m a +lmsStatusCell extendedInfo Nothing lu = wgtCell $ lmsUserStatusWidget extendedInfo lu +lmsStatusCell extendedInfo (Just toLink) lu = cell $ do uuid <- liftHandler $ encrypt $ lu ^. _lmsUserUser - modal (lmsUserStatusWidget True lu) (Left $ SomeRoute $ toLink uuid) + modal (lmsUserStatusWidget extendedInfo lu) (Left $ SomeRoute $ toLink uuid) qualificationBlockedCellNoReason :: IsDBTable m a => Maybe QualificationBlocked -> DBCell m a qualificationBlockedCellNoReason Nothing = mempty