mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-11-27 01:12:50 +03:00
Make transition strategy the default and move formId argument to rendering.
This commit is contained in:
parent
a8b8e7421d
commit
f4cf8a7069
@ -188,8 +188,7 @@ createFile { moduleName, fields } =
|
||||
Just justFormHelp ->
|
||||
[ Html.h2 [] [ Html.text "Form" ]
|
||||
, justFormHelp.form
|
||||
|> Form.toDynamicTransition "form"
|
||||
|> Form.renderHtml [] (Elm.get "errors" >> Elm.just) app Elm.unit
|
||||
|> Form.renderHtml "form" [] (Elm.get "errors" >> Elm.just) app Elm.unit
|
||||
]
|
||||
|
||||
Nothing ->
|
||||
@ -266,8 +265,8 @@ errorsView =
|
||||
(Type.namedWith [ "Html" ]
|
||||
"Html"
|
||||
[ Type.namedWith
|
||||
[ "Pages", "Msg" ]
|
||||
"Msg"
|
||||
[ "PagesMsg" ]
|
||||
"PagesMsg"
|
||||
[ Type.named [] "Msg" ]
|
||||
]
|
||||
)
|
||||
|
@ -215,8 +215,8 @@ view app shared model =
|
||||
)
|
||||
]
|
||||
[ form
|
||||
|> Form.toDynamicFetcher "dark-mode"
|
||||
|> Form.renderStyledHtml [] (.formResponse >> Just) app app.data.isDarkMode
|
||||
|> Form.toDynamicFetcher
|
||||
|> Form.renderStyledHtml "dark-mode" [] (.formResponse >> Just) app app.data.isDarkMode
|
||||
, Html.text <|
|
||||
"Current mode: "
|
||||
++ (if app.data.isDarkMode then
|
||||
|
@ -245,8 +245,7 @@ view app shared =
|
||||
[]
|
||||
[ Html.text <| "Edit profile " ++ user.first ++ " " ++ user.last ]
|
||||
, form
|
||||
|> Form.toDynamicTransition "user-form"
|
||||
|> Form.renderHtml
|
||||
|> Form.renderHtml "user-form"
|
||||
[ Attr.style "display" "flex"
|
||||
, Attr.style "flex-direction" "column"
|
||||
, Attr.style "gap" "20px"
|
||||
|
@ -123,9 +123,8 @@ view app shared =
|
||||
{ title = "GET Form Example"
|
||||
, body =
|
||||
[ form
|
||||
|> Form.toDynamicTransition "user-form"
|
||||
|> Form.withGetMethod
|
||||
|> Form.renderHtml
|
||||
|> Form.renderHtml "user-form"
|
||||
[ Attr.style "display" "flex"
|
||||
, Attr.style "flex-direction" "column"
|
||||
, Attr.style "gap" "20px"
|
||||
|
@ -218,8 +218,8 @@ view app shared =
|
||||
)
|
||||
]
|
||||
, form
|
||||
|> Form.toDynamicTransition "form"
|
||||
|> Form.renderStyledHtml []
|
||||
|> Form.renderStyledHtml "form"
|
||||
[]
|
||||
(.errors >> Just)
|
||||
app
|
||||
()
|
||||
|
@ -379,8 +379,7 @@ createFile moduleName fields =
|
||||
Elm.list
|
||||
[ Html.h2 [] [ Html.text "Form" ]
|
||||
, form.call []
|
||||
|> Gen.Form.toDynamicTransition "form"
|
||||
|> Gen.Form.renderStyledHtml [] (Elm.get "errors" >> Elm.just) app Elm.unit
|
||||
|> Gen.Form.renderStyledHtml "form" [] (Elm.get "errors" >> Elm.just) app Elm.unit
|
||||
]
|
||||
}
|
||||
, update =
|
||||
|
@ -261,8 +261,7 @@ view app shared =
|
||||
[]
|
||||
[ Html.text <| "Edit profile " ++ user.first ++ " " ++ user.last ]
|
||||
, form
|
||||
|> Form.toDynamicTransition "test1"
|
||||
|> Form.renderHtml
|
||||
|> Form.renderHtml "test1"
|
||||
[ Attr.style "display" "flex"
|
||||
, Attr.style "flex-direction" "column"
|
||||
, Attr.style "gap" "20px"
|
||||
|
@ -201,9 +201,9 @@ view static sharedModel model =
|
||||
, body =
|
||||
[ Html.h2 [] [ Html.text "Search" ]
|
||||
, form
|
||||
|> Form.toDynamicTransition "test1"
|
||||
|> Form.withGetMethod
|
||||
|> Form.renderHtml []
|
||||
|> Form.renderHtml "test1"
|
||||
[]
|
||||
-- TODO pass in server data
|
||||
(\_ -> Nothing)
|
||||
static
|
||||
|
@ -265,8 +265,8 @@ view app shared model =
|
||||
]
|
||||
, flashView app.data.flashMessage
|
||||
, form
|
||||
|> Form.toDynamicTransition "test1"
|
||||
|> Form.renderHtml []
|
||||
|> Form.renderHtml "test1"
|
||||
[]
|
||||
-- TODO pass in server data
|
||||
(\_ -> Nothing)
|
||||
app
|
||||
|
@ -719,8 +719,9 @@ view app model sharedModel =
|
||||
|> Debug.toString
|
||||
)
|
||||
, form
|
||||
|> Form.toDynamicTransition "test"
|
||||
|> Form.renderStyledHtml []
|
||||
|> Form.toDynamicTransition
|
||||
|> Form.renderStyledHtml "test"
|
||||
[]
|
||||
--app.action
|
||||
-- |> Maybe.andThen .formResponse
|
||||
(\_ -> Nothing)
|
||||
|
@ -126,8 +126,7 @@ view maybeUrl sharedModel model app =
|
||||
{ title = "Create Group"
|
||||
, body =
|
||||
[ postForm
|
||||
|> Form.toDynamicTransition "create-group"
|
||||
|> Form.renderHtml []
|
||||
|> Form.renderHtml "create-group" []
|
||||
-- TODO pass in form response from ActionData
|
||||
Nothing
|
||||
app
|
||||
|
@ -129,8 +129,8 @@ view maybeUrl sharedModel model app =
|
||||
, body =
|
||||
[ Html.h2 [] [ Html.text "Example" ]
|
||||
, dependentParser
|
||||
|> Form.toDynamicTransition "dependent-example"
|
||||
|> Form.renderHtml []
|
||||
|> Form.toDynamicTransition
|
||||
|> Form.renderHtml "dependent-example" []
|
||||
-- TODO pass in form response from ActionData
|
||||
Nothing
|
||||
app
|
||||
|
@ -264,7 +264,6 @@ view maybeUrl sharedModel app =
|
||||
)
|
||||
]
|
||||
, form
|
||||
|> Form.toDynamicTransition "login"
|
||||
|> Form.renderHtml [] app.action app ()
|
||||
|> Form.renderHtml "login" [] app.action app ()
|
||||
]
|
||||
}
|
||||
|
@ -210,8 +210,7 @@ view maybeUrl sharedModel model app =
|
||||
, body =
|
||||
[ Html.h2 [] [ Html.text "New item" ]
|
||||
, form
|
||||
|> Form.toDynamicTransition "form"
|
||||
|> Form.renderHtml
|
||||
|> Form.renderHtml "form"
|
||||
[ Attr.style "display" "flex"
|
||||
, Attr.style "flex-direction" "column"
|
||||
, Attr.style "gap" "20px"
|
||||
|
@ -120,8 +120,7 @@ view maybeUrl sharedModel model app =
|
||||
, body =
|
||||
[ Html.h2 [] [ Html.text "Example" ]
|
||||
, dependentParser
|
||||
|> Form.toDynamicTransition "form"
|
||||
|> Form.renderHtml []
|
||||
|> Form.renderHtml "form" []
|
||||
-- TODO pass in form response from ActionData
|
||||
Nothing
|
||||
app
|
||||
|
@ -279,8 +279,7 @@ view maybeUrl sharedModel model app =
|
||||
_ ->
|
||||
Html.text "No errors"
|
||||
, formParser
|
||||
|> Form.toDynamicTransition "edit-form"
|
||||
|> Form.renderHtml
|
||||
|> Form.renderHtml "edit-form"
|
||||
[ Attr.style "display" "flex"
|
||||
, Attr.style "flex-direction" "column"
|
||||
, Attr.style "gap" "20px"
|
||||
|
@ -340,8 +340,7 @@ view maybeUrl sharedModel model app =
|
||||
, body =
|
||||
[ Html.h2 [] [ Html.text "Update item" ]
|
||||
, form
|
||||
|> Form.toDynamicTransition "form"
|
||||
|> Form.renderHtml
|
||||
|> Form.renderHtml "form"
|
||||
[ Attr.style "display" "flex"
|
||||
, Attr.style "flex-direction" "column"
|
||||
, Attr.style "gap" "20px"
|
||||
@ -354,8 +353,8 @@ view maybeUrl sharedModel model app =
|
||||
|> Maybe.map pendingView
|
||||
|> Maybe.withDefault (Html.div [] [])
|
||||
, deleteForm
|
||||
|> Form.toDynamicTransition "delete-form"
|
||||
|> Form.renderHtml []
|
||||
|> Form.toDynamicTransition
|
||||
|> Form.renderHtml "delete-form" []
|
||||
-- TODO
|
||||
Nothing
|
||||
app
|
||||
|
@ -395,8 +395,9 @@ view app shared =
|
||||
Html.div []
|
||||
[ Html.text <| "Hello! You are already logged in as " ++ username
|
||||
, logoutForm
|
||||
|> Form.toDynamicTransition "logout"
|
||||
|> Form.renderHtml []
|
||||
|> Form.toDynamicTransition
|
||||
|> Form.renderHtml "logout"
|
||||
[]
|
||||
(\_ -> Nothing)
|
||||
app
|
||||
()
|
||||
@ -406,8 +407,7 @@ view app shared =
|
||||
Html.text "You aren't logged in yet."
|
||||
]
|
||||
, form
|
||||
|> Form.toDynamicTransition "login"
|
||||
|> Form.renderHtml [] .maybeError app ()
|
||||
|> Form.renderHtml "login" [] .maybeError app ()
|
||||
]
|
||||
]
|
||||
}
|
||||
|
@ -493,11 +493,11 @@ view app shared model =
|
||||
[ class "todoapp" ]
|
||||
[ addItemForm
|
||||
|> Form.toDynamicFetcher
|
||||
|> Form.withOnSubmit (\_ -> NewItemSubmitted)
|
||||
|> Form.renderHtml
|
||||
("new-item-"
|
||||
++ (model.nextId |> Time.posixToMillis |> String.fromInt)
|
||||
)
|
||||
|> Form.withOnSubmit (\_ -> NewItemSubmitted)
|
||||
|> Form.renderHtml
|
||||
[ class "create-form"
|
||||
, hidden (not (List.isEmpty failedAddItemActions))
|
||||
]
|
||||
@ -509,9 +509,10 @@ view app shared model =
|
||||
|> List.indexedMap
|
||||
(\index ( key, createFetcherErrors ) ->
|
||||
addItemForm
|
||||
|> Form.toDynamicFetcher key
|
||||
|> Form.toDynamicFetcher
|
||||
|> Form.withOnSubmit (\_ -> NewItemSubmitted)
|
||||
|> Form.renderHtml [ class "create-form", hidden (index /= 0) ]
|
||||
|> Form.renderHtml key
|
||||
[ class "create-form", hidden (index /= 0) ]
|
||||
(\_ -> Nothing)
|
||||
app
|
||||
(Just createFetcherErrors)
|
||||
@ -735,8 +736,8 @@ viewEntries app visibility entries =
|
||||
, style "visibility" cssVisibility
|
||||
]
|
||||
[ toggleAllForm
|
||||
|> Form.toDynamicFetcher "toggle-all"
|
||||
|> Form.renderHtml [] (\_ -> Nothing) app { allCompleted = allCompleted }
|
||||
|> Form.toDynamicFetcher
|
||||
|> Form.renderHtml "toggle-all" [] (\_ -> Nothing) app { allCompleted = allCompleted }
|
||||
, Keyed.ul [ class "todo-list" ] <|
|
||||
List.map (viewKeyedEntry app) (List.filter isVisible entries)
|
||||
]
|
||||
@ -761,18 +762,18 @@ viewEntry app todo =
|
||||
[ div
|
||||
[ class "view" ]
|
||||
[ checkItemForm
|
||||
|> Form.toDynamicFetcher ("toggle-" ++ todo.id)
|
||||
|> Form.renderHtml [] (\_ -> Nothing) app todo
|
||||
|> Form.toDynamicFetcher
|
||||
|> Form.renderHtml ("toggle-" ++ todo.id) [] (\_ -> Nothing) app todo
|
||||
, editItemForm
|
||||
|> Form.toDynamicFetcher ("edit-" ++ todo.id)
|
||||
|> Form.renderHtml [] (\_ -> Nothing) app todo
|
||||
|> Form.toDynamicFetcher
|
||||
|> Form.renderHtml ("edit-" ++ todo.id) [] (\_ -> Nothing) app todo
|
||||
, if todo.isSaving then
|
||||
LoadingSpinner.view
|
||||
|
||||
else
|
||||
deleteItemForm
|
||||
|> Form.toDynamicFetcher ("delete-" ++ todo.id)
|
||||
|> Form.renderHtml [] (\_ -> Nothing) app todo
|
||||
|> Form.toDynamicFetcher
|
||||
|> Form.renderHtml ("delete-" ++ todo.id) [] (\_ -> Nothing) app todo
|
||||
]
|
||||
]
|
||||
|
||||
@ -862,8 +863,8 @@ visibilitySwap visibilityParam visibility actualVisibility =
|
||||
viewControlsClear : App Data ActionData RouteParams -> Int -> Html (PagesMsg Msg)
|
||||
viewControlsClear app entriesCompleted =
|
||||
clearCompletedForm
|
||||
|> Form.toDynamicFetcher "clear-completed"
|
||||
|> Form.renderHtml [] (\_ -> Nothing) app { entriesCompleted = entriesCompleted }
|
||||
|> Form.toDynamicFetcher
|
||||
|> Form.renderHtml "clear-completed" [] (\_ -> Nothing) app { entriesCompleted = entriesCompleted }
|
||||
|
||||
|
||||
infoFooter : Html msg
|
||||
|
@ -52,9 +52,8 @@ type alias PagesMsg userMsg =
|
||||
|
||||
-- `Form.renderHtml` gives us `Html (PagesMsg msg)`, so we don't need to wrap its Msg type
|
||||
, logoutForm
|
||||
|> Form.toDynamicTransition "logout"
|
||||
|> Form.withOnSubmit (\_ -> NewItemSubmitted)
|
||||
|> Form.renderHtml [] (\_ -> Nothing) app Nothing
|
||||
|> Form.renderHtml "logout" [] (\_ -> Nothing) app Nothing
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -170,7 +170,7 @@ buildNoState definitions builder_ =
|
||||
ServerRender declarations builder ->
|
||||
userFunction builder.moduleName
|
||||
{ view =
|
||||
\shared _ app ->
|
||||
\app shared _ ->
|
||||
definitions.view
|
||||
{ shared = shared
|
||||
, app = app
|
||||
@ -191,7 +191,7 @@ buildNoState definitions builder_ =
|
||||
PreRender declarations builder ->
|
||||
userFunction builder.moduleName
|
||||
{ view =
|
||||
\shared _ app ->
|
||||
\app shared _ ->
|
||||
definitions.view
|
||||
{ shared = shared
|
||||
, app = app
|
||||
@ -257,7 +257,7 @@ buildWithLocalState definitions builder_ =
|
||||
ServerRender declarations builder ->
|
||||
userFunction builder.moduleName
|
||||
{ view =
|
||||
\shared model app ->
|
||||
\app shared model ->
|
||||
definitions.view
|
||||
{ shared = shared
|
||||
, model = model
|
||||
@ -266,7 +266,7 @@ buildWithLocalState definitions builder_ =
|
||||
, localState =
|
||||
Just
|
||||
{ update =
|
||||
\shared app msg model ->
|
||||
\app shared msg model ->
|
||||
definitions.update
|
||||
{ shared = shared
|
||||
, app = app
|
||||
@ -274,7 +274,7 @@ buildWithLocalState definitions builder_ =
|
||||
, model = model
|
||||
}
|
||||
, init =
|
||||
\shared app ->
|
||||
\app shared ->
|
||||
definitions.init
|
||||
{ shared = shared
|
||||
, app = app
|
||||
@ -304,7 +304,7 @@ buildWithLocalState definitions builder_ =
|
||||
PreRender declarations builder ->
|
||||
userFunction builder.moduleName
|
||||
{ view =
|
||||
\shared model app ->
|
||||
\app shared model ->
|
||||
definitions.view
|
||||
{ shared = shared
|
||||
, model = model
|
||||
@ -313,7 +313,7 @@ buildWithLocalState definitions builder_ =
|
||||
, localState =
|
||||
Just
|
||||
{ update =
|
||||
\shared app msg model ->
|
||||
\app shared msg model ->
|
||||
definitions.update
|
||||
{ shared = shared
|
||||
, app = app
|
||||
@ -321,7 +321,7 @@ buildWithLocalState definitions builder_ =
|
||||
, model = model
|
||||
}
|
||||
, init =
|
||||
\shared app ->
|
||||
\app shared ->
|
||||
definitions.init
|
||||
{ shared = shared
|
||||
, app = app
|
||||
@ -385,7 +385,7 @@ buildWithSharedState definitions builder_ =
|
||||
ServerRender declarations builder ->
|
||||
userFunction builder.moduleName
|
||||
{ view =
|
||||
\shared model app ->
|
||||
\app shared model ->
|
||||
definitions.view
|
||||
{ shared = shared
|
||||
, model = model
|
||||
@ -394,7 +394,7 @@ buildWithSharedState definitions builder_ =
|
||||
, localState =
|
||||
Just
|
||||
{ update =
|
||||
\shared app msg model ->
|
||||
\app shared msg model ->
|
||||
definitions.update
|
||||
{ shared = shared
|
||||
, app = app
|
||||
@ -402,7 +402,7 @@ buildWithSharedState definitions builder_ =
|
||||
, model = model
|
||||
}
|
||||
, init =
|
||||
\shared app ->
|
||||
\app shared ->
|
||||
definitions.init
|
||||
{ shared = shared
|
||||
, app = app
|
||||
@ -432,7 +432,7 @@ buildWithSharedState definitions builder_ =
|
||||
PreRender declarations builder ->
|
||||
userFunction builder.moduleName
|
||||
{ view =
|
||||
\shared model app ->
|
||||
\app shared model ->
|
||||
definitions.view
|
||||
{ shared = shared
|
||||
, model = model
|
||||
@ -441,7 +441,7 @@ buildWithSharedState definitions builder_ =
|
||||
, localState =
|
||||
Just
|
||||
{ update =
|
||||
\shared app msg model ->
|
||||
\app shared msg model ->
|
||||
definitions.update
|
||||
{ shared = shared
|
||||
, app = app
|
||||
@ -449,7 +449,7 @@ buildWithSharedState definitions builder_ =
|
||||
, model = model
|
||||
}
|
||||
, init =
|
||||
\shared app ->
|
||||
\app shared ->
|
||||
definitions.init
|
||||
{ shared = shared
|
||||
, app = app
|
||||
@ -520,13 +520,13 @@ userFunction moduleName definitions =
|
||||
case definitions.localState of
|
||||
Just _ ->
|
||||
Elm.Declare.fn3 "view"
|
||||
( "app", Just appType )
|
||||
( "shared"
|
||||
, Just (Elm.Annotation.named [ "Shared" ] "Model")
|
||||
)
|
||||
( "model", Just (Elm.Annotation.named [] "Model") )
|
||||
( "app", Just appType )
|
||||
(\shared model app ->
|
||||
definitions.view shared model app
|
||||
(\app shared model ->
|
||||
definitions.view app shared model
|
||||
|> Elm.withType
|
||||
(Elm.Annotation.namedWith [ "View" ]
|
||||
"View"
|
||||
@ -547,14 +547,14 @@ userFunction moduleName definitions =
|
||||
}
|
||||
viewDeclaration =
|
||||
Elm.Declare.fn2 "view"
|
||||
( "app", Just appType )
|
||||
( "shared"
|
||||
, Just (Elm.Annotation.named [ "Shared" ] "Model")
|
||||
)
|
||||
( "app", Just appType )
|
||||
(definitions.view Elm.unit)
|
||||
in
|
||||
{ declaration = viewDeclaration.declaration
|
||||
, call = \_ -> viewDeclaration.call
|
||||
, call = \app shared _ -> viewDeclaration.call app shared
|
||||
, callFrom = \a _ c d -> viewDeclaration.callFrom a c d
|
||||
}
|
||||
|
||||
@ -575,17 +575,17 @@ userFunction moduleName definitions =
|
||||
(\localState ->
|
||||
{ updateFn =
|
||||
Elm.Declare.fn4 "update"
|
||||
( "shared", Just (Elm.Annotation.named [ "Shared" ] "Model") )
|
||||
( "app", Just appType )
|
||||
( "shared", Just (Elm.Annotation.named [ "Shared" ] "Model") )
|
||||
( "msg", Just (Elm.Annotation.named [] "Msg") )
|
||||
( "model", Just (Elm.Annotation.named [] "Model") )
|
||||
localState.update
|
||||
, initFn =
|
||||
Elm.Declare.fn2 "init"
|
||||
( "shared", Just (Elm.Annotation.named [ "Shared" ] "Model") )
|
||||
( "app", Just appType )
|
||||
( "shared", Just (Elm.Annotation.named [ "Shared" ] "Model") )
|
||||
(\shared app ->
|
||||
localState.init shared app
|
||||
localState.init app shared
|
||||
|> Elm.withType
|
||||
(Elm.Annotation.tuple
|
||||
(localType "Model")
|
||||
|
Loading…
Reference in New Issue
Block a user