dateTimeCell cleanup
This commit is contained in:
parent
787cf0d7cc
commit
ba7b49e2d3
@ -172,11 +172,11 @@ colRating = sortable (Just "rating") (i18nCell MsgRating) $ \DBRow{ dbrOutput=(E
|
|||||||
|
|
||||||
colAssigned :: IsDBTable m a => Colonnade _ CorrectionTableData (DBCell m a)
|
colAssigned :: IsDBTable m a => Colonnade _ CorrectionTableData (DBCell m a)
|
||||||
colAssigned = sortable (Just "assignedtime") (i18nCell MsgAssignedTime) $ \DBRow{ dbrOutput=(Entity _subId Submission{..}, _sheet, _course, _, _) } ->
|
colAssigned = sortable (Just "assignedtime") (i18nCell MsgAssignedTime) $ \DBRow{ dbrOutput=(Entity _subId Submission{..}, _sheet, _course, _, _) } ->
|
||||||
maybe mempty timeCell submissionRatingAssigned
|
maybe mempty dateTimeCell submissionRatingAssigned
|
||||||
|
|
||||||
colRated :: IsDBTable m a => Colonnade _ CorrectionTableData (DBCell m a)
|
colRated :: IsDBTable m a => Colonnade _ CorrectionTableData (DBCell m a)
|
||||||
colRated = sortable (Just "ratingtime") (i18nCell MsgRatingTime) $ \DBRow{ dbrOutput=(Entity _subId Submission{..}, _sheet, _course, _, _) } ->
|
colRated = sortable (Just "ratingtime") (i18nCell MsgRatingTime) $ \DBRow{ dbrOutput=(Entity _subId Submission{..}, _sheet, _course, _, _) } ->
|
||||||
maybe mempty timeCell submissionRatingTime
|
maybe mempty dateTimeCell submissionRatingTime
|
||||||
|
|
||||||
colPseudonyms :: IsDBTable m a => Colonnade _ CorrectionTableData (DBCell m a)
|
colPseudonyms :: IsDBTable m a => Colonnade _ CorrectionTableData (DBCell m a)
|
||||||
colPseudonyms = sortable Nothing (i18nCell MsgPseudonyms) $ \DBRow{ dbrOutput=(_, _, _, _, users) } -> let
|
colPseudonyms = sortable Nothing (i18nCell MsgPseudonyms) $ \DBRow{ dbrOutput=(_, _, _, _, users) } -> let
|
||||||
|
|||||||
@ -83,13 +83,13 @@ colSchoolShort = sortable (Just "schoolshort") (i18nCell MsgCourseSchoolShort)
|
|||||||
colRegFrom :: IsDBTable m a => Colonnade _ CourseTableData (DBCell m a)
|
colRegFrom :: IsDBTable m a => Colonnade _ CourseTableData (DBCell m a)
|
||||||
colRegFrom = sortable (Just "register-from") (i18nCell MsgRegisterFrom)
|
colRegFrom = sortable (Just "register-from") (i18nCell MsgRegisterFrom)
|
||||||
$ \DBRow{ dbrOutput=(Entity _ Course{..}, _, _, _) } ->
|
$ \DBRow{ dbrOutput=(Entity _ Course{..}, _, _, _) } ->
|
||||||
maybe mempty timeCell courseRegisterFrom
|
maybe mempty dateTimeCell courseRegisterFrom
|
||||||
-- cell $ traverse (formatTime SelFormatDateTime) courseRegisterFrom >>= maybe mempty toWidget
|
-- cell $ traverse (formatTime SelFormatDateTime) courseRegisterFrom >>= maybe mempty toWidget
|
||||||
|
|
||||||
colRegTo :: IsDBTable m a => Colonnade _ CourseTableData (DBCell m a)
|
colRegTo :: IsDBTable m a => Colonnade _ CourseTableData (DBCell m a)
|
||||||
colRegTo = sortable (Just "register-to") (i18nCell MsgRegisterTo)
|
colRegTo = sortable (Just "register-to") (i18nCell MsgRegisterTo)
|
||||||
$ \DBRow{ dbrOutput=(Entity _ Course{..}, _, _, _) } ->
|
$ \DBRow{ dbrOutput=(Entity _ Course{..}, _, _, _) } ->
|
||||||
maybe mempty timeCell courseRegisterTo
|
maybe mempty dateTimeCell courseRegisterTo
|
||||||
|
|
||||||
colMembers :: IsDBTable m a => Colonnade _ CourseTableData (DBCell m a)
|
colMembers :: IsDBTable m a => Colonnade _ CourseTableData (DBCell m a)
|
||||||
colMembers = sortable (Just "members") (i18nCell MsgCourseMembers)
|
colMembers = sortable (Just "members") (i18nCell MsgCourseMembers)
|
||||||
@ -705,7 +705,7 @@ getCUsersR tid ssh csh = do
|
|||||||
[ colUserParticipantLink tid ssh csh
|
[ colUserParticipantLink tid ssh csh
|
||||||
, colUserEmail
|
, colUserEmail
|
||||||
, colUserMatriclenr
|
, colUserMatriclenr
|
||||||
, sortable (Just "registration") (i18nCell MsgRegistered) (timeCell . (view _userTableRegistration))
|
, sortable (Just "registration") (i18nCell MsgRegistered) (dateCell . (view _userTableRegistration))
|
||||||
, colUserComment tid ssh csh
|
, colUserComment tid ssh csh
|
||||||
]
|
]
|
||||||
psValidator = def
|
psValidator = def
|
||||||
|
|||||||
@ -336,7 +336,7 @@ mkEnrolledCoursesTable =
|
|||||||
courseCell <$> view (_dbrOutput . _1 . _entityVal)
|
courseCell <$> view (_dbrOutput . _1 . _entityVal)
|
||||||
, sortable (Just "time") (i18nCell MsgRegistered) $ do
|
, sortable (Just "time") (i18nCell MsgRegistered) $ do
|
||||||
regTime <- view $ _dbrOutput . _2
|
regTime <- view $ _dbrOutput . _2
|
||||||
return $ timeCell regTime
|
return $ dateTimeCell regTime
|
||||||
]
|
]
|
||||||
, dbtSorting = Map.fromList
|
, dbtSorting = Map.fromList
|
||||||
[ ( "course", SortColumn $ withType $ \(crse `E.InnerJoin` _) -> crse E.^. CourseName )
|
[ ( "course", SortColumn $ withType $ \(crse `E.InnerJoin` _) -> crse E.^. CourseName )
|
||||||
@ -409,9 +409,9 @@ mkSubmissionTable =
|
|||||||
<*> view (_3 . _entityKey)
|
<*> view (_3 . _entityKey)
|
||||||
-- , sortable (Just "edit") (i18nCell MsgSubmissionEditUser) $ do
|
-- , sortable (Just "edit") (i18nCell MsgSubmissionEditUser) $ do
|
||||||
-- regTime <- view $ _dbrOutput . _4
|
-- regTime <- view $ _dbrOutput . _4
|
||||||
-- return $ maybe mempty timeCell regTime
|
-- return $ maybe mempty dateTimeCell regTime
|
||||||
, sortable (Just "edit") (i18nCell MsgLastEditByUser) $
|
, sortable (Just "edit") (i18nCell MsgLastEditByUser) $
|
||||||
maybe mempty timeCell <$> view (_dbrOutput . _4)
|
maybe mempty dateTimeCell <$> view (_dbrOutput . _4)
|
||||||
]
|
]
|
||||||
|
|
||||||
validator = def -- DUPLICATED CODE: Handler.Corrections
|
validator = def -- DUPLICATED CODE: Handler.Corrections
|
||||||
@ -483,7 +483,7 @@ mkSubmissionGroupTable =
|
|||||||
, sortable (Just "submissiongroup") (i18nCell MsgSubmissionGroupName) . magnify (_dbrOutput . _2 . _entityVal) $
|
, sortable (Just "submissiongroup") (i18nCell MsgSubmissionGroupName) . magnify (_dbrOutput . _2 . _entityVal) $
|
||||||
maybe mempty textCell <$> view _submissionGroupName
|
maybe mempty textCell <$> view _submissionGroupName
|
||||||
, sortable (Just "edit") (i18nCell MsgLastEdit) $
|
, sortable (Just "edit") (i18nCell MsgLastEdit) $
|
||||||
maybe mempty timeCell <$> view (_dbrOutput . _3)
|
maybe mempty dateTimeCell <$> view (_dbrOutput . _3)
|
||||||
]
|
]
|
||||||
|
|
||||||
validator = def -- DUPLICATED CODE: Handler.Corrections
|
validator = def -- DUPLICATED CODE: Handler.Corrections
|
||||||
|
|||||||
@ -177,13 +177,13 @@ getSheetListR tid ssh csh = do
|
|||||||
, sortable (Just "name") (i18nCell MsgSheet)
|
, sortable (Just "name") (i18nCell MsgSheet)
|
||||||
$ \DBRow{dbrOutput=(Entity _ Sheet{..}, _, _)} -> anchorCell (CSheetR tid ssh csh sheetName SShowR) (toWidget sheetName)
|
$ \DBRow{dbrOutput=(Entity _ Sheet{..}, _, _)} -> anchorCell (CSheetR tid ssh csh sheetName SShowR) (toWidget sheetName)
|
||||||
, sortable (Just "last-edit") (i18nCell MsgLastEdit)
|
, sortable (Just "last-edit") (i18nCell MsgLastEdit)
|
||||||
$ \DBRow{dbrOutput=(_, E.Value mEditTime, _)} -> maybe mempty timeCell mEditTime
|
$ \DBRow{dbrOutput=(_, E.Value mEditTime, _)} -> maybe mempty dateTimeCell mEditTime
|
||||||
, sortable (Just "visible-from") (i18nCell MsgSheetVisibleFrom)
|
, sortable (Just "visible-from") (i18nCell MsgSheetVisibleFrom)
|
||||||
$ \DBRow{dbrOutput=(Entity _ Sheet{..}, _, _)} -> maybe mempty timeCell sheetVisibleFrom
|
$ \DBRow{dbrOutput=(Entity _ Sheet{..}, _, _)} -> maybe mempty dateTimeCell sheetVisibleFrom
|
||||||
, sortable (Just "submission-since") (i18nCell MsgSheetActiveFrom)
|
, sortable (Just "submission-since") (i18nCell MsgSheetActiveFrom)
|
||||||
$ \DBRow{dbrOutput=(Entity _ Sheet{..}, _, _)} -> timeCell sheetActiveFrom
|
$ \DBRow{dbrOutput=(Entity _ Sheet{..}, _, _)} -> dateTimeCell sheetActiveFrom
|
||||||
, sortable (Just "submission-until") (i18nCell MsgSheetActiveTo)
|
, sortable (Just "submission-until") (i18nCell MsgSheetActiveTo)
|
||||||
$ \DBRow{dbrOutput=(Entity _ Sheet{..}, _, _)} -> timeCell sheetActiveTo
|
$ \DBRow{dbrOutput=(Entity _ Sheet{..}, _, _)} -> dateTimeCell sheetActiveTo
|
||||||
, sortable Nothing (i18nCell MsgSheetType)
|
, sortable Nothing (i18nCell MsgSheetType)
|
||||||
$ \DBRow{dbrOutput=(Entity _ Sheet{..}, _, _)} -> i18nCell sheetType
|
$ \DBRow{dbrOutput=(Entity _ Sheet{..}, _, _)} -> i18nCell sheetType
|
||||||
, sortable Nothing (i18nCell MsgSubmission)
|
, sortable Nothing (i18nCell MsgSubmission)
|
||||||
|
|||||||
@ -280,7 +280,7 @@ submissionHelper tid ssh csh shn (SubmissionMode mcid) = do
|
|||||||
origTime = fileModified . entityVal . snd <$> mOrig
|
origTime = fileModified . entityVal . snd <$> mOrig
|
||||||
corrTime = fileModified . entityVal . snd <$> mCorr
|
corrTime = fileModified . entityVal . snd <$> mCorr
|
||||||
Just fileTime = (max <$> origTime <*> corrTime) <|> origTime <|> corrTime
|
Just fileTime = (max <$> origTime <*> corrTime) <|> origTime <|> corrTime
|
||||||
in timeCell fileTime
|
in dateTimeCell fileTime
|
||||||
]
|
]
|
||||||
coalesce :: ((Maybe (Entity SubmissionFile), Maybe (Entity File)), (Maybe (Entity SubmissionFile), Maybe (Entity File))) -> (Maybe (Entity SubmissionFile, Entity File), Maybe (Entity SubmissionFile, Entity File))
|
coalesce :: ((Maybe (Entity SubmissionFile), Maybe (Entity File)), (Maybe (Entity SubmissionFile), Maybe (Entity File))) -> (Maybe (Entity SubmissionFile, Entity File), Maybe (Entity SubmissionFile, Entity File))
|
||||||
coalesce ((ma, mb), (mc, md)) = ((,) <$> ma <*> mb, (,) <$> mc <*> md)
|
coalesce ((ma, mb), (mc, md)) = ((,) <$> ma <*> mb, (,) <$> mc <*> md)
|
||||||
|
|||||||
@ -53,7 +53,13 @@ commentCell (Just link) = anchorCell link icon
|
|||||||
-----------------
|
-----------------
|
||||||
-- Datatype cells
|
-- Datatype cells
|
||||||
timeCell :: IsDBTable m a => UTCTime -> DBCell m a
|
timeCell :: IsDBTable m a => UTCTime -> DBCell m a
|
||||||
timeCell t = cell $ formatTime SelFormatDateTime t >>= toWidget
|
timeCell t = cell $ formatTime SelFormatTime t >>= toWidget
|
||||||
|
|
||||||
|
dateCell :: IsDBTable m a => UTCTime -> DBCell m a
|
||||||
|
dateCell t = cell $ formatTime SelFormatDate t >>= toWidget
|
||||||
|
|
||||||
|
dateTimeCell :: IsDBTable m a => UTCTime -> DBCell m a
|
||||||
|
dateTimeCell t = cell $ formatTime SelFormatDateTime t >>= toWidget
|
||||||
|
|
||||||
userCell :: IsDBTable m a => Text -> Text -> DBCell m a
|
userCell :: IsDBTable m a => Text -> Text -> DBCell m a
|
||||||
userCell displayName surname = cell $ nameWidget displayName surname
|
userCell displayName surname = cell $ nameWidget displayName surname
|
||||||
@ -84,8 +90,8 @@ cellHasEMail = emailCell . view _userEmail
|
|||||||
|
|
||||||
|
|
||||||
-- Just for documentation purposes; inline this code instead:
|
-- Just for documentation purposes; inline this code instead:
|
||||||
maybeTimeCell :: IsDBTable m a => Maybe UTCTime -> DBCell m a
|
maybeDateTimeCell :: IsDBTable m a => Maybe UTCTime -> DBCell m a
|
||||||
maybeTimeCell = maybe mempty timeCell
|
maybeDateTimeCell = maybe mempty dateTimeCell
|
||||||
|
|
||||||
numCell :: (IsDBTable m a, Num b, DisplayAble b) => b -> DBCell m a
|
numCell :: (IsDBTable m a, Num b, DisplayAble b) => b -> DBCell m a
|
||||||
numCell = textCell . display
|
numCell = textCell . display
|
||||||
|
|||||||
Reference in New Issue
Block a user