Coding style corrections.
This commit is contained in:
parent
ed4ac04c28
commit
afe576a557
@ -80,73 +80,73 @@ initialState _ =
|
||||
}
|
||||
|
||||
render :: forall m. State -> H.ComponentHTML Action () m
|
||||
render { wsUp,
|
||||
authenticationForm,
|
||||
registrationForm }
|
||||
= HH.div_
|
||||
[ Bulma.columns_ [ Bulma.column_ auth_form, Bulma.column_ register_form ]
|
||||
]
|
||||
where
|
||||
render { wsUp, authenticationForm, registrationForm }
|
||||
= Bulma.section_small
|
||||
[ case wsUp of
|
||||
false -> Bulma.p "You are disconnected."
|
||||
true -> Bulma.columns_ [ Bulma.column_ auth_form, Bulma.column_ register_form ]
|
||||
]
|
||||
where
|
||||
|
||||
auth_form
|
||||
= [ Bulma.h3 "Authentication"
|
||||
, render_auth_form
|
||||
]
|
||||
|
||||
register_form
|
||||
= [ Bulma.h3 "Register!"
|
||||
, render_register_form
|
||||
]
|
||||
|
||||
should_be_disabled = (if wsUp then (HP.enabled true) else (HP.disabled true))
|
||||
|
||||
render_auth_form = HH.form
|
||||
[ HE.onSubmit AuthenticationAttempt ]
|
||||
[ Bulma.box_input "Login" "login" -- title, placeholder
|
||||
(HandleAuthenticationInput <<< AUTH_INP_login) -- action
|
||||
authenticationForm.login -- value
|
||||
true -- validity (TODO)
|
||||
should_be_disabled -- condition
|
||||
, Bulma.box_password "Password" "password" -- title, placeholder
|
||||
(HandleAuthenticationInput <<< AUTH_INP_pass) -- action
|
||||
authenticationForm.pass -- value
|
||||
true -- validity (TODO)
|
||||
should_be_disabled -- condition
|
||||
, HH.button
|
||||
[ HP.style "padding: 0.5rem 1.25rem;"
|
||||
, HP.type_ HP.ButtonSubmit
|
||||
, (if wsUp then (HP.enabled true) else (HP.disabled true))
|
||||
]
|
||||
[ HH.text "Send Message to Server" ]
|
||||
auth_form
|
||||
= [ Bulma.h3 "Authentication"
|
||||
, render_auth_form
|
||||
]
|
||||
|
||||
render_register_form = HH.form
|
||||
[ HE.onSubmit RegisterAttempt ]
|
||||
[ Bulma.box_input "Login" "login" -- title, placeholder
|
||||
(HandleRegisterInput <<< REG_INP_login) -- action
|
||||
registrationForm.login -- value
|
||||
true -- validity (TODO)
|
||||
should_be_disabled -- condition
|
||||
, Bulma.box_input "Email" "email@example.com" -- title, placeholder
|
||||
(HandleRegisterInput <<< REG_INP_email) -- action
|
||||
registrationForm.email -- value
|
||||
true -- validity (TODO)
|
||||
should_be_disabled -- condition
|
||||
, Bulma.box_password "Password" "password" -- title, placeholder
|
||||
(HandleRegisterInput <<< REG_INP_pass) -- action
|
||||
registrationForm.pass -- value
|
||||
true -- validity (TODO)
|
||||
should_be_disabled -- condition
|
||||
, HH.div_
|
||||
[ HH.button
|
||||
[ HP.style "padding: 0.5rem 1.25rem;"
|
||||
, HP.type_ HP.ButtonSubmit
|
||||
, (if wsUp then (HP.enabled true) else (HP.disabled true))
|
||||
]
|
||||
[ HH.text "Send Message to Server" ]
|
||||
]
|
||||
register_form
|
||||
= [ Bulma.h3 "Register!"
|
||||
, render_register_form
|
||||
]
|
||||
|
||||
should_be_disabled = (if wsUp then (HP.enabled true) else (HP.disabled true))
|
||||
|
||||
render_auth_form = HH.form
|
||||
[ HE.onSubmit AuthenticationAttempt ]
|
||||
[ Bulma.box_input "Login" "login" -- title, placeholder
|
||||
(HandleAuthenticationInput <<< AUTH_INP_login) -- action
|
||||
authenticationForm.login -- value
|
||||
true -- validity (TODO)
|
||||
should_be_disabled -- condition
|
||||
, Bulma.box_password "Password" "password" -- title, placeholder
|
||||
(HandleAuthenticationInput <<< AUTH_INP_pass) -- action
|
||||
authenticationForm.pass -- value
|
||||
true -- validity (TODO)
|
||||
should_be_disabled -- condition
|
||||
, HH.button
|
||||
[ HP.style "padding: 0.5rem 1.25rem;"
|
||||
, HP.type_ HP.ButtonSubmit
|
||||
, (if wsUp then (HP.enabled true) else (HP.disabled true))
|
||||
]
|
||||
[ HH.text "Send Message to Server" ]
|
||||
]
|
||||
|
||||
render_register_form = HH.form
|
||||
[ HE.onSubmit RegisterAttempt ]
|
||||
[ Bulma.box_input "Login" "login" -- title, placeholder
|
||||
(HandleRegisterInput <<< REG_INP_login) -- action
|
||||
registrationForm.login -- value
|
||||
true -- validity (TODO)
|
||||
should_be_disabled -- condition
|
||||
, Bulma.box_input "Email" "email@example.com" -- title, placeholder
|
||||
(HandleRegisterInput <<< REG_INP_email) -- action
|
||||
registrationForm.email -- value
|
||||
true -- validity (TODO)
|
||||
should_be_disabled -- condition
|
||||
, Bulma.box_password "Password" "password" -- title, placeholder
|
||||
(HandleRegisterInput <<< REG_INP_pass) -- action
|
||||
registrationForm.pass -- value
|
||||
true -- validity (TODO)
|
||||
should_be_disabled -- condition
|
||||
, HH.div_
|
||||
[ HH.button
|
||||
[ HP.style "padding: 0.5rem 1.25rem;"
|
||||
, HP.type_ HP.ButtonSubmit
|
||||
, (if wsUp then (HP.enabled true) else (HP.disabled true))
|
||||
]
|
||||
[ HH.text "Send Message to Server" ]
|
||||
]
|
||||
]
|
||||
|
||||
handleAction :: forall m. MonadAff m => Action -> H.HalogenM State Action () Output m Unit
|
||||
handleAction = case _ of
|
||||
HandleAuthenticationInput authinp -> do
|
||||
|
@ -104,48 +104,50 @@ initialState token =
|
||||
|
||||
render :: forall m. State -> H.ComponentHTML Action () m
|
||||
render { accepted_domains, my_domains, newDomainForm, wsUp }
|
||||
= Bulma.section_medium
|
||||
[ Bulma.columns_ [ Bulma.column_ newdomain_form, Bulma.column_ list_of_own_domains ]
|
||||
]
|
||||
where
|
||||
= Bulma.section_small
|
||||
[ case wsUp of
|
||||
false -> Bulma.p "You are disconnected."
|
||||
true -> Bulma.columns_ [ Bulma.column_ newdomain_form, Bulma.column_ list_of_own_domains ]
|
||||
]
|
||||
where
|
||||
|
||||
newdomain_form
|
||||
= [ Bulma.h3 "Add a domain!"
|
||||
, render_adduser_form
|
||||
]
|
||||
|
||||
list_of_own_domains
|
||||
= [ Bulma.h3 "My domains"
|
||||
, HH.ul_ $ map (\domain -> HH.li_ (domain_buttons domain)) my_domains
|
||||
]
|
||||
|
||||
domain_buttons domain
|
||||
= [ HH.button
|
||||
[ HP.type_ HP.ButtonSubmit
|
||||
, HE.onClick \_ -> RemoveDomain domain
|
||||
, HP.classes CSSClasses.button
|
||||
]
|
||||
[ HH.text "x" ]
|
||||
, HH.button
|
||||
[ HP.type_ HP.ButtonSubmit
|
||||
, HE.onClick \_ -> EnterDomain domain
|
||||
, HP.classes CSSClasses.button
|
||||
]
|
||||
[ HH.text domain ]
|
||||
]
|
||||
|
||||
render_adduser_form = HH.form
|
||||
[ HE.onSubmit NewDomainAttempt ]
|
||||
[ Bulma.new_domain_field
|
||||
(HandleNewDomainInput <<< INP_newdomain)
|
||||
newDomainForm.new_domain
|
||||
[ HHE.onSelectedIndexChange domain_choice ]
|
||||
accepted_domains
|
||||
newdomain_form
|
||||
= [ Bulma.h3 "Add a domain!"
|
||||
, render_adduser_form
|
||||
]
|
||||
|
||||
domain_choice :: Int -> Action
|
||||
domain_choice i
|
||||
= HandleNewDomainInput <<< UpdateSelectedDomain $ maybe default_domain (\x -> x) $ accepted_domains A.!! i
|
||||
list_of_own_domains
|
||||
= [ Bulma.h3 "My domains"
|
||||
, HH.ul_ $ map (\domain -> HH.li_ (domain_buttons domain)) my_domains
|
||||
]
|
||||
|
||||
domain_buttons domain
|
||||
= [ HH.button
|
||||
[ HP.type_ HP.ButtonSubmit
|
||||
, HE.onClick \_ -> RemoveDomain domain
|
||||
, HP.classes CSSClasses.button
|
||||
]
|
||||
[ HH.text "x" ]
|
||||
, HH.button
|
||||
[ HP.type_ HP.ButtonSubmit
|
||||
, HE.onClick \_ -> EnterDomain domain
|
||||
, HP.classes CSSClasses.button
|
||||
]
|
||||
[ HH.text domain ]
|
||||
]
|
||||
|
||||
render_adduser_form = HH.form
|
||||
[ HE.onSubmit NewDomainAttempt ]
|
||||
[ Bulma.new_domain_field
|
||||
(HandleNewDomainInput <<< INP_newdomain)
|
||||
newDomainForm.new_domain
|
||||
[ HHE.onSelectedIndexChange domain_choice ]
|
||||
accepted_domains
|
||||
]
|
||||
|
||||
domain_choice :: Int -> Action
|
||||
domain_choice i
|
||||
= HandleNewDomainInput <<< UpdateSelectedDomain $ maybe default_domain (\x -> x) $ accepted_domains A.!! i
|
||||
|
||||
handleAction :: forall m. MonadAff m => Action -> H.HalogenM State Action () Output m Unit
|
||||
handleAction = case _ of
|
||||
|
@ -319,6 +319,9 @@ box_password :: forall w i.
|
||||
String -> String -> (String -> i) -> String -> Boolean -> (HP.IProp DHI.HTMLinput i) -> HH.HTML w i
|
||||
box_password = field_inner true
|
||||
|
||||
section_small :: forall w i. Array (HH.HTML w i) -> HH.HTML w i
|
||||
section_small = HH.section [ HP.classes (C.section <> C.is_small) ]
|
||||
|
||||
section_medium :: forall w i. Array (HH.HTML w i) -> HH.HTML w i
|
||||
section_medium = HH.section [ HP.classes (C.section <> C.medium) ]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user