chore(profile): allow editing phone numbers
This commit is contained in:
parent
4ae59fc1fa
commit
7fc6e43131
@ -34,7 +34,7 @@ User json -- Each Uni2work user has a corresponding row in this table; create
|
|||||||
timeFormat DateTimeFormat "default='%R'" -- preferred Time-only display format for user; user-defined
|
timeFormat DateTimeFormat "default='%R'" -- preferred Time-only display format 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)
|
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
|
languages Languages Maybe -- Preferred language; user-defined
|
||||||
notificationSettings NotificationSettings "default='{}'::jsonb" -- Bit-array for which events email notifications are requested by user; user-defined
|
notificationSettings NotificationSettings "default='{}'::jsonb" -- Bit-array for which events email notifications are requested by user; user-defined; missing fields in json object will be parsed to default trigger
|
||||||
warningDays NominalDiffTime default=1209600 -- timedistance to pending deadlines for homepage infos
|
warningDays NominalDiffTime default=1209600 -- timedistance to pending deadlines for homepage infos
|
||||||
csvOptions CsvOptions "default='{}'::jsonb"
|
csvOptions CsvOptions "default='{}'::jsonb"
|
||||||
sex Sex Maybe -- currently ignored
|
sex Sex Maybe -- currently ignored
|
||||||
|
|||||||
@ -70,6 +70,9 @@ data SettingsForm = SettingsForm
|
|||||||
, stgPrefersPostal :: Bool
|
, stgPrefersPostal :: Bool
|
||||||
, stgPostAddress :: Maybe StoredMarkup
|
, stgPostAddress :: Maybe StoredMarkup
|
||||||
|
|
||||||
|
, stgTelephone :: Maybe Text
|
||||||
|
, stgMobile :: Maybe Text
|
||||||
|
|
||||||
, stgExamOfficeSettings :: ExamOfficeSettings
|
, stgExamOfficeSettings :: ExamOfficeSettings
|
||||||
, stgSchools :: Set SchoolId
|
, stgSchools :: Set SchoolId
|
||||||
, stgNotificationSettings :: NotificationSettings
|
, stgNotificationSettings :: NotificationSettings
|
||||||
@ -129,9 +132,12 @@ makeSettingForm template html = do
|
|||||||
<*> apopt checkBoxField (fslI MsgShowSex & setTooltip MsgShowSexTip) (stgShowSex <$> template)
|
<*> apopt checkBoxField (fslI MsgShowSex & setTooltip MsgShowSexTip) (stgShowSex <$> template)
|
||||||
|
|
||||||
<* aformSection MsgFormNotifications
|
<* aformSection MsgFormNotifications
|
||||||
<*> aopt (textField & cfStrip) (fslI MsgPDFPassword & setTooltip MsgPDFPasswordTip) (stgPinPassword <$> template)
|
<*> aopt (textField & cfStrip) (fslI MsgPDFPassword & setTooltip MsgPDFPasswordTip) (stgPinPassword <$> template)
|
||||||
<*> apopt checkBoxField (fslI MsgPrefersPostalExp & setTooltip MsgPostalTip) (stgPrefersPostal <$> template)
|
<*> apopt checkBoxField (fslI MsgPrefersPostalExp & setTooltip MsgPostalTip) (stgPrefersPostal <$> template)
|
||||||
<*> aopt htmlField (fslI MsgPostAddress & setTooltip MsgPostAddressTip) (stgPostAddress <$> template)
|
<*> aopt htmlField (fslI MsgPostAddress & setTooltip MsgPostAddressTip) (stgPostAddress <$> template)
|
||||||
|
|
||||||
|
<*> aopt (textField & cfStrip) (fslI MsgUserTelephone) (stgTelephone <$> template)
|
||||||
|
<*> aopt (textField & cfStrip) (fslI MsgUserMobile ) (stgMobile <$> template)
|
||||||
|
|
||||||
<*> examOfficeForm (stgExamOfficeSettings <$> template)
|
<*> examOfficeForm (stgExamOfficeSettings <$> template)
|
||||||
<*> schoolsForm (stgSchools <$> template)
|
<*> schoolsForm (stgSchools <$> template)
|
||||||
@ -362,14 +368,14 @@ validateSettings User{..} = do
|
|||||||
validEmail' userDisplayEmail'
|
validEmail' userDisplayEmail'
|
||||||
|
|
||||||
userPostAddress' <- use _stgPostAddress
|
userPostAddress' <- use _stgPostAddress
|
||||||
let postalNotSet = isNothing userPostAddress'
|
let postalNotSet = isNothing userPostAddress' -- TODO $ canonical userPostAddress'
|
||||||
postalIsValid = validPostAddress userPostAddress'
|
postalIsValid = validPostAddress userPostAddress'
|
||||||
guardValidation MsgUserPostalInvalid $
|
guardValidation MsgUserPostalInvalid $
|
||||||
postalNotSet || postalIsValid
|
postalNotSet || postalIsValid
|
||||||
|
|
||||||
userPrefersPostal' <- use _stgPrefersPostal
|
userPrefersPostal' <- use _stgPrefersPostal
|
||||||
guardValidation MsgUserPrefersPostalInvalid $
|
guardValidation MsgUserPrefersPostalInvalid $
|
||||||
not $ userPrefersPostal' && (postalNotSet || isJust userCompanyDepartment)
|
not $ userPrefersPostal' && postalNotSet && isNothing userCompanyDepartment
|
||||||
|
|
||||||
userPinPassword' <- use _stgPinPassword
|
userPinPassword' <- use _stgPinPassword
|
||||||
let pinBad = validCmdArgument =<< userPinPassword'
|
let pinBad = validCmdArgument =<< userPinPassword'
|
||||||
@ -439,6 +445,8 @@ serveProfileR (uid, user@User{..}) = do
|
|||||||
, stgPinPassword = userPinPassword
|
, stgPinPassword = userPinPassword
|
||||||
, stgPostAddress = userPostAddress
|
, stgPostAddress = userPostAddress
|
||||||
, stgPrefersPostal = userPrefersPostal
|
, stgPrefersPostal = userPrefersPostal
|
||||||
|
, stgTelephone = userTelephone
|
||||||
|
, stgMobile = userMobile
|
||||||
, stgExamOfficeSettings = ExamOfficeSettings
|
, stgExamOfficeSettings = ExamOfficeSettings
|
||||||
{ eosettingsGetSynced = userExamOfficeGetSynced
|
{ eosettingsGetSynced = userExamOfficeGetSynced
|
||||||
, eosettingsGetLabels = userExamOfficeGetLabels
|
, eosettingsGetLabels = userExamOfficeGetLabels
|
||||||
@ -467,9 +475,11 @@ serveProfileR (uid, user@User{..}) = do
|
|||||||
, UserWarningDays =. stgWarningDays
|
, UserWarningDays =. stgWarningDays
|
||||||
, UserNotificationSettings =. stgNotificationSettings
|
, UserNotificationSettings =. stgNotificationSettings
|
||||||
, UserShowSex =. stgShowSex
|
, UserShowSex =. stgShowSex
|
||||||
, UserPinPassword =. stgPinPassword
|
, UserPinPassword =. stgPinPassword -- TODO & canonical
|
||||||
, UserPostAddress =. stgPostAddress
|
, UserPostAddress =. stgPostAddress -- TODO & canonical
|
||||||
, UserPrefersPostal =. stgPrefersPostal
|
, UserPrefersPostal =. stgPrefersPostal
|
||||||
|
, UserTelephone =. stgTelephone & canonical
|
||||||
|
, UserMobile =. stgMobile & canonical
|
||||||
, UserExamOfficeGetSynced =. (stgExamOfficeSettings & eosettingsGetSynced)
|
, UserExamOfficeGetSynced =. (stgExamOfficeSettings & eosettingsGetSynced)
|
||||||
, UserExamOfficeGetLabels =. (stgExamOfficeSettings & eosettingsGetLabels)
|
, UserExamOfficeGetLabels =. (stgExamOfficeSettings & eosettingsGetLabels)
|
||||||
]
|
]
|
||||||
|
|||||||
@ -1986,3 +1986,9 @@ instance {-# OVERLAPPABLE #-} (Canonical mono, MonoFoldable mono, Eq mono) => Ca
|
|||||||
-- this instance is more of a convenient abuse of the class (expand to Foldable)
|
-- this instance is more of a convenient abuse of the class (expand to Foldable)
|
||||||
instance (Ord a, Canonical a) => Canonical (Set a) where
|
instance (Ord a, Canonical a) => Canonical (Set a) where
|
||||||
canonical = Set.map canonical
|
canonical = Set.map canonical
|
||||||
|
|
||||||
|
instance Canonical (Maybe Text) where
|
||||||
|
canonical Nothing = Nothing
|
||||||
|
canonical (Just t) =
|
||||||
|
let t' = Text.strip t
|
||||||
|
in if Text.null t' then Nothing else Just t'
|
||||||
|
|||||||
Reference in New Issue
Block a user