refactor(schedule): enhance options type and instances
This commit is contained in:
parent
1de2c7f9d3
commit
4316606743
@ -1,7 +1,7 @@
|
||||
module Handler.Utils.Schedule.Types.ScheduleOptions
|
||||
( ScheduleOptions(..)
|
||||
, ScheduleView(..)
|
||||
( ScheduleView(..)
|
||||
, ScheduleOffset(..)
|
||||
, ScheduleOptions(..)
|
||||
) where
|
||||
|
||||
import Import
|
||||
@ -9,13 +9,6 @@ import Import
|
||||
import Utils.Form
|
||||
|
||||
|
||||
data ScheduleOptions = ScheduleOptions
|
||||
{ scheduleView :: ScheduleView
|
||||
, scheduleOffset :: ScheduleOffset
|
||||
}
|
||||
deriving (Eq, Ord, Show, Read, Generic, Typeable)
|
||||
|
||||
|
||||
data ScheduleView = ScheduleViewWeek
|
||||
deriving (Eq, Ord, Enum, Show, Read, Generic, Typeable)
|
||||
|
||||
@ -25,10 +18,10 @@ instance Bounded ScheduleView where
|
||||
instance Finite ScheduleView
|
||||
instance Universe ScheduleView
|
||||
|
||||
instance PathPiece ScheduleView where
|
||||
toPathPiece = camelToPathPiece' 2 . tshow
|
||||
fromPathPiece "week" = Just ScheduleViewWeek
|
||||
fromPathPiece _ = Nothing
|
||||
deriveJSON defaultOptions
|
||||
{ constructorTagModifier = camelToPathPiece' 2
|
||||
} ''ScheduleView
|
||||
derivePathPiece ''ScheduleView (camelToPathPiece' 2) "-"
|
||||
|
||||
instance Button UniWorX ScheduleView where
|
||||
btnClasses ScheduleViewWeek = [BCIsButton, BCScheduleView]
|
||||
@ -36,14 +29,17 @@ instance Button UniWorX ScheduleView where
|
||||
|
||||
|
||||
data ScheduleOffset = ScheduleOffsetNone
|
||||
| ScheduleOffsetDays
|
||||
{ sodDays :: Int
|
||||
, sodCurr :: Maybe Int
|
||||
}
|
||||
| ScheduleOffsetDays Int
|
||||
deriving (Eq, Ord, Show, Read, Generic, Typeable)
|
||||
|
||||
deriveJSON defaultOptions
|
||||
{ constructorTagModifier = camelToPathPiece' 2
|
||||
, fieldLabelModifier = camelToPathPiece' 1
|
||||
, omitNothingFields = True
|
||||
} ''ScheduleOffset
|
||||
derivePathPiece ''ScheduleOffset (camelToPathPiece' 2) "-"
|
||||
|
||||
|
||||
data ScheduleOptions = ScheduleOptions
|
||||
{ scheduleView :: ScheduleView
|
||||
, scheduleOffset :: ScheduleOffset
|
||||
}
|
||||
deriving (Eq, Ord, Show, Read, Generic, Typeable)
|
||||
|
||||
Reference in New Issue
Block a user