From 0ab978e2317f0163ac9539de574563940696565d Mon Sep 17 00:00:00 2001 From: Philippe Pittoli Date: Sat, 16 Nov 2024 17:15:05 +0100 Subject: [PATCH] Specific input functions. --- src/App/Page/Authentication.purs | 37 ++++--------- src/App/Page/MailValidation.purs | 19 ++----- src/App/Page/Registration.purs | 18 ++----- src/Bulma.purs | 89 ++++++++++++++++++++++++++++++-- src/MissingHTMLProperties.purs | 6 --- 5 files changed, 105 insertions(+), 64 deletions(-) diff --git a/src/App/Page/Authentication.purs b/src/App/Page/Authentication.purs index 393dd95..faedb01 100644 --- a/src/App/Page/Authentication.purs +++ b/src/App/Page/Authentication.purs @@ -158,7 +158,7 @@ render { current_tab, authenticationForm, passwordRecoveryForm, newPasswordForm, show_error :: Error -> String show_error = case _ of - Login arr -> "Error with the login: " <> (A.fold $ map show_error_login arr) + Login arr -> "Error with the login: " <> (A.fold $ map show_error_login arr) Email arr -> "Error with the email: " <> (A.fold $ map show_error_email arr) Password arr -> "Error with the password: " <> (A.fold $ map show_error_password arr) @@ -221,41 +221,26 @@ render { current_tab, authenticationForm, passwordRecoveryForm, newPasswordForm, render_auth_form = HH.form [ HE.onSubmit AuthenticationAttempt ] - [ Bulma.box_input "loginLOGIN" "Login" "login" -- title, placeholder - (HandleAuthenticationInput <<< AUTH_INP_login) -- action - authenticationForm.login -- value - , Bulma.box_password "passwordLOGIN" "Password" "password" -- title, placeholder - (HandleAuthenticationInput <<< AUTH_INP_pass) -- action - authenticationForm.pass -- value + [ Bulma.username_input "Username" authenticationForm.login (HandleAuthenticationInput <<< AUTH_INP_login) + , Bulma.password_input "Password" authenticationForm.pass (HandleAuthenticationInput <<< AUTH_INP_pass) , Bulma.btn_validation - ] render_password_recovery_form = HH.form [ HE.onSubmit PasswordRecoveryAttempt ] - [ Bulma.box_input "loginPASSR" "Login" "login" -- title, placeholder - (HandlePasswordRecovery <<< PASSR_INP_login) -- action - passwordRecoveryForm.login -- value - , Bulma.box_input "emailPASSR" "Email" "email" -- title, placeholder - (HandlePasswordRecovery <<< PASSR_INP_email) -- action - passwordRecoveryForm.email -- value + [ Bulma.username_input "Username" passwordRecoveryForm.login (HandlePasswordRecovery <<< PASSR_INP_login) + , Bulma.email_input "Email" passwordRecoveryForm.email (HandlePasswordRecovery <<< PASSR_INP_email) , Bulma.btn_validation ] render_new_password_form = HH.form [ HE.onSubmit NewPasswordAttempt ] - [ Bulma.box_input "loginNEWPASS" "Login" "login" - (HandleNewPassword <<< NEWPASS_INP_login) - newPasswordForm.login - , Bulma.box_input "tokenNEWPASS" "Token" "token" - (HandleNewPassword <<< NEWPASS_INP_token) - newPasswordForm.token - , Bulma.box_password "passwordNEWPASS" "Password" "password" - (HandleNewPassword <<< NEWPASS_INP_password) - newPasswordForm.password - , Bulma.box_password "confirmationNEWPASS" "Confirmation" "confirmation" - (HandleNewPassword <<< NEWPASS_INP_confirmation) - newPasswordForm.confirmation + [ Bulma.username_input "Username" newPasswordForm.login (HandleNewPassword <<< NEWPASS_INP_login) + , Bulma.token_input "Token" newPasswordForm.token (HandleNewPassword <<< NEWPASS_INP_token) + , Bulma.password_input_new "Password" newPasswordForm.password (HandleNewPassword <<< NEWPASS_INP_password) + + , Bulma.password_input_confirmation "Confirmation" newPasswordForm.confirmation + (HandleNewPassword <<< NEWPASS_INP_confirmation) , Bulma.btn_validation ] diff --git a/src/App/Page/MailValidation.purs b/src/App/Page/MailValidation.purs index 7d2427d..15c636d 100644 --- a/src/App/Page/MailValidation.purs +++ b/src/App/Page/MailValidation.purs @@ -88,20 +88,14 @@ render { mailValidationForm } b e = Bulma.column_ [ Bulma.box e ] mail_validation_form = [ Bulma.h3 "Verify your account" - , Bulma.div_content [] [Bulma.explanation [Bulma.p """ - Email addresses must be validated within 2 days. - """]] + , Bulma.div_content [] [Bulma.explanation [Bulma.p "Email addresses must be validated within 30 minutes."]] , render_register_form ] render_register_form = HH.form [ HE.onSubmit ValidateInputs ] - [ Bulma.box_input "loginValidation" "Login" "login" -- title, placeholder - (HandleValidationInput <<< VALIDATION_INP_login) -- action - mailValidationForm.login -- value - , Bulma.box_input "tokenValidation" "Token" "token" -- title, placeholder - (HandleValidationInput <<< VALIDATION_INP_token) -- action - mailValidationForm.token -- value + [ Bulma.username_input "Username" mailValidationForm.login (HandleValidationInput <<< VALIDATION_INP_login) + , Bulma.token_input "Token" mailValidationForm.token (HandleValidationInput <<< VALIDATION_INP_token) , Bulma.btn_validation ] @@ -121,11 +115,8 @@ handleAction = case _ of let { login, token } = mailValidationForm case login, token of - "", _ -> - H.raise $ Log $ UnableToSend "Please, write your login." - - _, "" -> - H.raise $ Log $ UnableToSend "Please, write your token." + "", _ -> H.raise $ Log $ UnableToSend "Please, write your login." + _, "" -> H.raise $ Log $ UnableToSend "Please, write your token." _, _ -> do case L.login login, T.token token of diff --git a/src/App/Page/Registration.purs b/src/App/Page/Registration.purs index fca82dc..16d6df6 100644 --- a/src/App/Page/Registration.purs +++ b/src/App/Page/Registration.purs @@ -104,24 +104,20 @@ render { registrationForm } render_register_form = HH.form [ HE.onSubmit ValidateInputs ] - (login_input <> login_error <> + (username_input <> username_error <> email_input <> email_error <> password_input <> password_error <> legal_mentions <> validation_btn) - login_input = [ Bulma.login_input "Login" registrationForm.login (HandleRegisterInput <<< REG_INP_login) ] + username_input = [ Bulma.username_input "Username" registrationForm.login (HandleRegisterInput <<< REG_INP_login) ] - login_error + username_error = case between 0 1 (S.length registrationForm.login), L.login registrationForm.login of true, _ -> [] _, Left errors -> [ Bulma.error_box "loginREGISTER" "Login error" (show_error $ Login errors) ] _, Right _ -> [] - email_input - = [ Bulma.box_input "emailREGISTER" "Email" "email@example.com" -- title, placeholder - (HandleRegisterInput <<< REG_INP_email) -- action - registrationForm.email -- value - ] + email_input = [ Bulma.email_input "Email" registrationForm.email (HandleRegisterInput <<< REG_INP_email) ] email_error = case between 0 5 (S.length registrationForm.email), E.email registrationForm.email of @@ -129,11 +125,7 @@ render { registrationForm } _, Left errors -> [ Bulma.error_box "emailREGISTER" "Email error" (show_error $ Email errors) ] _, Right _ -> [] - password_input - = [ Bulma.box_password "passwordREGISTER" "Password" "password" -- title, placeholder - (HandleRegisterInput <<< REG_INP_pass) -- action - registrationForm.pass -- value - ] + password_input = [ Bulma.password_input "Password" registrationForm.pass (HandleRegisterInput <<< REG_INP_pass) ] password_error = case between 0 15 (S.length registrationForm.pass), P.password registrationForm.pass of diff --git a/src/Bulma.purs b/src/Bulma.purs index c3eebf4..d8c7a35 100644 --- a/src/Bulma.purs +++ b/src/Bulma.purs @@ -8,7 +8,6 @@ import Halogen.HTML as HH import DOM.HTML.Indexed as DHI import Halogen.HTML.Properties as HP import Halogen.HTML.Events as HE -import MissingHTMLProperties as MissingProperties import DOM.HTML.Indexed.AutocompleteType (AutocompleteType(..)) import CSSClasses as C @@ -20,7 +19,7 @@ import Halogen.HTML.Core (AttrName(..)) checkbox :: forall w i. Array (HH.HTML w i) -> i -> HH.HTML w i checkbox content_ action = HH.label - [ HP.classes [C.label] ] $ [ HH.input [ HE.onValueInput \ _ -> action, MissingProperties.ty "checkbox" ] ] <> content_ + [ HP.classes [C.label] ] $ [ HH.input [ HE.onValueInput \ _ -> action, HP.type_ HP.InputCheckbox ] ] <> content_ --