Rename variant.

This commit is contained in:
Dillon Kearns 2022-07-24 20:25:04 +02:00
parent 1a8e8e4886
commit 9a353066af

View File

@ -130,7 +130,7 @@ type alias Context error data =
{-| -} {-| -}
init : parsedAndView -> Form String parsedAndView data init : parsedAndView -> Form String parsedAndView data
init parsedAndView = init parsedAndView =
FormNew [] Form []
(\_ _ -> (\_ _ ->
{ result = Dict.empty { result = Dict.empty
, parsedAndView = parsedAndView , parsedAndView = parsedAndView
@ -167,7 +167,7 @@ dynamic :
parsedAndView parsedAndView
data data
dynamic forms formBuilder = dynamic forms formBuilder =
FormNew [] Form []
(\maybeData formState -> (\maybeData formState ->
let let
toParser : toParser :
@ -179,7 +179,7 @@ dynamic forms formBuilder =
} }
toParser decider = toParser decider =
case forms decider of case forms decider of
FormNew _ parseFn _ -> Form _ parseFn _ ->
-- TODO need to include hidden form fields from `definitions` (should they be automatically rendered? Does that mean the view type needs to be hardcoded?) -- TODO need to include hidden form fields from `definitions` (should they be automatically rendered? Does that mean the view type needs to be hardcoded?)
parseFn maybeData formState parseFn maybeData formState
@ -197,7 +197,7 @@ dynamic forms formBuilder =
} }
newThing = newThing =
case formBuilder of case formBuilder of
FormNew _ parseFn _ -> Form _ parseFn _ ->
parseFn maybeData formState parseFn maybeData formState
arg : { combine : decider -> AnyValidation error parsed named constraints1, view : decider -> subView } arg : { combine : decider -> AnyValidation error parsed named constraints1, view : decider -> subView }
@ -314,8 +314,8 @@ field :
-> Field error parsed data kind constraints -> Field error parsed data kind constraints
-> Form error (FieldValidation error parsed kind -> parsedAndView) data -> Form error (FieldValidation error parsed kind -> parsedAndView) data
-> Form error parsedAndView data -> Form error parsedAndView data
field name (Field fieldParser kind) (FormNew definitions parseFn toInitialValues) = field name (Field fieldParser kind) (Form definitions parseFn toInitialValues) =
FormNew Form
(( name, RegularField ) (( name, RegularField )
:: definitions :: definitions
) )
@ -396,8 +396,8 @@ hiddenField :
-> Field error parsed data kind constraints -> Field error parsed data kind constraints
-> Form error (FieldValidation error parsed Form.FieldView.Hidden -> parsedAndView) data -> Form error (FieldValidation error parsed Form.FieldView.Hidden -> parsedAndView) data
-> Form error parsedAndView data -> Form error parsedAndView data
hiddenField name (Field fieldParser _) (FormNew definitions parseFn toInitialValues) = hiddenField name (Field fieldParser _) (Form definitions parseFn toInitialValues) =
FormNew Form
(( name, HiddenField ) (( name, HiddenField )
:: definitions :: definitions
) )
@ -478,12 +478,12 @@ hiddenKind :
-> error -> error
-> Form error parsedAndView data -> Form error parsedAndView data
-> Form error parsedAndView data -> Form error parsedAndView data
hiddenKind ( name, value ) error_ (FormNew definitions parseFn toInitialValues) = hiddenKind ( name, value ) error_ (Form definitions parseFn toInitialValues) =
let let
(Field fieldParser _) = (Field fieldParser _) =
Field.exactValue value error_ Field.exactValue value error_
in in
FormNew Form
(( name, HiddenField ) (( name, HiddenField )
:: definitions :: definitions
) )
@ -670,7 +670,7 @@ parse :
-> data -> data
-> Form error { info | combine : AnyValidation error parsed named constraints } data -> Form error { info | combine : AnyValidation error parsed named constraints } data
-> ( Maybe parsed, FieldErrors error ) -> ( Maybe parsed, FieldErrors error )
parse formId app data (FormNew _ parser _) = parse formId app data (Form _ parser _) =
-- TODO Get transition context from `app` so you can check if the current form is being submitted -- TODO Get transition context from `app` so you can check if the current form is being submitted
-- TODO either as a transition or a fetcher? Should be easy enough to check for the `id` on either of those? -- TODO either as a transition or a fetcher? Should be easy enough to check for the `id` on either of those?
let let
@ -710,7 +710,7 @@ runServerSide :
List ( String, String ) List ( String, String )
-> Form error { all | combine : AnyValidation error parsed kind constraints } data -> Form error { all | combine : AnyValidation error parsed kind constraints } data
-> ( Maybe parsed, DataSource (FieldErrors error) ) -> ( Maybe parsed, DataSource (FieldErrors error) )
runServerSide rawFormData (FormNew _ parser _) = runServerSide rawFormData (Form _ parser _) =
let let
parsed : parsed :
{ result : Dict String (List error) { result : Dict String (List error)
@ -747,7 +747,7 @@ runServerSideWithoutServerValidations :
List ( String, String ) List ( String, String )
-> Form error { all | combine : AnyValidation error parsed kind constraints } data -> Form error { all | combine : AnyValidation error parsed kind constraints } data
-> ( Maybe parsed, FieldErrors error ) -> ( Maybe parsed, FieldErrors error )
runServerSideWithoutServerValidations rawFormData (FormNew _ parser _) = runServerSideWithoutServerValidations rawFormData (Form _ parser _) =
let let
parsed : parsed :
{ result : Dict String (List error) { result : Dict String (List error)
@ -927,7 +927,7 @@ toDynamicFetcher :
(AnyValidation error parsed field constraints) (AnyValidation error parsed field constraints)
data data
(Context error data -> view) (Context error data -> view)
toDynamicFetcher name (FormNew a b c) = toDynamicFetcher name (Form a b c) =
let let
options = options =
{ submitStrategy = FetcherStrategy { submitStrategy = FetcherStrategy
@ -997,7 +997,7 @@ toDynamicTransition :
(AnyValidation error parsed field constraints) (AnyValidation error parsed field constraints)
data data
(Context error data -> view) (Context error data -> view)
toDynamicTransition name (FormNew a b c) = toDynamicTransition name (Form a b c) =
let let
options = options =
{ submitStrategy = TransitionStrategy { submitStrategy = TransitionStrategy
@ -1381,7 +1381,7 @@ type FormInternal error parsed data view
{-| -} {-| -}
type Form error parsedAndView data type Form error parsedAndView data
= FormNew = Form
(List ( String, FieldDefinition )) (List ( String, FieldDefinition ))
(Maybe data (Maybe data
-> Form.FormState -> Form.FormState