fix(occurrences): room occurrence form works now
This commit is contained in:
parent
72b2b6876b
commit
f642b9cccf
@ -27,7 +27,7 @@ instance Hashable LiteralType
|
||||
instance Binary LiteralType
|
||||
instance NFData LiteralType
|
||||
|
||||
|
||||
|
||||
deriving instance Generic PersistValue
|
||||
|
||||
instance Hashable PersistValue
|
||||
|
||||
@ -16,16 +16,12 @@ import Utils.Form
|
||||
import Utils.Files
|
||||
|
||||
import Handler.Utils.Form.Types
|
||||
|
||||
import Handler.Utils.Pandoc
|
||||
|
||||
import Handler.Utils.DateTime
|
||||
|
||||
import Handler.Utils.I18n
|
||||
|
||||
import Handler.Utils.Files
|
||||
|
||||
import Handler.Utils.Exam
|
||||
import Handler.Utils.Memcached
|
||||
|
||||
import Utils.Term
|
||||
|
||||
@ -2352,10 +2348,11 @@ roomReferenceSimpleField =
|
||||
|
||||
roomReferenceSimpleSuggestions :: HandlerFor UniWorX (OptionList Text)
|
||||
roomReferenceSimpleSuggestions = do
|
||||
suggsRaw <- runDB [sqlQQ|
|
||||
suggsRaw :: [Text] <- $(memcachedByHere) (Just $ Right $ 30 * diffSecond) ("rooms-recently-used"::Text) (E.unSingle <<$>> runDB
|
||||
[sqlQQ|
|
||||
SELECT room FROM (
|
||||
SELECT DISTINCT ON (room)
|
||||
j.value #> '{room,text}' AS room
|
||||
j.value #>> '{room,text}' AS room
|
||||
, t.@{TutorialLastChanged} AS changed
|
||||
FROM ^{Tutorial} AS t
|
||||
, jsonb_array_elements((@{TutorialTime}->'exceptions') || (@{TutorialTime}->'scheduled')) AS j
|
||||
@ -2364,8 +2361,9 @@ roomReferenceSimpleSuggestions = do
|
||||
WHERE room IS NOT NULL
|
||||
ORDER BY changed DESC
|
||||
LIMIT 7;
|
||||
|]
|
||||
return $ mkOptionList $ fmap (\(E.unSingle -> t) -> Option t t t) suggsRaw
|
||||
|] )
|
||||
$logDebugS "Room" $ mconcat suggsRaw
|
||||
return $ mkOptionList $ fmap (\t -> Option t t t) suggsRaw
|
||||
-- suggs <- liftHandler $ runDBRead $ E.select $ do
|
||||
-- tut <- E.from $ E.table @Tutorial
|
||||
-- return $ tut E.^. tutorialTime E.#>>. ["scheduled","1","room","text"]
|
||||
@ -2406,7 +2404,7 @@ roomReferenceForm' noneOpt fs mPrev = multiActionAOpts opts opts' fs $ fmap clas
|
||||
Nothing -> pure Nothing
|
||||
Just RoomReferenceSimple' -> wFormToAForm $ do
|
||||
MsgRenderer mr <- getMsgRenderer
|
||||
fmap (Just . RoomReferenceSimple) <$> wpreq (textField & cfStrip) (fslI MsgRoomReferenceSimpleText & addPlaceholder (mr MsgRoomReferenceSimpleTextPlaceholder) & maybe id (\n -> addName $ n <> "__text") (fsName fs)) (mPrev ^? _Just . _Just . _roomRefText)
|
||||
fmap (Just . RoomReferenceSimple) <$> wpreq (textField & cfStrip & addDatalist roomReferenceSimpleSuggestions) (fslI MsgRoomReferenceSimpleText & addPlaceholder (mr MsgRoomReferenceSimpleTextPlaceholder) & maybe id (\n -> addName $ n <> "__text") (fsName fs)) (mPrev ^? _Just . _Just . _roomRefText)
|
||||
Just RoomReferenceLink' -> wFormToAForm $ do
|
||||
MsgRenderer mr <- getMsgRenderer
|
||||
roomRefLink' <- wpreq urlField (fslI MsgRoomReferenceLinkLink & addPlaceholder (mr MsgRoomReferenceLinkLinkPlaceholder) & maybe id (\n -> addName $ n <> "__link") (fsName fs)) (mPrev ^? _Just . _Just . _roomRefLink)
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
-- SPDX-FileCopyrightText: 2022 Gregor Kleen <gregor.kleen@ifi.lmu.de>,Sarah Vaupel <vaupel.sarah@campus.lmu.de>,Winnie Ros <winnie.ros@campus.lmu.de>
|
||||
-- SPDX-FileCopyrightText: 2022-24 Gregor Kleen <gregor.kleen@ifi.lmu.de>,Sarah Vaupel <vaupel.sarah@campus.lmu.de>,Winnie Ros <winnie.ros@campus.lmu.de>,Steffen Jost <s.jost@fraport.de>
|
||||
--
|
||||
-- SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
@ -61,9 +61,8 @@ occurrencesAForm (toPathPiece -> miIdent') mPrev = wFormToAForm $ do
|
||||
<$> apreq (selectField' Nothing optionsFinite) (fslI MsgOccurrenceWeekDay & addName (nudge "occur-week-day")) Nothing
|
||||
<*> apreq timeFieldTypeTime (fslI MsgOccurrenceStart & addName (nudge "occur-start")) Nothing
|
||||
<*> apreq timeFieldTypeTime (fslI MsgOccurrenceEnd & addName (nudge "occur-end")) Nothing
|
||||
-- DEBUG TODO
|
||||
-- <*> roomReferenceFormOpt (fslI MsgTableTutorialRoom) Nothing
|
||||
<*> aopt roomReferenceSimpleField (fslI MsgTableTutorialRoom) Nothing
|
||||
<*> roomReferenceForm' Nothing (fslI MsgTableTutorialRoom & addName (nudge "occur-room")) Nothing
|
||||
-- <*> aopt roomReferenceSimpleField (fslI MsgTableTutorialRoom & addName (nudge "occur-room")) (Just Nothing)
|
||||
)
|
||||
]
|
||||
) (fslI MsgScheduleRegularKind & addName (nudge "kind")) Nothing
|
||||
@ -100,9 +99,8 @@ occurrencesAForm (toPathPiece -> miIdent') mPrev = wFormToAForm $ do
|
||||
<$> apreq dayField (fslI MsgDay & addName (nudge "occur-day")) Nothing
|
||||
<*> apreq timeFieldTypeTime (fslI MsgOccurrenceStart & addName (nudge "occur-start")) Nothing
|
||||
<*> apreq timeFieldTypeTime (fslI MsgOccurrenceEnd & addName (nudge "occur-end")) Nothing
|
||||
-- DEBUG TODO
|
||||
-- <*> roomReferenceFormOpt (fslI MsgTableTutorialRoom) (Just Nothing) -- still does not work
|
||||
<*> aopt roomReferenceSimpleField (fslI MsgTableTutorialRoom) Nothing
|
||||
<*> roomReferenceForm' Nothing (fslI MsgTableTutorialRoom & addName (nudge "occur-room")) Nothing
|
||||
-- <*> aopt roomReferenceSimpleField (fslI MsgTableTutorialRoom & addName (nudge "occur-room")) Nothing
|
||||
)
|
||||
, ( ExceptionKindNoOccur
|
||||
, ExceptNoOccur
|
||||
|
||||
@ -16,8 +16,8 @@ module Utils.DateTime
|
||||
, mkDateTimeFormatter
|
||||
, nominalHour, nominalMinute
|
||||
, minNominalYear, avgNominalYear
|
||||
, diffMinute, diffHour, diffDay
|
||||
, module Zones
|
||||
, diffSecond, diffMinute, diffHour, diffDay
|
||||
, module Zones
|
||||
, day
|
||||
, utctDayMidnight
|
||||
) where
|
||||
@ -86,7 +86,7 @@ timeLocaleMap extra@((_, defLocale):_) = do
|
||||
letE [localeMap'] (varE localeMap)
|
||||
|
||||
compileTime :: ExpQ -- Type UTCTime
|
||||
compileTime = do
|
||||
compileTime = do
|
||||
now <- runIO getCurrentTime
|
||||
[e|now|]
|
||||
|
||||
@ -166,7 +166,8 @@ avgNominalYear = fromRational $ 365.2425 * toRational nominalDay
|
||||
-- DiffTime --
|
||||
--------------
|
||||
|
||||
diffMinute, diffHour, diffDay :: DiffTime
|
||||
diffSecond, diffMinute, diffHour, diffDay :: DiffTime
|
||||
diffSecond = 1
|
||||
diffMinute = 60
|
||||
diffHour = 3600
|
||||
diffDay = 86400
|
||||
|
||||
Loading…
Reference in New Issue
Block a user