propagated avatars. works.
This commit is contained in:
parent
edc307a01f
commit
fc83ae87df
8 changed files with 26 additions and 9 deletions
|
@ -2,6 +2,7 @@ module Handler.Home where
|
||||||
|
|
||||||
import Import
|
import Import
|
||||||
import qualified Text.Read as R
|
import qualified Text.Read as R
|
||||||
|
import Data.Maybe
|
||||||
|
|
||||||
-- This is a handler function for the GET request method on the HomeR
|
-- This is a handler function for the GET request method on the HomeR
|
||||||
-- resource pattern. All of your resource patterns are defined in
|
-- resource pattern. All of your resource patterns are defined in
|
||||||
|
|
|
@ -41,7 +41,7 @@ newUserForm secs = renderDivs $ User
|
||||||
|
|
||||||
data UserConf = UserConf
|
data UserConf = UserConf
|
||||||
{ userConfEmail :: Maybe Text
|
{ userConfEmail :: Maybe Text
|
||||||
, userConfNotify :: Bool
|
, userConfAvatar :: Maybe AvatarId
|
||||||
}
|
}
|
||||||
|
|
||||||
getModifyUserR :: UserId -> Handler Html
|
getModifyUserR :: UserId -> Handler Html
|
||||||
|
@ -63,11 +63,12 @@ postModifyUserR uId = do
|
||||||
Just user -> do
|
Just user -> do
|
||||||
((res, _), _) <- runFormPost $ modifyUserForm user
|
((res, _), _) <- runFormPost $ modifyUserForm user
|
||||||
case res of
|
case res of
|
||||||
FormSuccess email -> do
|
FormSuccess uc -> do
|
||||||
runDB $ update uId
|
runDB $ update uId
|
||||||
[ UserEmail =. email
|
[ UserEmail =. userConfEmail uc
|
||||||
|
, UserAvatar =. userConfAvatar uc
|
||||||
]
|
]
|
||||||
liftIO $ notify user email
|
liftIO $ notify user (userConfEmail uc)
|
||||||
setMessageI MsgUserEdited
|
setMessageI MsgUserEdited
|
||||||
redirect $ SelectR uId
|
redirect $ SelectR uId
|
||||||
_ -> do
|
_ -> do
|
||||||
|
@ -77,9 +78,14 @@ postModifyUserR uId = do
|
||||||
setMessageI MsgUserUnknown
|
setMessageI MsgUserUnknown
|
||||||
redirect $ HomeR
|
redirect $ HomeR
|
||||||
|
|
||||||
modifyUserForm :: User -> Form (Maybe Text)
|
modifyUserForm :: User -> Form UserConf
|
||||||
modifyUserForm user = renderDivs $
|
modifyUserForm user = renderDivs $ UserConf
|
||||||
aopt emailField (fieldSettingsLabel MsgEmailNotify) (Just $ userEmail user)
|
<$> aopt emailField (fieldSettingsLabel MsgEmailNotify) (Just $ userEmail user)
|
||||||
|
<*> aopt (selectField avatars) (fieldSettingsLabel MsgSelectAvatar) (Just $ userAvatar user)
|
||||||
|
where
|
||||||
|
avatars = do
|
||||||
|
ents <- runDB $ selectList [] [Asc AvatarIdent]
|
||||||
|
optionsPairs $ map (\ent -> ((avatarIdent $ entityVal ent), entityKey ent)) ents
|
||||||
|
|
||||||
notify :: User -> Maybe Text -> IO ()
|
notify :: User -> Maybe Text -> IO ()
|
||||||
notify user email
|
notify user email
|
||||||
|
|
|
@ -72,8 +72,8 @@ newArticleForm = renderDivs $ Beverage
|
||||||
<*> areq currencyField (fieldSettingsLabel MsgPrice) (Just 100)
|
<*> areq currencyField (fieldSettingsLabel MsgPrice) (Just 100)
|
||||||
<*> areq amountField (fieldSettingsLabel MsgAmount) (Just 0)
|
<*> areq amountField (fieldSettingsLabel MsgAmount) (Just 0)
|
||||||
<*> areq amountField (fieldSettingsLabel MsgAmountWarning) (Just 0)
|
<*> areq amountField (fieldSettingsLabel MsgAmountWarning) (Just 0)
|
||||||
<*> aopt (selectField albums) (fieldSettingsLabel MsgSelectAvatar) Nothing
|
<*> aopt (selectField avatars) (fieldSettingsLabel MsgSelectAvatar) Nothing
|
||||||
where
|
where
|
||||||
albums = do
|
avatars = do
|
||||||
ents <- runDB $ selectList [] [Asc AvatarIdent]
|
ents <- runDB $ selectList [] [Asc AvatarIdent]
|
||||||
optionsPairs $ map (\ent -> ((avatarIdent $ entityVal ent), entityKey ent)) ents
|
optionsPairs $ map (\ent -> ((avatarIdent $ entityVal ent), entityKey ent)) ents
|
||||||
|
|
|
@ -4,6 +4,7 @@ import Import
|
||||||
import Handler.Common
|
import Handler.Common
|
||||||
import qualified Text.Read as R
|
import qualified Text.Read as R
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
|
import Data.Maybe
|
||||||
|
|
||||||
getSelectR :: UserId -> Handler Html
|
getSelectR :: UserId -> Handler Html
|
||||||
getSelectR uId = do
|
getSelectR uId = do
|
||||||
|
|
|
@ -35,12 +35,15 @@ article#func.article {
|
||||||
position: relative;
|
position: relative;
|
||||||
top: -7.75em;
|
top: -7.75em;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
|
z-index: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.article a p {
|
.article a p {
|
||||||
|
position: relative;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
line-height: normal;
|
line-height: normal;
|
||||||
|
z-index: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
img.flag {
|
img.flag {
|
||||||
|
|
|
@ -15,6 +15,8 @@ $forall (Entity uId user) <- users
|
||||||
<article .article>
|
<article .article>
|
||||||
<a href=@{SelectR uId}>
|
<a href=@{SelectR uId}>
|
||||||
<p>#{userIdent user}
|
<p>#{userIdent user}
|
||||||
|
$if userAvatar user /= Nothing
|
||||||
|
<img src=@{GetAvatarR $ fromJust $ userAvatar user}>
|
||||||
|
|
||||||
<article .article #func>
|
<article .article #func>
|
||||||
<a href=@{ReactivateR}>
|
<a href=@{ReactivateR}>
|
||||||
|
|
|
@ -22,3 +22,5 @@ $forall (Entity bId bev) <- beverages
|
||||||
<a href=@{BuyR uId bId}>
|
<a href=@{BuyR uId bId}>
|
||||||
<p>
|
<p>
|
||||||
#{beverageIdent bev}
|
#{beverageIdent bev}
|
||||||
|
$if beverageAvatar bev /= Nothing
|
||||||
|
<img src=@{GetAvatarR $ fromJust $ beverageAvatar bev}>
|
||||||
|
|
|
@ -7,3 +7,5 @@ $forall (Entity bId bev) <- beverages
|
||||||
<a href=@{BuyCashR bId}>
|
<a href=@{BuyCashR bId}>
|
||||||
<p>
|
<p>
|
||||||
#{beverageIdent bev}
|
#{beverageIdent bev}
|
||||||
|
$if beverageAvatar bev /= Nothing
|
||||||
|
<img src=@{GetAvatarR $ fromJust $ beverageAvatar bev}>
|
||||||
|
|
Loading…
Reference in a new issue