chore(avs): switch company (WIP)
This commit is contained in:
parent
6084f92ad7
commit
29182cb6dd
@ -747,20 +747,20 @@ postAdminAvsUserR uuid = do
|
|||||||
-- return fwgt
|
-- return fwgt
|
||||||
|
|
||||||
-- TODO: make it optional, if there are eligible companies only
|
-- TODO: make it optional, if there are eligible companies only
|
||||||
switchCompForm :: Handler Widget
|
switchCompForm :: Maybe Company -> Handler Widget
|
||||||
switchCompForm = do
|
switchCompForm mbPrime = do
|
||||||
let switchAllCompForm :: AForm (HandlerFor UniWorX) (CryptoUUIDUser,CompanyName)
|
let switchAllCompForm :: AForm (HandlerFor UniWorX) (CryptoUUIDUser,CompanyName)
|
||||||
switchAllCompForm = (,)
|
switchAllCompForm = (,)
|
||||||
<$> areq hiddenField "user-id" (Just uuid)
|
<$> areq hiddenField "user-id" (Just uuid)
|
||||||
<*> areq (selectFieldList [(ciOriginal c, c) | c <- compsUsed]) "new primary company" Nothing
|
<*> areq (selectFieldList [(ciOriginal c, c) | c <- compsUsed]) "new primary company" (companyName <$> mbPrime)
|
||||||
<* aopt (buttonField UserAvsSwitchCompany) "" Nothing
|
-- <* aopt (buttonField UserAvsSwitchCompany) "" Nothing
|
||||||
((spRes, spWgt), spEnc) <- runFormPost . identifyForm ("switch-primary-company"::Text) $ renderAForm FormStandard switchAllCompForm
|
((spRes, spWgt), spEnc) <- runFormPost . identifyForm ("switch-primary-company"::Text) $ renderAForm FormStandard switchAllCompForm
|
||||||
formResultModal spRes (AdminAvsUserR uuid) (\(_,c) -> do
|
formResultModal spRes (AdminAvsUserR uuid) (\(_,c) -> do
|
||||||
lift $ $logInfoS "AVS" ("Switch company option result " <> tshow spRes)
|
lift $ $logInfoS "AVS" ("Switch company option result " <> tshow spRes)
|
||||||
tell . pure $ Message Success [shamlet|TODO #{c} received|] Nothing
|
tell . pure $ Message Success [shamlet|TODO #{c} received|] Nothing
|
||||||
)
|
)
|
||||||
return $ wrapForm spWgt
|
return $ wrapForm spWgt
|
||||||
def { formAction = Just $ SomeRoute (AdminAvsUserR uuid), formEncoding = spEnc, formSubmit = FormNoSubmit, formAttrs = [ asyncSubmitAttr | isModal ]}
|
def { formAction = Just $ SomeRoute (AdminAvsUserR uuid), formEncoding = spEnc, formSubmit = FormSubmit, formAttrs = [ asyncSubmitAttr | isModal ]}
|
||||||
|
|
||||||
compDict <- if 1 >= length compsUsed
|
compDict <- if 1 >= length compsUsed
|
||||||
then return mempty -- switch company only sensible if there is more than one company to choose
|
then return mempty -- switch company only sensible if there is more than one company to choose
|
||||||
@ -772,7 +772,7 @@ postAdminAvsUserR uuid = do
|
|||||||
comps :: [Entity Company] <- selectList fltrCmps [Asc CompanyName, Asc CompanyAvsId] -- company name is already unique, but AVS sometimes contains uses whitespace
|
comps :: [Entity Company] <- selectList fltrCmps [Asc CompanyName, Asc CompanyAvsId] -- company name is already unique, but AVS sometimes contains uses whitespace
|
||||||
return (companyName <$> mbPrimeComp, Map.fromAscList [(cname,cid) | (Entity{entityKey=cid, entityVal=Company{companyName=cname}}) <- comps])
|
return (companyName <$> mbPrimeComp, Map.fromAscList [(cname,cid) | (Entity{entityKey=cid, entityVal=Company{companyName=cname}}) <- comps])
|
||||||
-- formDict <- Map.traverseWithKey runSwitchFrom compDict
|
-- formDict <- Map.traverseWithKey runSwitchFrom compDict
|
||||||
swForm <- switchCompForm
|
swForm <- switchCompForm mbPrimeComp
|
||||||
return (primName, --formDict,
|
return (primName, --formDict,
|
||||||
swForm)
|
swForm)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user