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