Rename module.

This commit is contained in:
Dillon Kearns 2023-05-24 08:39:43 -07:00
parent 08fcd53f09
commit 513e58f560
8 changed files with 55 additions and 54 deletions

View File

@ -30,7 +30,7 @@
"Pages.Manifest.Category",
"Pages.Flags",
"Pages.Fetcher",
"Pages.Transition",
"Pages.Navigation",
"Scaffold.Route",
"Scaffold.Form",
"Pages.Script",

View File

@ -18,7 +18,7 @@ import Html.Styled.Attributes as Attr
import Json.Decode as Decode
import Json.Encode as Encode
import Pages.Form
import Pages.Transition exposing (FetcherSubmitStatus(..))
import Pages.Navigation exposing (FetcherSubmitStatus(..))
import PagesMsg exposing (PagesMsg)
import Platform.Sub
import RouteBuilder

View File

@ -21,7 +21,7 @@ import Json.Encode as Encode
import LoadingSpinner
import MySession
import Pages.Form
import Pages.Transition exposing (FetcherSubmitStatus(..))
import Pages.Navigation exposing (FetcherSubmitStatus(..))
import PagesMsg exposing (PagesMsg)
import Route
import RouteBuilder exposing (App, StatefulRoute)
@ -451,7 +451,7 @@ view app shared model =
optimisticVisibility : Visibility
optimisticVisibility =
case app.navigation of
Just (Pages.Transition.Loading path _) ->
Just (Pages.Navigation.Loading path _) ->
case path of
[ "active" ] ->
Active
@ -477,7 +477,7 @@ view app shared model =
, status
)
of
( Form.Valid (Add newItem), Pages.Transition.FetcherComplete (Just parsedActionData) ) ->
( Form.Valid (Add newItem), Pages.Navigation.FetcherComplete (Just parsedActionData) ) ->
parsedActionData.errors
|> Maybe.map (Tuple.pair key)

View File

@ -98,7 +98,7 @@ import Pages.Fetcher
import Pages.Internal.NotFoundReason exposing (NotFoundReason)
import Pages.Internal.RoutePattern exposing (RoutePattern)
import Pages.PageUrl exposing (PageUrl)
import Pages.Transition
import Pages.Navigation
import PagesMsg exposing (PagesMsg)
import UrlPath exposing (UrlPath)
import Server.Request
@ -145,8 +145,8 @@ type alias App data action routeParams =
, submit :
{ fields : List ( String, String ), headers : List ( String, String ) }
-> Pages.Fetcher.Fetcher (Result Http.Error action)
, navigation : Maybe Pages.Transition.Transition
, concurrentSubmissions : Dict String (Pages.Transition.FetcherState (Maybe action))
, navigation : Maybe Pages.Navigation.Navigation
, concurrentSubmissions : Dict String (Pages.Navigation.FetcherState (Maybe action))
, pageFormState : Form.Model
}

View File

@ -23,7 +23,7 @@ import Form.Validation exposing (Validation)
import Html
import Html.Styled
import Pages.Internal.Msg
import Pages.Transition
import Pages.Navigation
import PagesMsg exposing (PagesMsg)
@ -92,8 +92,8 @@ renderHtml :
--, action : Maybe action
app
| pageFormState : Form.Model
, navigation : Maybe Pages.Transition.Transition
, concurrentSubmissions : Dict String (Pages.Transition.FetcherState (Maybe action))
, navigation : Maybe Pages.Navigation.Navigation
, concurrentSubmissions : Dict String (Pages.Navigation.FetcherState (Maybe action))
}
-> 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)
@ -110,26 +110,26 @@ renderHtml attrs options_ app form_ =
(case app.concurrentSubmissions |> Dict.get options_.id of
Just { status } ->
case status of
Pages.Transition.FetcherComplete _ ->
Pages.Navigation.FetcherComplete _ ->
False
Pages.Transition.FetcherSubmitting ->
Pages.Navigation.FetcherSubmitting ->
True
Pages.Transition.FetcherReloading _ ->
Pages.Navigation.FetcherReloading _ ->
True
Nothing ->
False
)
|| (case app.navigation of
Just (Pages.Transition.Submitting formData) ->
Just (Pages.Navigation.Submitting formData) ->
formData.id == Just options_.id
Just (Pages.Transition.LoadAfterSubmit submitData _ _) ->
Just (Pages.Navigation.LoadAfterSubmit submitData _ _) ->
submitData.id == Just options_.id
Just (Pages.Transition.Loading _ _) ->
Just (Pages.Navigation.Loading _ _) ->
False
Nothing ->
@ -186,8 +186,8 @@ renderStyledHtml :
--, action : Maybe action
app
| pageFormState : Form.Model
, navigation : Maybe Pages.Transition.Transition
, concurrentSubmissions : Dict String (Pages.Transition.FetcherState (Maybe action))
, navigation : Maybe Pages.Navigation.Navigation
, concurrentSubmissions : Dict String (Pages.Navigation.FetcherState (Maybe action))
}
-> 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)
@ -205,26 +205,26 @@ renderStyledHtml attrs options_ app form_ =
(case app.concurrentSubmissions |> Dict.get options_.id of
Just { status } ->
case status of
Pages.Transition.FetcherComplete _ ->
Pages.Navigation.FetcherComplete _ ->
False
Pages.Transition.FetcherSubmitting ->
Pages.Navigation.FetcherSubmitting ->
True
Pages.Transition.FetcherReloading _ ->
Pages.Navigation.FetcherReloading _ ->
True
Nothing ->
False
)
|| (case app.navigation of
Just (Pages.Transition.Submitting formData) ->
Just (Pages.Navigation.Submitting formData) ->
formData.id == Just options_.id
Just (Pages.Transition.LoadAfterSubmit submitData _ _) ->
Just (Pages.Navigation.LoadAfterSubmit submitData _ _) ->
submitData.id == Just options_.id
Just (Pages.Transition.Loading _ _) ->
Just (Pages.Navigation.Loading _ _) ->
False
Nothing ->

View File

@ -33,9 +33,9 @@ import Pages.Internal.Msg
import Pages.Internal.NotFoundReason exposing (NotFoundReason)
import Pages.Internal.ResponseSketch as ResponseSketch exposing (ResponseSketch)
import Pages.Internal.String as String
import Pages.Navigation
import Pages.ProgramConfig exposing (ProgramConfig)
import Pages.StaticHttpRequest as StaticHttpRequest
import Pages.Transition
import PagesMsg exposing (PagesMsg)
import QueryParams
import Task
@ -340,9 +340,9 @@ type alias Model userModel pageData actionData sharedData =
}
, notFound : Maybe { reason : NotFoundReason, path : UrlPath }
, userFlags : Decode.Value
, transition : Maybe ( Int, Pages.Transition.Transition )
, transition : Maybe ( Int, Pages.Navigation.Navigation )
, nextTransitionKey : Int
, inFlightFetchers : Dict String ( Int, Pages.Transition.FetcherState actionData )
, inFlightFetchers : Dict String ( Int, Pages.Navigation.FetcherState actionData )
, pageFormState : Form.Model
, pendingRedirect : Bool
, pendingData : Maybe ( pageData, sharedData, Maybe actionData )
@ -454,9 +454,9 @@ update config appMsg model =
, { fetcherState
| status =
maybeFetcherDoneActionData
|> Maybe.map Pages.Transition.FetcherReloading
|> Maybe.map Pages.Navigation.FetcherReloading
-- TODO remove this bad default, FetcherSubmitting is incorrect
|> Maybe.withDefault Pages.Transition.FetcherSubmitting
|> Maybe.withDefault Pages.Navigation.FetcherSubmitting
}
)
)
@ -534,7 +534,7 @@ update config appMsg model =
Just
( -- TODO remove hardcoded number
-1
, Pages.Transition.Submitting payload
, Pages.Navigation.Submitting payload
)
}
, Submit payload
@ -857,7 +857,7 @@ update config appMsg model =
|> Dict.insert fetcherKey
( transitionId
, { payload = fetcherData
, status = Pages.Transition.FetcherSubmitting
, status = Pages.Navigation.FetcherSubmitting
, initiatedAt = initiatedAt
}
)
@ -866,7 +866,7 @@ update config appMsg model =
)
toFetcherState : Dict String ( Int, Pages.Transition.FetcherState actionData ) -> Dict String (Pages.Transition.FetcherState actionData)
toFetcherState : Dict String ( Int, Pages.Navigation.FetcherState actionData ) -> Dict String (Pages.Navigation.FetcherState actionData)
toFetcherState inFlightFetchers =
inFlightFetchers
|> Dict.map (\_ ( _, fetcherState ) -> fetcherState)
@ -1143,14 +1143,14 @@ cancelStaleFetchers model =
|> List.filterMap
(\( _, ( id, fetcher ) ) ->
case fetcher.status of
Pages.Transition.FetcherReloading _ ->
Pages.Navigation.FetcherReloading _ ->
Http.cancel (String.fromInt id)
|> Just
Pages.Transition.FetcherSubmitting ->
Pages.Navigation.FetcherSubmitting ->
Nothing
Pages.Transition.FetcherComplete _ ->
Pages.Navigation.FetcherComplete _ ->
Nothing
)
|> Cmd.batch
@ -1407,7 +1407,7 @@ startNewGetLoad urlToGet toMsg ( model, effect ) =
cancelIfStale : Effect userMsg pageData actionData sharedData userEffect errorPage
cancelIfStale =
case model.transition of
Just ( transitionKey, Pages.Transition.Loading _ _ ) ->
Just ( transitionKey, Pages.Navigation.Loading _ _ ) ->
CancelRequest transitionKey
_ ->
@ -1418,22 +1418,22 @@ startNewGetLoad urlToGet toMsg ( model, effect ) =
, transition =
( model.nextTransitionKey
, case model.transition of
Just ( _, Pages.Transition.LoadAfterSubmit submitData _ _ ) ->
Pages.Transition.LoadAfterSubmit
Just ( _, Pages.Navigation.LoadAfterSubmit submitData _ _ ) ->
Pages.Navigation.LoadAfterSubmit
submitData
(urlToGet.path |> UrlPath.fromString)
Pages.Transition.Load
Pages.Navigation.Load
Just ( _, Pages.Transition.Submitting submitData ) ->
Pages.Transition.LoadAfterSubmit
Just ( _, Pages.Navigation.Submitting submitData ) ->
Pages.Navigation.LoadAfterSubmit
submitData
(urlToGet.path |> UrlPath.fromString)
Pages.Transition.Load
Pages.Navigation.Load
_ ->
Pages.Transition.Loading
Pages.Navigation.Loading
(urlToGet.path |> UrlPath.fromString)
Pages.Transition.Load
Pages.Navigation.Load
)
|> Just
}
@ -1459,9 +1459,9 @@ clearLoadingFetchersAfterDataLoad completedTransitionId model =
-- TODO fetchers are never removed from the list. Need to decide how and when to remove them.
--(fetcherState.status /= Pages.Transition.FetcherReloading) || (transitionId > completedTransitionId)
case ( transitionId > completedTransitionId, fetcherState.status ) of
( False, Pages.Transition.FetcherReloading actionData ) ->
( False, Pages.Navigation.FetcherReloading actionData ) ->
( transitionId
, { fetcherState | status = Pages.Transition.FetcherComplete actionData }
, { fetcherState | status = Pages.Navigation.FetcherComplete actionData }
)
_ ->

View File

@ -1,6 +1,7 @@
module Pages.Transition exposing
( Transition(..), LoadingState(..), map, FormData
module Pages.Navigation exposing
( LoadingState(..), map, FormData
, FetcherState, FetcherSubmitStatus(..)
, Navigation(..)
)
{-|
@ -29,7 +30,7 @@ type alias FormData =
{-| -}
type Transition
type Navigation
= Submitting FormData
| LoadAfterSubmit FormData UrlPath LoadingState
| Loading UrlPath LoadingState

View File

@ -21,9 +21,9 @@ import Pages.Internal.NotFoundReason exposing (NotFoundReason)
import Pages.Internal.Platform.ToJsPayload
import Pages.Internal.ResponseSketch exposing (ResponseSketch)
import Pages.Internal.RoutePattern exposing (RoutePattern)
import Pages.Navigation
import Pages.PageUrl exposing (PageUrl)
import Pages.SiteConfig exposing (SiteConfig)
import Pages.Transition
import PagesMsg exposing (PagesMsg)
import Url exposing (Url)
import UrlPath exposing (UrlPath)
@ -46,7 +46,7 @@ type alias ProgramConfig userMsg userModel route pageData actionData sharedData
, pageUrl : Maybe PageUrl
}
-> ( userModel, effect )
, update : Form.Model -> Dict String (Pages.Transition.FetcherState actionData) -> Maybe Pages.Transition.Transition -> sharedData -> pageData -> Maybe Browser.Navigation.Key -> userMsg -> userModel -> ( 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 )
, subscriptions : route -> UrlPath -> userModel -> Sub userMsg
, sharedData : BackendTask FatalError sharedData
, data : Decode.Value -> route -> BackendTask FatalError (PageServerResponse pageData errorPage)
@ -54,8 +54,8 @@ type alias ProgramConfig userMsg userModel route pageData actionData sharedData
, onActionData : actionData -> Maybe userMsg
, view :
Form.Model
-> Dict String (Pages.Transition.FetcherState actionData)
-> Maybe Pages.Transition.Transition
-> Dict String (Pages.Navigation.FetcherState actionData)
-> Maybe Pages.Navigation.Navigation
->
{ path : UrlPath
, route : route