mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-12-25 04:43:03 +03:00
Update pokdedex example.
This commit is contained in:
parent
156425b8df
commit
b8a95ca88d
@ -16,14 +16,11 @@ type Effect msg
|
||||
| Batch (List (Effect msg))
|
||||
| GetStargazers (Result Http.Error Int -> msg)
|
||||
| FetchRouteData
|
||||
{ body : Maybe { contentType : String, body : String }
|
||||
, path : Maybe String
|
||||
{ data : Maybe FormDecoder.FormData
|
||||
, toMsg : Result Http.Error Url -> msg
|
||||
}
|
||||
| Submit
|
||||
{ values : FormDecoder.FormData
|
||||
, path : Maybe (List String)
|
||||
, method : Maybe String
|
||||
, toMsg : Result Http.Error Url -> msg
|
||||
}
|
||||
| SubmitFetcher (Pages.Fetcher.Fetcher msg)
|
||||
@ -67,16 +64,13 @@ map fn effect =
|
||||
|
||||
FetchRouteData fetchInfo ->
|
||||
FetchRouteData
|
||||
{ body = fetchInfo.body
|
||||
, path = fetchInfo.path
|
||||
{ data = fetchInfo.data
|
||||
, toMsg = fetchInfo.toMsg >> fn
|
||||
}
|
||||
|
||||
Submit fetchInfo ->
|
||||
Submit
|
||||
{ values = fetchInfo.values
|
||||
, path = fetchInfo.path
|
||||
, method = fetchInfo.method
|
||||
, toMsg = fetchInfo.toMsg >> fn
|
||||
}
|
||||
|
||||
@ -88,16 +82,12 @@ map fn effect =
|
||||
|
||||
perform :
|
||||
{ fetchRouteData :
|
||||
{ body : Maybe { contentType : String, body : String }
|
||||
, path : Maybe String
|
||||
{ data : Maybe FormDecoder.FormData
|
||||
, toMsg : Result Http.Error Url -> pageMsg
|
||||
}
|
||||
-> Cmd msg
|
||||
, submit :
|
||||
{ values : FormDecoder.FormData
|
||||
, encType : Maybe String
|
||||
, method : Maybe String
|
||||
, path : Maybe String
|
||||
, toMsg : Result Http.Error Url -> pageMsg
|
||||
}
|
||||
-> Cmd msg
|
||||
@ -129,19 +119,10 @@ perform ({ fromPageMsg, key } as helpers) effect =
|
||||
|
||||
FetchRouteData fetchInfo ->
|
||||
helpers.fetchRouteData
|
||||
{ body = fetchInfo.body
|
||||
, path = fetchInfo.path
|
||||
, toMsg = fetchInfo.toMsg
|
||||
}
|
||||
fetchInfo
|
||||
|
||||
Submit record ->
|
||||
helpers.submit
|
||||
{ values = record.values
|
||||
, path = Nothing --fetchInfo.path
|
||||
, method = record.method
|
||||
, encType = Nothing -- TODO
|
||||
, toMsg = record.toMsg
|
||||
}
|
||||
helpers.submit record
|
||||
|
||||
SubmitFetcher record ->
|
||||
helpers.runFetcher record
|
||||
|
@ -412,7 +412,7 @@ isAtLeast atLeastStatus currentStatus =
|
||||
|
||||
{-| -}
|
||||
update :
|
||||
({ values : FormDecoder.FormData, path : Maybe (List String), method : Maybe String, toMsg : Result Http.Error Url -> msg } -> effect)
|
||||
({ values : FormDecoder.FormData, toMsg : Result Http.Error Url -> msg } -> effect)
|
||||
-> effect
|
||||
-> (Msg -> msg)
|
||||
-> Form msg String value view
|
||||
@ -516,11 +516,7 @@ update submitEffect noEffect toMsg ((Form _ _ _ modelToValue config) as form) ms
|
||||
else
|
||||
( { model | isSubmitting = Submitting }
|
||||
, submitEffect
|
||||
{ values = values -- TODO should this use FormDecoder.FormData directly to get the method and action url?
|
||||
|
||||
-- TODO what to do if it's an external URL?
|
||||
, path = config.url |> Maybe.map Path.fromString |> Maybe.map Path.toSegments
|
||||
, method = config.method
|
||||
{ values = values
|
||||
, toMsg = GotFormResponse >> toMsg
|
||||
}
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user