feat: add week start to user settings
This commit is contained in:
parent
4151f62fa5
commit
0c9671b3d9
@ -209,6 +209,7 @@ user-defaults:
|
||||
date-time-format: "%a %d %b %Y %R"
|
||||
date-format: "%a %d %b %Y"
|
||||
time-format: "%R"
|
||||
week-start: Monday
|
||||
download-files: false
|
||||
warning-days: 1209600
|
||||
show-sex: false
|
||||
|
||||
@ -807,6 +807,7 @@ Date: Datum
|
||||
DateTimeFormat: Datums- und Uhrzeitformat
|
||||
DateFormat: Datumsformat
|
||||
TimeFormat: Uhrzeitformat
|
||||
WeekStart: Erster Wochentag
|
||||
DownloadFiles: Dateien automatisch herunterladen
|
||||
DownloadFilesTip: Wenn gesetzt werden Dateien automatisch als Download behandelt, ansonsten ist das Verhalten browserabhängig (es können z.B. PDFs im Browser geöffnet werden).
|
||||
WarningDays: Fristen-Vorschau
|
||||
|
||||
@ -804,6 +804,7 @@ Date: Date
|
||||
DateTimeFormat: Date and time format
|
||||
DateFormat: Date format
|
||||
TimeFormat: Time format
|
||||
WeekStart: First day of week
|
||||
DownloadFiles: Automatically download files
|
||||
DownloadFilesTip: When set, files are automatically treated as downloads. Otherwise behaviour is browser dependent (PDFs might, for example, be opened within the browser)
|
||||
WarningDays: Deadline-preview
|
||||
|
||||
@ -28,6 +28,7 @@ User json -- Each Uni2work user has a corresponding row in this table; create
|
||||
dateTimeFormat DateTimeFormat "default='%a %d %b %Y %R'" -- preferred Date+Time display format for user; user-defined
|
||||
dateFormat DateTimeFormat "default='%d.%m.%Y'" -- preferred Date-only display format for user; user-defined
|
||||
timeFormat DateTimeFormat "default='%R'" -- preferred Time-only display format for user; user-defined
|
||||
weekStart DayOfWeek default='Monday' -- preferred first day of week for user; user-defined
|
||||
downloadFiles Bool default=false -- Should files be opened in browser or downloaded? (users often oblivious that their browser has a setting for this)
|
||||
languages Languages Maybe -- Preferred language; user-defined
|
||||
notificationSettings NotificationSettings -- Bit-array for which events email notifications are requested by user; user-defined
|
||||
|
||||
@ -253,6 +253,7 @@ upsertCampusUser upsertMode ldapData = do
|
||||
, userDateTimeFormat = userDefaultDateTimeFormat
|
||||
, userDateFormat = userDefaultDateFormat
|
||||
, userTimeFormat = userDefaultTimeFormat
|
||||
, userWeekStart = userDefaultWeekStart
|
||||
, userDownloadFiles = userDefaultDownloadFiles
|
||||
, userWarningDays = userDefaultWarningDays
|
||||
, userShowSex = userDefaultShowSex
|
||||
|
||||
@ -44,6 +44,7 @@ data SettingsForm = SettingsForm
|
||||
, stgDateTime :: DateTimeFormat
|
||||
, stgDate :: DateTimeFormat
|
||||
, stgTime :: DateTimeFormat
|
||||
, stgWeekStart :: DayOfWeek
|
||||
, stgDownloadFiles :: Bool
|
||||
, stgWarningDays :: NominalDiffTime
|
||||
, stgShowSex :: Bool
|
||||
@ -114,6 +115,7 @@ makeSettingForm template html = do
|
||||
<*> areq (selectField $ dateTimeFormatOptions SelFormatDateTime) (fslI MsgDateTimeFormat) (stgDateTime <$> template)
|
||||
<*> areq (selectField $ dateTimeFormatOptions SelFormatDate) (fslI MsgDateFormat) (stgDate <$> template)
|
||||
<*> areq (selectField $ dateTimeFormatOptions SelFormatTime) (fslI MsgTimeFormat) (stgTime <$> template)
|
||||
<*> areq (selectField . return $ mkOptionList (weekDayList mr)) (fslI MsgWeekStart) (stgWeekStart <$> template)
|
||||
<* aformSection MsgFormBehaviour
|
||||
<*> apopt checkBoxField (fslI MsgDownloadFiles
|
||||
& setTooltip MsgDownloadFilesTip
|
||||
@ -128,8 +130,9 @@ makeSettingForm template html = do
|
||||
<*> allocationNotificationForm (stgAllocationNotificationSettings <$> template)
|
||||
return (result, widget) -- no validation required here
|
||||
where
|
||||
themeList = [ Option (toMessage t) t (toPathPiece t) | t <- universeF ]
|
||||
scheduleViewList mr = [ Option (mr t) t (toPathPiece t) | t <- universeF ]
|
||||
themeList = [ Option (toMessage t) t (toPathPiece t) | t <- universeF ]
|
||||
weekDayList mr = [ Option (mr t) t (toPathPiece t) | t <- universeF ]
|
||||
|
||||
schoolsForm :: Maybe (Set SchoolId) -> AForm Handler (Set SchoolId)
|
||||
schoolsForm template = formToAForm $ schoolsFormView =<< renderWForm FormStandard schoolsForm' mempty
|
||||
@ -367,6 +370,7 @@ postProfileR = do
|
||||
, stgDateTime = userDateTimeFormat
|
||||
, stgDate = userDateFormat
|
||||
, stgTime = userTimeFormat
|
||||
, stgWeekStart = userWeekStart
|
||||
, stgDownloadFiles = userDownloadFiles
|
||||
, stgSchools = userSchools
|
||||
, stgNotificationSettings = userNotificationSettings
|
||||
@ -387,6 +391,7 @@ postProfileR = do
|
||||
, UserDateTimeFormat =. stgDateTime
|
||||
, UserDateFormat =. stgDate
|
||||
, UserTimeFormat =. stgTime
|
||||
, UserWeekStart =. stgWeekStart
|
||||
, UserDownloadFiles =. stgDownloadFiles
|
||||
, UserWarningDays =. stgWarningDays
|
||||
, UserNotificationSettings =. stgNotificationSettings
|
||||
|
||||
@ -72,6 +72,7 @@ postAdminUserAddR = do
|
||||
, userDateTimeFormat = userDefaultDateTimeFormat
|
||||
, userDateFormat = userDefaultDateFormat
|
||||
, userTimeFormat = userDefaultTimeFormat
|
||||
, userWeekStart = userDefaultWeekStart
|
||||
, userDownloadFiles = userDefaultDownloadFiles
|
||||
, userWarningDays = userDefaultWarningDays
|
||||
, userShowSex = userDefaultShowSex
|
||||
|
||||
@ -283,6 +283,9 @@ instance FromHttpApiData TokenBucketIdent where
|
||||
parseUrlPiece = maybe (Left "Could not parse TokenBucketIdent") Right . fromPathPiece
|
||||
|
||||
|
||||
derivePersistField "DayOfWeek"
|
||||
|
||||
|
||||
pathPieceJSON ''ScheduleView
|
||||
pathPieceJSONKey ''ScheduleView
|
||||
derivePersistField "ScheduleView"
|
||||
|
||||
@ -209,6 +209,7 @@ data UserDefaultConf = UserDefaultConf
|
||||
{ userDefaultTheme :: Theme
|
||||
, userDefaultMaxFavourites, userDefaultMaxFavouriteTerms :: Int
|
||||
, userDefaultDateTimeFormat, userDefaultDateFormat, userDefaultTimeFormat :: DateTimeFormat
|
||||
, userDefaultWeekStart :: DayOfWeek
|
||||
, userDefaultDownloadFiles :: Bool
|
||||
, userDefaultWarningDays :: NominalDiffTime
|
||||
, userDefaultShowSex :: Bool
|
||||
|
||||
@ -28,7 +28,6 @@ weekSchedule uid scheduleOffset = do
|
||||
dayOffset = case scheduleOffset of
|
||||
ScheduleOffsetNone -> 0
|
||||
ScheduleOffsetDays d -> d
|
||||
-- ScheduleOffsetMonths _ -> 0 -- TODO: month offset currently not supported
|
||||
dayNowOffset = toInteger dayOffset `addDays` utctDay now
|
||||
|
||||
-- TODO: single runDB for all fetches below?
|
||||
|
||||
Reference in New Issue
Block a user