Rename fields.

This commit is contained in:
Dillon Kearns 2023-05-24 08:37:02 -07:00
parent 284a40c306
commit 08fcd53f09
9 changed files with 37 additions and 42 deletions

View File

@ -237,12 +237,12 @@ otherFile routes phaseString =
view =
Elm.Declare.function "view"
[ ( "pageFormState", Type.named [ "Form" ] "Model" |> Just )
, ( "fetchers"
, ( "concurrentSubmissions"
, Gen.Dict.annotation_.dict Type.string
(Gen.Pages.Transition.annotation_.fetcherState (Type.named [] "ActionData"))
|> Just
)
, ( "transition", Type.named [ "Pages", "Transition" ] "Transition" |> Type.maybe |> Just )
, ( "navigation", Type.named [ "Pages", "Transition" ] "Transition" |> Type.maybe |> Just )
, ( "page"
, Type.record
[ ( "path", Type.named [ "UrlPath" ] "UrlPath" )
@ -257,7 +257,7 @@ otherFile routes phaseString =
]
(\args ->
case args of
[ pageFormState, fetchers, transition, page, maybePageUrl, globalData, pageData, actionData ] ->
[ pageFormState, concurrentSubmissions, navigation, page, maybePageUrl, globalData, pageData, actionData ] ->
Elm.Case.custom (Elm.tuple (page |> Elm.get "route") pageData)
Type.unit
([ Elm.Pattern.tuple Elm.Pattern.ignore (Elm.Pattern.variant1 "DataErrorPage____" (Elm.Pattern.var "data"))
@ -375,9 +375,9 @@ otherFile routes phaseString =
"fetcherArg"
(Gen.Pages.Fetcher.call_.submit (decodeRouteType ActionData route))
)
, ( "transition", transition )
, ( "fetchers"
, fetchers
, ( "navigation", navigation )
, ( "concurrentSubmissions"
, concurrentSubmissions
|> Gen.Dict.map
(\_ fetcherState ->
fetcherState
@ -416,8 +416,8 @@ otherFile routes phaseString =
, ( "path", page |> Elm.get "path" )
, ( "url", Elm.nothing )
, ( "submit", Elm.functionReduced "value" (Gen.Pages.Fetcher.call_.submit (decodeRouteType ActionData route)) )
, ( "transition", Elm.nothing )
, ( "fetchers", Gen.Dict.empty )
, ( "navigation", Elm.nothing )
, ( "concurrentSubmissions", Gen.Dict.empty )
, ( "pageFormState", Gen.Dict.empty )
]
]
@ -855,8 +855,8 @@ otherFile routes phaseString =
[ route |> decodeRouteType ActionData
]
)
, ( "transition", Elm.nothing )
, ( "fetchers", Gen.Dict.empty )
, ( "navigation", Elm.nothing )
, ( "concurrentSubmissions", Gen.Dict.empty )
, ( "pageFormState", Gen.Dict.empty )
]
]
@ -914,13 +914,13 @@ otherFile routes phaseString =
update =
Elm.Declare.function "update"
[ ( "pageFormState", Type.named [ "Form" ] "Model" |> Just )
, ( "fetchers"
, ( "concurrentSubmissions"
, Gen.Dict.annotation_.dict
Type.string
(Gen.Pages.Transition.annotation_.fetcherState (Type.named [] "ActionData"))
|> Just
)
, ( "transition", Type.named [ "Pages", "Transition" ] "Transition" |> Type.maybe |> Just )
, ( "navigation", Type.named [ "Pages", "Transition" ] "Transition" |> Type.maybe |> Just )
, ( "sharedData", Type.named [ "Shared" ] "Data" |> Just )
, ( "pageData", Type.named [] "PageData" |> Just )
, ( "navigationKey", Type.named [ "Browser", "Navigation" ] "Key" |> Type.maybe |> Just )
@ -929,7 +929,7 @@ otherFile routes phaseString =
]
(\args ->
case args of
[ pageFormState, fetchers, transition, sharedData, pageData, navigationKey, msg, model ] ->
[ pageFormState, concurrentSubmissions, navigation, sharedData, pageData, navigationKey, msg, model ] ->
Elm.Case.custom msg
Type.unit
([ Elm.Pattern.variant1 "MsgErrorPage____" (Elm.Pattern.var "msg_")
@ -1183,9 +1183,9 @@ otherFile routes phaseString =
, ( "path", justPage |> Elm.get "path" )
, ( "url", Elm.just pageUrl )
, ( "submit", Elm.fn ( "options", Nothing ) (Gen.Pages.Fetcher.call_.submit (decodeRouteType ActionData route)) )
, ( "transition", transition )
, ( "fetchers"
, fetchers
, ( "navigation", navigation )
, ( "concurrentSubmissions"
, concurrentSubmissions
|> Gen.Dict.map
(\_ fetcherState ->
fetcherState

View File

@ -200,7 +200,7 @@ view app sharedModel model =
let
inFlight : List Action
inFlight =
app.fetchers
app.concurrentSubmissions
|> Dict.values
|> List.filterMap
(\{ status, payload } ->
@ -271,7 +271,7 @@ view app sharedModel model =
else
Html.text "Ready"
]
, app.fetchers
, app.concurrentSubmissions
|> Dict.toList
|> List.map
(\( key, item ) ->

View File

@ -679,7 +679,7 @@ view app model sharedModel =
|> Maybe.withDefault (Html.p [] [])
, Html.p []
[ -- TODO should this be calling a function in Form and passing in the form, like `Form.isSubmitting form`?
if app.transition /= Nothing then
if app.navigation /= Nothing then
Html.text "Submitting..."
else

View File

@ -231,7 +231,7 @@ view maybeUrl sharedModel model app =
let
pendingItems : Dict String Int
pendingItems =
app.fetchers
app.concurrentSubmissions
|> Dict.values
|> List.filterMap
(\pending ->
@ -268,7 +268,7 @@ view maybeUrl sharedModel model app =
{ totalItems = 0, totalPrice = 0 }
in
[ Html.pre []
[ app.fetchers
[ app.concurrentSubmissions
|> Debug.toString
|> Html.text
]

View File

@ -165,7 +165,7 @@ view maybeUrl sharedModel model app =
[ Html.text <|
"Edit"
]
, nameFormView app.data.user app.transition
, nameFormView app.data.user app.navigation
, Html.pre []
[ app.action
|> Debug.toString

View File

@ -317,7 +317,7 @@ view maybeUrl sharedModel model app =
let
pendingCreation : Maybe NewItem
pendingCreation =
app.transition
app.navigation
|> Maybe.andThen getTransitionFields
|> Maybe.andThen
(\transitionFields ->

View File

@ -330,7 +330,7 @@ view app shared model =
let
pendingFetchers : List Action
pendingFetchers =
app.fetchers
app.concurrentSubmissions
|> Dict.values
|> List.filterMap
(\{ status, payload } ->
@ -450,7 +450,7 @@ view app shared model =
optimisticVisibility : Visibility
optimisticVisibility =
case app.transition of
case app.navigation of
Just (Pages.Transition.Loading path _) ->
case path of
[ "active" ] ->
@ -467,7 +467,7 @@ view app shared model =
failedAddItemActions : List ( String, String )
failedAddItemActions =
app.fetchers
app.concurrentSubmissions
|> Dict.toList
|> List.filterMap
(\( key, { status, payload } ) ->

View File

@ -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)
, transition : Maybe Pages.Transition.Transition
, fetchers : Dict String (Pages.Transition.FetcherState (Maybe action))
, navigation : Maybe Pages.Transition.Transition
, concurrentSubmissions : Dict String (Pages.Transition.FetcherState (Maybe action))
, pageFormState : Form.Model
}

View File

@ -48,6 +48,7 @@ type alias Handler error combined =
Form.Handler.Handler error (BackendTask FatalError (Validation error combined Never Never))
{-| -}
type alias Options error parsed input msg =
Form.Options error parsed input msg { concurrent : Bool }
@ -81,12 +82,6 @@ withConcurrent options_ =
-- form
{-| -}
type Strategy
= Parallel
| Serial
{-| -}
renderHtml :
List (Html.Attribute (PagesMsg userMsg))
@ -97,8 +92,8 @@ renderHtml :
--, action : Maybe action
app
| pageFormState : Form.Model
, transition : Maybe Pages.Transition.Transition
, fetchers : Dict String (Pages.Transition.FetcherState (Maybe action))
, navigation : Maybe Pages.Transition.Transition
, concurrentSubmissions : Dict String (Pages.Transition.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)
@ -112,7 +107,7 @@ renderHtml attrs options_ app form_ =
|> Form.renderHtml
{ state = app.pageFormState
, submitting =
(case app.fetchers |> Dict.get options_.id of
(case app.concurrentSubmissions |> Dict.get options_.id of
Just { status } ->
case status of
Pages.Transition.FetcherComplete _ ->
@ -127,7 +122,7 @@ renderHtml attrs options_ app form_ =
Nothing ->
False
)
|| (case app.transition of
|| (case app.navigation of
Just (Pages.Transition.Submitting formData) ->
formData.id == Just options_.id
@ -191,8 +186,8 @@ renderStyledHtml :
--, action : Maybe action
app
| pageFormState : Form.Model
, transition : Maybe Pages.Transition.Transition
, fetchers : Dict String (Pages.Transition.FetcherState (Maybe action))
, navigation : Maybe Pages.Transition.Transition
, concurrentSubmissions : Dict String (Pages.Transition.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)
@ -207,7 +202,7 @@ renderStyledHtml attrs options_ app form_ =
{ state = app.pageFormState
, toMsg = Pages.Internal.Msg.FormMsg
, submitting =
(case app.fetchers |> Dict.get options_.id of
(case app.concurrentSubmissions |> Dict.get options_.id of
Just { status } ->
case status of
Pages.Transition.FetcherComplete _ ->
@ -222,7 +217,7 @@ renderStyledHtml attrs options_ app form_ =
Nothing ->
False
)
|| (case app.transition of
|| (case app.navigation of
Just (Pages.Transition.Submitting formData) ->
formData.id == Just options_.id