mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-12-23 11:55:41 +03:00
Reorganize modules.
This commit is contained in:
parent
513e58f560
commit
b1cba8ce0e
@ -21,13 +21,14 @@ import Gen.Json.Decode
|
|||||||
import Gen.Json.Encode
|
import Gen.Json.Encode
|
||||||
import Gen.List
|
import Gen.List
|
||||||
import Gen.Maybe
|
import Gen.Maybe
|
||||||
|
import Gen.Pages.ConcurrentSubmission
|
||||||
import Gen.Pages.Fetcher
|
import Gen.Pages.Fetcher
|
||||||
import Gen.Pages.Internal.NotFoundReason
|
import Gen.Pages.Internal.NotFoundReason
|
||||||
import Gen.Pages.Internal.Platform
|
import Gen.Pages.Internal.Platform
|
||||||
import Gen.Pages.Internal.Platform.Cli
|
import Gen.Pages.Internal.Platform.Cli
|
||||||
import Gen.Pages.Internal.RoutePattern
|
import Gen.Pages.Internal.RoutePattern
|
||||||
|
import Gen.Pages.Navigation
|
||||||
import Gen.Pages.PageUrl
|
import Gen.Pages.PageUrl
|
||||||
import Gen.Pages.Transition
|
|
||||||
import Gen.PagesMsg
|
import Gen.PagesMsg
|
||||||
import Gen.Server.Response
|
import Gen.Server.Response
|
||||||
import Gen.String
|
import Gen.String
|
||||||
@ -239,10 +240,10 @@ otherFile routes phaseString =
|
|||||||
[ ( "pageFormState", Type.named [ "Form" ] "Model" |> Just )
|
[ ( "pageFormState", Type.named [ "Form" ] "Model" |> Just )
|
||||||
, ( "concurrentSubmissions"
|
, ( "concurrentSubmissions"
|
||||||
, Gen.Dict.annotation_.dict Type.string
|
, Gen.Dict.annotation_.dict Type.string
|
||||||
(Gen.Pages.Transition.annotation_.fetcherState (Type.named [] "ActionData"))
|
(Gen.Pages.ConcurrentSubmission.annotation_.concurrentSubmission (Type.named [] "ActionData"))
|
||||||
|> Just
|
|> Just
|
||||||
)
|
)
|
||||||
, ( "navigation", Type.named [ "Pages", "Transition" ] "Transition" |> Type.maybe |> Just )
|
, ( "navigation", Type.named [ "Pages", "Navigation" ] "Navigation" |> Type.maybe |> Just )
|
||||||
, ( "page"
|
, ( "page"
|
||||||
, Type.record
|
, Type.record
|
||||||
[ ( "path", Type.named [ "UrlPath" ] "UrlPath" )
|
[ ( "path", Type.named [ "UrlPath" ] "UrlPath" )
|
||||||
@ -381,7 +382,7 @@ otherFile routes phaseString =
|
|||||||
|> Gen.Dict.map
|
|> Gen.Dict.map
|
||||||
(\_ fetcherState ->
|
(\_ fetcherState ->
|
||||||
fetcherState
|
fetcherState
|
||||||
|> Gen.Pages.Transition.map (\ad -> actionDataOrNothing ad)
|
|> Gen.Pages.ConcurrentSubmission.map (\ad -> actionDataOrNothing ad)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
, ( "pageFormState", pageFormState )
|
, ( "pageFormState", pageFormState )
|
||||||
@ -917,10 +918,10 @@ otherFile routes phaseString =
|
|||||||
, ( "concurrentSubmissions"
|
, ( "concurrentSubmissions"
|
||||||
, Gen.Dict.annotation_.dict
|
, Gen.Dict.annotation_.dict
|
||||||
Type.string
|
Type.string
|
||||||
(Gen.Pages.Transition.annotation_.fetcherState (Type.named [] "ActionData"))
|
(Gen.Pages.ConcurrentSubmission.annotation_.concurrentSubmission (Type.named [] "ActionData"))
|
||||||
|> Just
|
|> Just
|
||||||
)
|
)
|
||||||
, ( "navigation", Type.named [ "Pages", "Transition" ] "Transition" |> Type.maybe |> Just )
|
, ( "navigation", Type.named [ "Pages", "Navigation" ] "Navigation" |> Type.maybe |> Just )
|
||||||
, ( "sharedData", Type.named [ "Shared" ] "Data" |> Just )
|
, ( "sharedData", Type.named [ "Shared" ] "Data" |> Just )
|
||||||
, ( "pageData", Type.named [] "PageData" |> Just )
|
, ( "pageData", Type.named [] "PageData" |> Just )
|
||||||
, ( "navigationKey", Type.named [ "Browser", "Navigation" ] "Key" |> Type.maybe |> Just )
|
, ( "navigationKey", Type.named [ "Browser", "Navigation" ] "Key" |> Type.maybe |> Just )
|
||||||
@ -1189,7 +1190,7 @@ otherFile routes phaseString =
|
|||||||
|> Gen.Dict.map
|
|> Gen.Dict.map
|
||||||
(\_ fetcherState ->
|
(\_ fetcherState ->
|
||||||
fetcherState
|
fetcherState
|
||||||
|> Gen.Pages.Transition.map
|
|> Gen.Pages.ConcurrentSubmission.map
|
||||||
(\ad ->
|
(\ad ->
|
||||||
Elm.Case.custom ad
|
Elm.Case.custom ad
|
||||||
Type.unit
|
Type.unit
|
||||||
|
1
elm.json
1
elm.json
@ -31,6 +31,7 @@
|
|||||||
"Pages.Flags",
|
"Pages.Flags",
|
||||||
"Pages.Fetcher",
|
"Pages.Fetcher",
|
||||||
"Pages.Navigation",
|
"Pages.Navigation",
|
||||||
|
"Pages.ConcurrentSubmission",
|
||||||
"Scaffold.Route",
|
"Scaffold.Route",
|
||||||
"Scaffold.Form",
|
"Scaffold.Form",
|
||||||
"Pages.Script",
|
"Pages.Script",
|
||||||
|
@ -17,8 +17,8 @@ import Html.Styled as Html
|
|||||||
import Html.Styled.Attributes as Attr
|
import Html.Styled.Attributes as Attr
|
||||||
import Json.Decode as Decode
|
import Json.Decode as Decode
|
||||||
import Json.Encode as Encode
|
import Json.Encode as Encode
|
||||||
|
import Pages.ConcurrentSubmission
|
||||||
import Pages.Form
|
import Pages.Form
|
||||||
import Pages.Navigation exposing (FetcherSubmitStatus(..))
|
|
||||||
import PagesMsg exposing (PagesMsg)
|
import PagesMsg exposing (PagesMsg)
|
||||||
import Platform.Sub
|
import Platform.Sub
|
||||||
import RouteBuilder
|
import RouteBuilder
|
||||||
@ -205,7 +205,7 @@ view app sharedModel model =
|
|||||||
|> List.filterMap
|
|> List.filterMap
|
||||||
(\{ status, payload } ->
|
(\{ status, payload } ->
|
||||||
case status of
|
case status of
|
||||||
FetcherComplete _ ->
|
Pages.ConcurrentSubmission.Complete _ ->
|
||||||
Nothing
|
Nothing
|
||||||
|
|
||||||
_ ->
|
_ ->
|
||||||
|
@ -477,7 +477,7 @@ view app shared model =
|
|||||||
, status
|
, status
|
||||||
)
|
)
|
||||||
of
|
of
|
||||||
( Form.Valid (Add newItem), Pages.Navigation.FetcherComplete (Just parsedActionData) ) ->
|
( Form.Valid (Add newItem), Pages.ConcurrentSubmission.Complete (Just parsedActionData) ) ->
|
||||||
parsedActionData.errors
|
parsedActionData.errors
|
||||||
|> Maybe.map (Tuple.pair key)
|
|> Maybe.map (Tuple.pair key)
|
||||||
|
|
||||||
|
@ -94,6 +94,7 @@ import Form
|
|||||||
import Head
|
import Head
|
||||||
import Http
|
import Http
|
||||||
import Json.Decode
|
import Json.Decode
|
||||||
|
import Pages.ConcurrentSubmission
|
||||||
import Pages.Fetcher
|
import Pages.Fetcher
|
||||||
import Pages.Internal.NotFoundReason exposing (NotFoundReason)
|
import Pages.Internal.NotFoundReason exposing (NotFoundReason)
|
||||||
import Pages.Internal.RoutePattern exposing (RoutePattern)
|
import Pages.Internal.RoutePattern exposing (RoutePattern)
|
||||||
@ -146,7 +147,7 @@ type alias App data action routeParams =
|
|||||||
{ fields : List ( String, String ), headers : List ( String, String ) }
|
{ fields : List ( String, String ), headers : List ( String, String ) }
|
||||||
-> Pages.Fetcher.Fetcher (Result Http.Error action)
|
-> Pages.Fetcher.Fetcher (Result Http.Error action)
|
||||||
, navigation : Maybe Pages.Navigation.Navigation
|
, navigation : Maybe Pages.Navigation.Navigation
|
||||||
, concurrentSubmissions : Dict String (Pages.Navigation.FetcherState (Maybe action))
|
, concurrentSubmissions : Dict String (Pages.ConcurrentSubmission.ConcurrentSubmission (Maybe action))
|
||||||
, pageFormState : Form.Model
|
, pageFormState : Form.Model
|
||||||
}
|
}
|
||||||
|
|
||||||
|
52
src/Pages/ConcurrentSubmission.elm
Normal file
52
src/Pages/ConcurrentSubmission.elm
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
module Pages.ConcurrentSubmission exposing
|
||||||
|
( ConcurrentSubmission, Status(..)
|
||||||
|
, map
|
||||||
|
)
|
||||||
|
|
||||||
|
{-|
|
||||||
|
|
||||||
|
@docs ConcurrentSubmission, Status
|
||||||
|
|
||||||
|
@docs map
|
||||||
|
|
||||||
|
-}
|
||||||
|
|
||||||
|
import Pages.FormData exposing (FormData)
|
||||||
|
import Time
|
||||||
|
|
||||||
|
|
||||||
|
{-| -}
|
||||||
|
type alias ConcurrentSubmission actionData =
|
||||||
|
{ status : Status actionData
|
||||||
|
, payload : FormData
|
||||||
|
, initiatedAt : Time.Posix
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
{-| -}
|
||||||
|
type Status actionData
|
||||||
|
= Submitting
|
||||||
|
| Reloading actionData
|
||||||
|
| Complete actionData
|
||||||
|
|
||||||
|
|
||||||
|
{-| -}
|
||||||
|
map : (a -> b) -> ConcurrentSubmission a -> ConcurrentSubmission b
|
||||||
|
map mapFn fetcherState =
|
||||||
|
{ status = mapStatus mapFn fetcherState.status
|
||||||
|
, payload = fetcherState.payload
|
||||||
|
, initiatedAt = fetcherState.initiatedAt
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
mapStatus : (a -> b) -> Status a -> Status b
|
||||||
|
mapStatus mapFn fetcherSubmitStatus =
|
||||||
|
case fetcherSubmitStatus of
|
||||||
|
Submitting ->
|
||||||
|
Submitting
|
||||||
|
|
||||||
|
Reloading value ->
|
||||||
|
Reloading (mapFn value)
|
||||||
|
|
||||||
|
Complete value ->
|
||||||
|
Complete (mapFn value)
|
@ -22,6 +22,7 @@ import Form.Handler
|
|||||||
import Form.Validation exposing (Validation)
|
import Form.Validation exposing (Validation)
|
||||||
import Html
|
import Html
|
||||||
import Html.Styled
|
import Html.Styled
|
||||||
|
import Pages.ConcurrentSubmission
|
||||||
import Pages.Internal.Msg
|
import Pages.Internal.Msg
|
||||||
import Pages.Navigation
|
import Pages.Navigation
|
||||||
import PagesMsg exposing (PagesMsg)
|
import PagesMsg exposing (PagesMsg)
|
||||||
@ -93,7 +94,7 @@ renderHtml :
|
|||||||
app
|
app
|
||||||
| pageFormState : Form.Model
|
| pageFormState : Form.Model
|
||||||
, navigation : Maybe Pages.Navigation.Navigation
|
, navigation : Maybe Pages.Navigation.Navigation
|
||||||
, concurrentSubmissions : Dict String (Pages.Navigation.FetcherState (Maybe action))
|
, concurrentSubmissions : Dict String (Pages.ConcurrentSubmission.ConcurrentSubmission (Maybe action))
|
||||||
}
|
}
|
||||||
-> Form.Form error { combine : Validation error parsed named constraints, view : Form.Context error input -> List (Html.Html (PagesMsg userMsg)) } parsed input
|
-> Form.Form error { combine : Validation error parsed named constraints, view : Form.Context error input -> List (Html.Html (PagesMsg userMsg)) } parsed input
|
||||||
-> Html.Html (PagesMsg userMsg)
|
-> Html.Html (PagesMsg userMsg)
|
||||||
@ -110,13 +111,13 @@ renderHtml attrs options_ app form_ =
|
|||||||
(case app.concurrentSubmissions |> Dict.get options_.id of
|
(case app.concurrentSubmissions |> Dict.get options_.id of
|
||||||
Just { status } ->
|
Just { status } ->
|
||||||
case status of
|
case status of
|
||||||
Pages.Navigation.FetcherComplete _ ->
|
Pages.ConcurrentSubmission.Complete _ ->
|
||||||
False
|
False
|
||||||
|
|
||||||
Pages.Navigation.FetcherSubmitting ->
|
Pages.ConcurrentSubmission.Submitting ->
|
||||||
True
|
True
|
||||||
|
|
||||||
Pages.Navigation.FetcherReloading _ ->
|
Pages.ConcurrentSubmission.Reloading _ ->
|
||||||
True
|
True
|
||||||
|
|
||||||
Nothing ->
|
Nothing ->
|
||||||
@ -187,7 +188,7 @@ renderStyledHtml :
|
|||||||
app
|
app
|
||||||
| pageFormState : Form.Model
|
| pageFormState : Form.Model
|
||||||
, navigation : Maybe Pages.Navigation.Navigation
|
, navigation : Maybe Pages.Navigation.Navigation
|
||||||
, concurrentSubmissions : Dict String (Pages.Navigation.FetcherState (Maybe action))
|
, concurrentSubmissions : Dict String (Pages.ConcurrentSubmission.ConcurrentSubmission (Maybe action))
|
||||||
}
|
}
|
||||||
-> Form.Form error { combine : Validation error parsed named constraints, view : Form.Context error input -> List (Html.Styled.Html (PagesMsg userMsg)) } parsed input
|
-> Form.Form error { combine : Validation error parsed named constraints, view : Form.Context error input -> List (Html.Styled.Html (PagesMsg userMsg)) } parsed input
|
||||||
-> Html.Styled.Html (PagesMsg userMsg)
|
-> Html.Styled.Html (PagesMsg userMsg)
|
||||||
@ -205,13 +206,13 @@ renderStyledHtml attrs options_ app form_ =
|
|||||||
(case app.concurrentSubmissions |> Dict.get options_.id of
|
(case app.concurrentSubmissions |> Dict.get options_.id of
|
||||||
Just { status } ->
|
Just { status } ->
|
||||||
case status of
|
case status of
|
||||||
Pages.Navigation.FetcherComplete _ ->
|
Pages.ConcurrentSubmission.Complete _ ->
|
||||||
False
|
False
|
||||||
|
|
||||||
Pages.Navigation.FetcherSubmitting ->
|
Pages.ConcurrentSubmission.Submitting ->
|
||||||
True
|
True
|
||||||
|
|
||||||
Pages.Navigation.FetcherReloading _ ->
|
Pages.ConcurrentSubmission.Reloading _ ->
|
||||||
True
|
True
|
||||||
|
|
||||||
Nothing ->
|
Nothing ->
|
||||||
|
18
src/Pages/FormData.elm
Normal file
18
src/Pages/FormData.elm
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
module Pages.FormData exposing (FormData)
|
||||||
|
|
||||||
|
{-|
|
||||||
|
|
||||||
|
@docs FormData
|
||||||
|
|
||||||
|
-}
|
||||||
|
|
||||||
|
import Form
|
||||||
|
|
||||||
|
|
||||||
|
{-| -}
|
||||||
|
type alias FormData =
|
||||||
|
{ fields : List ( String, String )
|
||||||
|
, method : Form.Method
|
||||||
|
, action : String
|
||||||
|
, id : Maybe String
|
||||||
|
}
|
@ -26,6 +26,7 @@ import Html.Attributes as Attr
|
|||||||
import Http
|
import Http
|
||||||
import Json.Decode as Decode
|
import Json.Decode as Decode
|
||||||
import Json.Encode
|
import Json.Encode
|
||||||
|
import Pages.ConcurrentSubmission
|
||||||
import Pages.ContentCache as ContentCache
|
import Pages.ContentCache as ContentCache
|
||||||
import Pages.Fetcher
|
import Pages.Fetcher
|
||||||
import Pages.Flags
|
import Pages.Flags
|
||||||
@ -342,7 +343,7 @@ type alias Model userModel pageData actionData sharedData =
|
|||||||
, userFlags : Decode.Value
|
, userFlags : Decode.Value
|
||||||
, transition : Maybe ( Int, Pages.Navigation.Navigation )
|
, transition : Maybe ( Int, Pages.Navigation.Navigation )
|
||||||
, nextTransitionKey : Int
|
, nextTransitionKey : Int
|
||||||
, inFlightFetchers : Dict String ( Int, Pages.Navigation.FetcherState actionData )
|
, inFlightFetchers : Dict String ( Int, Pages.ConcurrentSubmission.ConcurrentSubmission actionData )
|
||||||
, pageFormState : Form.Model
|
, pageFormState : Form.Model
|
||||||
, pendingRedirect : Bool
|
, pendingRedirect : Bool
|
||||||
, pendingData : Maybe ( pageData, sharedData, Maybe actionData )
|
, pendingData : Maybe ( pageData, sharedData, Maybe actionData )
|
||||||
@ -454,9 +455,9 @@ update config appMsg model =
|
|||||||
, { fetcherState
|
, { fetcherState
|
||||||
| status =
|
| status =
|
||||||
maybeFetcherDoneActionData
|
maybeFetcherDoneActionData
|
||||||
|> Maybe.map Pages.Navigation.FetcherReloading
|
|> Maybe.map Pages.ConcurrentSubmission.Reloading
|
||||||
-- TODO remove this bad default, FetcherSubmitting is incorrect
|
-- TODO remove this bad default, FetcherSubmitting is incorrect
|
||||||
|> Maybe.withDefault Pages.Navigation.FetcherSubmitting
|
|> Maybe.withDefault Pages.ConcurrentSubmission.Submitting
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -857,7 +858,7 @@ update config appMsg model =
|
|||||||
|> Dict.insert fetcherKey
|
|> Dict.insert fetcherKey
|
||||||
( transitionId
|
( transitionId
|
||||||
, { payload = fetcherData
|
, { payload = fetcherData
|
||||||
, status = Pages.Navigation.FetcherSubmitting
|
, status = Pages.ConcurrentSubmission.Submitting
|
||||||
, initiatedAt = initiatedAt
|
, initiatedAt = initiatedAt
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -866,7 +867,7 @@ update config appMsg model =
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
toFetcherState : Dict String ( Int, Pages.Navigation.FetcherState actionData ) -> Dict String (Pages.Navigation.FetcherState actionData)
|
toFetcherState : Dict String ( Int, Pages.ConcurrentSubmission.ConcurrentSubmission actionData ) -> Dict String (Pages.ConcurrentSubmission.ConcurrentSubmission actionData)
|
||||||
toFetcherState inFlightFetchers =
|
toFetcherState inFlightFetchers =
|
||||||
inFlightFetchers
|
inFlightFetchers
|
||||||
|> Dict.map (\_ ( _, fetcherState ) -> fetcherState)
|
|> Dict.map (\_ ( _, fetcherState ) -> fetcherState)
|
||||||
@ -1143,14 +1144,14 @@ cancelStaleFetchers model =
|
|||||||
|> List.filterMap
|
|> List.filterMap
|
||||||
(\( _, ( id, fetcher ) ) ->
|
(\( _, ( id, fetcher ) ) ->
|
||||||
case fetcher.status of
|
case fetcher.status of
|
||||||
Pages.Navigation.FetcherReloading _ ->
|
Pages.ConcurrentSubmission.Reloading _ ->
|
||||||
Http.cancel (String.fromInt id)
|
Http.cancel (String.fromInt id)
|
||||||
|> Just
|
|> Just
|
||||||
|
|
||||||
Pages.Navigation.FetcherSubmitting ->
|
Pages.ConcurrentSubmission.Submitting ->
|
||||||
Nothing
|
Nothing
|
||||||
|
|
||||||
Pages.Navigation.FetcherComplete _ ->
|
Pages.ConcurrentSubmission.Complete _ ->
|
||||||
Nothing
|
Nothing
|
||||||
)
|
)
|
||||||
|> Cmd.batch
|
|> Cmd.batch
|
||||||
@ -1459,9 +1460,9 @@ clearLoadingFetchersAfterDataLoad completedTransitionId model =
|
|||||||
-- TODO fetchers are never removed from the list. Need to decide how and when to remove them.
|
-- TODO fetchers are never removed from the list. Need to decide how and when to remove them.
|
||||||
--(fetcherState.status /= Pages.Transition.FetcherReloading) || (transitionId > completedTransitionId)
|
--(fetcherState.status /= Pages.Transition.FetcherReloading) || (transitionId > completedTransitionId)
|
||||||
case ( transitionId > completedTransitionId, fetcherState.status ) of
|
case ( transitionId > completedTransitionId, fetcherState.status ) of
|
||||||
( False, Pages.Navigation.FetcherReloading actionData ) ->
|
( False, Pages.ConcurrentSubmission.Reloading actionData ) ->
|
||||||
( transitionId
|
( transitionId
|
||||||
, { fetcherState | status = Pages.Navigation.FetcherComplete actionData }
|
, { fetcherState | status = Pages.ConcurrentSubmission.Complete actionData }
|
||||||
)
|
)
|
||||||
|
|
||||||
_ ->
|
_ ->
|
||||||
|
@ -1,34 +1,17 @@
|
|||||||
module Pages.Navigation exposing
|
module Pages.Navigation exposing (Navigation(..), LoadingState(..))
|
||||||
( LoadingState(..), map, FormData
|
|
||||||
, FetcherState, FetcherSubmitStatus(..)
|
|
||||||
, Navigation(..)
|
|
||||||
)
|
|
||||||
|
|
||||||
{-|
|
{-|
|
||||||
|
|
||||||
@docs Transition, LoadingState, map, FormData
|
@docs Navigation, LoadingState
|
||||||
|
|
||||||
|
|
||||||
## Fetchers
|
|
||||||
|
|
||||||
@docs FetcherState, FetcherSubmitStatus
|
|
||||||
|
|
||||||
-}
|
-}
|
||||||
|
|
||||||
import Form
|
import Form
|
||||||
|
import Pages.FormData exposing (FormData)
|
||||||
import Time
|
import Time
|
||||||
import UrlPath exposing (UrlPath)
|
import UrlPath exposing (UrlPath)
|
||||||
|
|
||||||
|
|
||||||
{-| -}
|
|
||||||
type alias FormData =
|
|
||||||
{ fields : List ( String, String )
|
|
||||||
, method : Form.Method
|
|
||||||
, action : String
|
|
||||||
, id : Maybe String
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
{-| -}
|
{-| -}
|
||||||
type Navigation
|
type Navigation
|
||||||
= Submitting FormData
|
= Submitting FormData
|
||||||
@ -41,40 +24,3 @@ type LoadingState
|
|||||||
= Redirecting
|
= Redirecting
|
||||||
| Load
|
| Load
|
||||||
| ActionRedirect
|
| ActionRedirect
|
||||||
|
|
||||||
|
|
||||||
{-| -}
|
|
||||||
type alias FetcherState actionData =
|
|
||||||
{ status : FetcherSubmitStatus actionData
|
|
||||||
, payload : FormData
|
|
||||||
, initiatedAt : Time.Posix
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
{-| -}
|
|
||||||
type FetcherSubmitStatus actionData
|
|
||||||
= FetcherSubmitting
|
|
||||||
| FetcherReloading actionData
|
|
||||||
| FetcherComplete actionData
|
|
||||||
|
|
||||||
|
|
||||||
{-| -}
|
|
||||||
map : (a -> b) -> FetcherState a -> FetcherState b
|
|
||||||
map mapFn fetcherState =
|
|
||||||
{ status = mapStatus mapFn fetcherState.status
|
|
||||||
, payload = fetcherState.payload
|
|
||||||
, initiatedAt = fetcherState.initiatedAt
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
mapStatus : (a -> b) -> FetcherSubmitStatus a -> FetcherSubmitStatus b
|
|
||||||
mapStatus mapFn fetcherSubmitStatus =
|
|
||||||
case fetcherSubmitStatus of
|
|
||||||
FetcherSubmitting ->
|
|
||||||
FetcherSubmitting
|
|
||||||
|
|
||||||
FetcherReloading value ->
|
|
||||||
FetcherReloading (mapFn value)
|
|
||||||
|
|
||||||
FetcherComplete value ->
|
|
||||||
FetcherComplete (mapFn value)
|
|
||||||
|
@ -15,6 +15,7 @@ import Http
|
|||||||
import Json.Decode as Decode
|
import Json.Decode as Decode
|
||||||
import Json.Encode
|
import Json.Encode
|
||||||
import PageServerResponse exposing (PageServerResponse)
|
import PageServerResponse exposing (PageServerResponse)
|
||||||
|
import Pages.ConcurrentSubmission
|
||||||
import Pages.Fetcher
|
import Pages.Fetcher
|
||||||
import Pages.Flags
|
import Pages.Flags
|
||||||
import Pages.Internal.NotFoundReason exposing (NotFoundReason)
|
import Pages.Internal.NotFoundReason exposing (NotFoundReason)
|
||||||
@ -46,7 +47,7 @@ type alias ProgramConfig userMsg userModel route pageData actionData sharedData
|
|||||||
, pageUrl : Maybe PageUrl
|
, pageUrl : Maybe PageUrl
|
||||||
}
|
}
|
||||||
-> ( userModel, effect )
|
-> ( userModel, effect )
|
||||||
, update : Form.Model -> Dict String (Pages.Navigation.FetcherState actionData) -> Maybe Pages.Navigation.Navigation -> sharedData -> pageData -> Maybe Browser.Navigation.Key -> userMsg -> userModel -> ( userModel, effect )
|
, update : Form.Model -> Dict String (Pages.ConcurrentSubmission.ConcurrentSubmission actionData) -> Maybe Pages.Navigation.Navigation -> sharedData -> pageData -> Maybe Browser.Navigation.Key -> userMsg -> userModel -> ( userModel, effect )
|
||||||
, subscriptions : route -> UrlPath -> userModel -> Sub userMsg
|
, subscriptions : route -> UrlPath -> userModel -> Sub userMsg
|
||||||
, sharedData : BackendTask FatalError sharedData
|
, sharedData : BackendTask FatalError sharedData
|
||||||
, data : Decode.Value -> route -> BackendTask FatalError (PageServerResponse pageData errorPage)
|
, data : Decode.Value -> route -> BackendTask FatalError (PageServerResponse pageData errorPage)
|
||||||
@ -54,7 +55,7 @@ type alias ProgramConfig userMsg userModel route pageData actionData sharedData
|
|||||||
, onActionData : actionData -> Maybe userMsg
|
, onActionData : actionData -> Maybe userMsg
|
||||||
, view :
|
, view :
|
||||||
Form.Model
|
Form.Model
|
||||||
-> Dict String (Pages.Navigation.FetcherState actionData)
|
-> Dict String (Pages.ConcurrentSubmission.ConcurrentSubmission actionData)
|
||||||
-> Maybe Pages.Navigation.Navigation
|
-> Maybe Pages.Navigation.Navigation
|
||||||
->
|
->
|
||||||
{ path : UrlPath
|
{ path : UrlPath
|
||||||
|
Loading…
Reference in New Issue
Block a user