Fix admin toggle.
parent
b2caff5123
commit
320ff4f2ec
|
@ -63,9 +63,10 @@ data Action
|
||||||
|
|
||||||
| HandleAddUserInput AddUserInput
|
| HandleAddUserInput AddUserInput
|
||||||
|
|
||||||
| AddUserAttempt Event
|
| AddUserAttempt
|
||||||
-- | Finalize
|
-- | Finalize
|
||||||
| HandleWebSocket (WebSocketEvent WebSocketMessageType)
|
| HandleWebSocket (WebSocketEvent WebSocketMessageType)
|
||||||
|
| PreventSubmit Event
|
||||||
|
|
||||||
type StateAddUserForm = { login :: String, admin :: Boolean, email :: String, pass :: String }
|
type StateAddUserForm = { login :: String, admin :: Boolean, email :: String, pass :: String }
|
||||||
|
|
||||||
|
@ -130,7 +131,7 @@ render {
|
||||||
should_be_disabled = (maybe (HP.disabled true) (\_ -> HP.enabled true) wsInfo.connection)
|
should_be_disabled = (maybe (HP.disabled true) (\_ -> HP.enabled true) wsInfo.connection)
|
||||||
|
|
||||||
render_adduser_form = HH.form
|
render_adduser_form = HH.form
|
||||||
[ HE.onSubmit AddUserAttempt ]
|
[ HE.onSubmit PreventSubmit ]
|
||||||
[ Bulma.box_input "User login" "login" -- title, placeholder
|
[ Bulma.box_input "User login" "login" -- title, placeholder
|
||||||
(HandleAddUserInput <<< ADDUSER_INP_login) -- action
|
(HandleAddUserInput <<< ADDUSER_INP_login) -- action
|
||||||
addUserForm.login -- value
|
addUserForm.login -- value
|
||||||
|
@ -140,8 +141,7 @@ render {
|
||||||
(show addUserForm.admin) -- value
|
(show addUserForm.admin) -- value
|
||||||
(HandleAddUserInput ADDUSER_toggle_admin) -- action1
|
(HandleAddUserInput ADDUSER_toggle_admin) -- action1
|
||||||
(HandleAddUserInput ADDUSER_toggle_admin) -- action2
|
(HandleAddUserInput ADDUSER_toggle_admin) -- action2
|
||||||
true -- validity (TODO)
|
true -- validity
|
||||||
-- should_be_disabled -- condition
|
|
||||||
, Bulma.box_input "User email" "email" -- title, placeholder
|
, Bulma.box_input "User email" "email" -- title, placeholder
|
||||||
(HandleAddUserInput <<< ADDUSER_INP_email) -- action
|
(HandleAddUserInput <<< ADDUSER_INP_email) -- action
|
||||||
addUserForm.email -- value
|
addUserForm.email -- value
|
||||||
|
@ -152,15 +152,14 @@ render {
|
||||||
addUserForm.pass -- value
|
addUserForm.pass -- value
|
||||||
true -- validity (TODO)
|
true -- validity (TODO)
|
||||||
should_be_disabled -- condition
|
should_be_disabled -- condition
|
||||||
, HH.div_
|
, HH.button
|
||||||
[ HH.button
|
|
||||||
[ HP.style "padding: 0.5rem 1.25rem;"
|
[ HP.style "padding: 0.5rem 1.25rem;"
|
||||||
, HP.type_ HP.ButtonSubmit
|
, HP.type_ HP.ButtonSubmit
|
||||||
|
, HE.onClick \ _ -> AddUserAttempt
|
||||||
, maybe (HP.disabled true) (\_ -> HP.enabled true) wsInfo.connection
|
, maybe (HP.disabled true) (\_ -> HP.enabled true) wsInfo.connection
|
||||||
]
|
]
|
||||||
[ HH.text "Send Message to Server" ]
|
[ HH.text "Send Message to Server" ]
|
||||||
]
|
]
|
||||||
]
|
|
||||||
|
|
||||||
render_messages = HH.ul_ $ map (\msg -> HH.li_ [ HH.text msg ]) messages
|
render_messages = HH.ul_ $ map (\msg -> HH.li_ [ HH.text msg ]) messages
|
||||||
|
|
||||||
|
@ -215,9 +214,9 @@ handleAction = case _ of
|
||||||
ADDUSER_toggle_admin -> H.modify_ _ { addUserForm { admin = not addUserForm.admin } }
|
ADDUSER_toggle_admin -> H.modify_ _ { addUserForm { admin = not addUserForm.admin } }
|
||||||
ADDUSER_INP_pass v -> H.modify_ _ { addUserForm { pass = v } }
|
ADDUSER_INP_pass v -> H.modify_ _ { addUserForm { pass = v } }
|
||||||
|
|
||||||
AddUserAttempt ev -> do
|
PreventSubmit ev -> H.liftEffect $ Event.preventDefault ev
|
||||||
H.liftEffect $ Event.preventDefault ev
|
|
||||||
|
|
||||||
|
AddUserAttempt -> do
|
||||||
{ wsInfo, addUserForm } <- H.get
|
{ wsInfo, addUserForm } <- H.get
|
||||||
let login = addUserForm.login
|
let login = addUserForm.login
|
||||||
email = addUserForm.email
|
email = addUserForm.email
|
||||||
|
|
Loading…
Reference in New Issue