fix(room): deduplicate room column and fix order

This commit is contained in:
Steffen Jost 2024-10-17 16:48:09 +02:00
parent ec2b09b20b
commit d4d511a02f
3 changed files with 25 additions and 13 deletions

View File

@ -42,7 +42,7 @@ instance Finite DailyTableAction
nullaryPathPiece ''DailyTableAction $ camelToPathPiece' 2 nullaryPathPiece ''DailyTableAction $ camelToPathPiece' 2
embedRenderMessage ''UniWorX ''DailyTableAction id embedRenderMessage ''UniWorX ''DailyTableAction id
data DailyTableActionData = DailyActDummyData data DailyTableActionData = DailyActDummyData
deriving (Eq, Ord, Read, Show, Generic) deriving (Eq, Ord, Read, Show, Generic)
-- | partial JSON object to be used for filtering with "@>" -- | partial JSON object to be used for filtering with "@>"
@ -240,9 +240,9 @@ mkDailyTable isAdmin ssh nd = do
in anchorCell (CTutorialR tid cssh csh tutName TUsersR) $ citext2widget tutName in anchorCell (CTutorialR tid cssh csh tutName TUsersR) $ citext2widget tutName
, sortable Nothing (i18nCell MsgTableTutorialOccurrence) $ \(view $ resultTutorial . _entityKey -> tutId) -> cellMaybe (lessonTimesCell False) $ Map.lookup tutId tutLessons , sortable Nothing (i18nCell MsgTableTutorialOccurrence) $ \(view $ resultTutorial . _entityKey -> tutId) -> cellMaybe (lessonTimesCell False) $ Map.lookup tutId tutLessons
, sortable Nothing (i18nCell MsgTableTutorialRoom) $ \(view $ resultTutorial . _entityKey -> tutId) -> , sortable Nothing (i18nCell MsgTableTutorialRoom) $ \(view $ resultTutorial . _entityKey -> tutId) ->
-- listInlineCell (foldMap (fmap lessonRoom) $ Map.lookup tutId tutLessons) $ cellMaybe roomReferenceCell -- listInlineCell (nubOrd . concat $ mapMM lessonRoom $ Map.lookup tutId tutLessons) roomReferenceCell
-- listInlineCell (concat $ mapMM lessonRoom $ Map.lookup tutId tutLessons) roomReferenceCell cellMaybe ((`listInlineCell` roomReferenceCell) . nubOrd) $ mapMM lessonRoom $ Map.lookup tutId tutLessons
cellMaybe (`listInlineCell` roomReferenceCell) $ mapMM lessonRoom $ Map.lookup tutId tutLessons -- , sortable Nothing (i18nCell MsgTableTutorialRoom) $ \(view $ resultTutorial . _entityKey -> _) -> listCell ["A","D","C","B"] textCell -- DEMO: listCell reverses the order, for list-types! listInlineCell is fixed now
, sortable Nothing (i18nCell $ MsgCourseQualifications 3) $ \(preview resultCourseQualis -> cqs) -> maybeCell cqs $ flip listInlineCell qualificationIdShortCell , sortable Nothing (i18nCell $ MsgCourseQualifications 3) $ \(preview resultCourseQualis -> cqs) -> maybeCell cqs $ flip listInlineCell qualificationIdShortCell
, sortable (Just "user-company") (i18nCell MsgTablePrimeCompany) $ \(preview resultCompanyId -> mcid) -> cellMaybe companyIdCell mcid , sortable (Just "user-company") (i18nCell MsgTablePrimeCompany) $ \(preview resultCompanyId -> mcid) -> cellMaybe companyIdCell mcid
, sortable (Just "booking-company") (i18nCell MsgTableBookingCompany) $ \(view $ resultParticipant . _entityVal . _tutorialParticipantCompany -> mcid) -> cellMaybe companyIdCell mcid , sortable (Just "booking-company") (i18nCell MsgTableBookingCompany) $ \(view $ resultParticipant . _entityVal . _tutorialParticipantCompany -> mcid) -> cellMaybe companyIdCell mcid

View File

@ -1854,19 +1854,19 @@ maybeLinkEitherCellCM' mCache xM x2route (x2widgetAuth,x2widgetUnauth) = cell $
toWidget $ x2widgetUnauth Nothing toWidget $ x2widgetUnauth Nothing
listInlineCell :: (IsDBTable m a, MonoFoldable mono) => mono -> (Element mono -> DBCell m a) -> DBCell m a listInlineCell :: (IsDBTable m a, MonoFoldable mono, SemiSequence mono) => mono -> (Element mono -> DBCell m a) -> DBCell m a
listInlineCell = listInlineCell' . return listInlineCell = listInlineCell' . return
listInlineCell' :: (IsDBTable m a, MonoFoldable mono) => WriterT a m mono -> (Element mono -> DBCell m a) -> DBCell m a listInlineCell' :: (IsDBTable m a, MonoFoldable mono, SemiSequence mono) => WriterT a m mono -> (Element mono -> DBCell m a) -> DBCell m a
listInlineCell' mkXS mkCell = ilistInlineCell' (otoList <$> mkXS) $ const mkCell listInlineCell' mkXS mkCell = ilistInlineCell' (otoList <$> mkXS) $ const mkCell
ilistInlineCell :: (IsDBTable m a, MonoFoldableWithKey mono) => mono -> (MonoKey mono -> Element mono -> DBCell m a) -> DBCell m a ilistInlineCell :: (IsDBTable m a, MonoFoldableWithKey mono, SemiSequence mono) => mono -> (MonoKey mono -> Element mono -> DBCell m a) -> DBCell m a
ilistInlineCell = ilistInlineCell' . return ilistInlineCell = ilistInlineCell' . return
ilistInlineCell' :: (IsDBTable m a, MonoFoldableWithKey mono) => WriterT a m mono -> (MonoKey mono -> Element mono -> DBCell m a) -> DBCell m a ilistInlineCell' :: (IsDBTable m a, MonoFoldableWithKey mono, SemiSequence mono) => WriterT a m mono -> (MonoKey mono -> Element mono -> DBCell m a) -> DBCell m a
ilistInlineCell' mkXS mkCell = review dbCell . ([], ) $ do ilistInlineCell' mkXS mkCell = review dbCell . ([], ) $ do
xs <- mkXS xs <- mkXS
cells <- forM (otoKeyedList xs) $ cells <- forM (otoKeyedList $ reverse xs) $ -- Do we need to reverse for all MonoFoldableWithKey, or is only the List-Instance flawed?
\(view dbCell . uncurry mkCell -> (attrs, mkWidget)) -> (attrs, ) <$> mkWidget \(view dbCell . uncurry mkCell -> (attrs, mkWidget)) -> (attrs, ) <$> mkWidget
return $(widgetFile "table/cell/listInline") return $(widgetFile "table/cell/listInline")

View File

@ -1084,6 +1084,12 @@ fillDb = do
, scheduleEnd = TimeOfDay 14 44 0 , scheduleEnd = TimeOfDay 14 44 0
, scheduleRoom = Just $ RoomReferenceSimple "A320neo" , scheduleRoom = Just $ RoomReferenceSimple "A320neo"
} }
, ScheduleWeekly
{ scheduleDayOfWeek = Friday
, scheduleStart = TimeOfDay 15 55 0
, scheduleEnd = TimeOfDay 16 16 0
, scheduleRoom = Just $ RoomReferenceSimple "A340"
}
, ScheduleWeekly , ScheduleWeekly
{ scheduleDayOfWeek = Sunday { scheduleDayOfWeek = Sunday
, scheduleStart = TimeOfDay 15 55 0 , scheduleStart = TimeOfDay 15 55 0
@ -1094,8 +1100,8 @@ fillDb = do
, occurrencesExceptions = Set.fromList , occurrencesExceptions = Set.fromList
[ ExceptOccur [ ExceptOccur
{ exceptDay = nTimes 7 succ firstDay { exceptDay = nTimes 7 succ firstDay
, exceptStart = TimeOfDay 8 30 0 , exceptStart = TimeOfDay 8 30 30
, exceptEnd = TimeOfDay 16 0 0 , exceptEnd = TimeOfDay 16 0 30
, exceptRoom = Just $ RoomReferenceSimple "A380" , exceptRoom = Just $ RoomReferenceSimple "A380"
} }
, ExceptOccur , ExceptOccur
@ -1107,7 +1113,13 @@ fillDb = do
, ExceptOccur , ExceptOccur
{ exceptDay = nowaday { exceptDay = nowaday
, exceptStart = TimeOfDay 9 10 0 , exceptStart = TimeOfDay 9 10 0
, exceptEnd = TimeOfDay 16 10 0 , exceptEnd = TimeOfDay 12 10 0
, exceptRoom = Just $ RoomReferenceSimple "B747"
}
, ExceptOccur
{ exceptDay = nowaday
, exceptStart = TimeOfDay 13 11 0
, exceptEnd = TimeOfDay 16 11 0
, exceptRoom = Just $ RoomReferenceSimple "B747" , exceptRoom = Just $ RoomReferenceSimple "B747"
} }
] ]
@ -1152,7 +1164,7 @@ fillDb = do
{ exceptDay = nowaday { exceptDay = nowaday
, exceptStart = TimeOfDay 17 10 0 , exceptStart = TimeOfDay 17 10 0
, exceptEnd = TimeOfDay 18 10 0 , exceptEnd = TimeOfDay 18 10 0
, exceptRoom = Nothing , exceptRoom = Just $ RoomReferenceSimple "A380"
} }
] ]
} }