From 1de2c7f9d34b38eef2e36cbcede52543fa8bea17 Mon Sep 17 00:00:00 2001 From: Sarah Vaupel <> Date: Fri, 18 Sep 2020 09:47:00 +0200 Subject: [PATCH] refactor(schedule-offset): add current offset to offset type --- .../Utils/Schedule/Types/ScheduleOptions.hs | 25 +++++++------------ 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/Handler/Utils/Schedule/Types/ScheduleOptions.hs b/src/Handler/Utils/Schedule/Types/ScheduleOptions.hs index c770628ce..9dabb44bd 100644 --- a/src/Handler/Utils/Schedule/Types/ScheduleOptions.hs +++ b/src/Handler/Utils/Schedule/Types/ScheduleOptions.hs @@ -8,8 +8,6 @@ import Import import Utils.Form -import Web.PathPieces (readFromPathPiece) - data ScheduleOptions = ScheduleOptions { scheduleView :: ScheduleView @@ -38,19 +36,14 @@ instance Button UniWorX ScheduleView where data ScheduleOffset = ScheduleOffsetNone - | ScheduleOffsetDays Int - -- | ScheduleOffsetMonths Int + | ScheduleOffsetDays + { sodDays :: Int + , sodCurr :: Maybe Int + } deriving (Eq, Ord, Show, Read, Generic, Typeable) -instance PathPiece ScheduleOffset where - toPathPiece ScheduleOffsetNone = "none" - toPathPiece (ScheduleOffsetDays d) = tshow d <> "d" - --toPathPiece (ScheduleOffsetMonths m) = tshow m <> "m" - fromPathPiece "none" = Just ScheduleOffsetNone - fromPathPiece t - | Just t' <- fromNullable t - , Just n <- readFromPathPiece (init t') = case last t' of - 'd' -> Just $ ScheduleOffsetDays n - --'m' -> Just $ ScheduleOffsetMonths n - _ -> Nothing - | otherwise = Nothing +deriveJSON defaultOptions + { constructorTagModifier = camelToPathPiece' 2 + , fieldLabelModifier = camelToPathPiece' 1 + , omitNothingFields = True + } ''ScheduleOffset