diff --git a/examples/smoothies/app/Route/New.elm b/examples/smoothies/app/Route/New.elm index 7f89d331..6cd67407 100644 --- a/examples/smoothies/app/Route/New.elm +++ b/examples/smoothies/app/Route/New.elm @@ -14,8 +14,8 @@ import Html.Attributes as Attr import MySession import Pages.Field as Field import Pages.FieldRenderer as FieldRenderer -import Pages.Form import Pages.FormParser as FormParser +import Pages.FormState import Pages.Msg import Pages.PageUrl exposing (PageUrl) import Pages.Url @@ -148,7 +148,7 @@ form = |> Maybe.withDefault [] errorsView field = - (if field.status == Pages.Form.Blurred then + (if field.status == Pages.FormState.Blurred then field |> errors |> List.map (\error -> Html.li [] [ Html.text error ]) diff --git a/examples/smoothies/app/Route/Profile.elm b/examples/smoothies/app/Route/Profile.elm index 9ffb7a05..2cdbc6f0 100644 --- a/examples/smoothies/app/Route/Profile.elm +++ b/examples/smoothies/app/Route/Profile.elm @@ -10,7 +10,7 @@ import Head.Seo as Seo import Html exposing (Html) import Html.Attributes as Attr import MySession -import Pages.Form +import Pages.FormState import Pages.Msg import Pages.PageUrl exposing (PageUrl) import Pages.Transition @@ -178,7 +178,7 @@ view maybeUrl sharedModel model app = nameFormView : User -> Maybe Pages.Transition.Transition -> Html (Pages.Msg.Msg userMsg) nameFormView user maybeTransition = Html.form - (Pages.Form.listeners "test" + (Pages.FormState.listeners "test" ++ [ Attr.method "POST" , Pages.Msg.onSubmit ] diff --git a/examples/smoothies/app/Route/Profile/Edit.elm b/examples/smoothies/app/Route/Profile/Edit.elm index 99c12d18..eb71f359 100644 --- a/examples/smoothies/app/Route/Profile/Edit.elm +++ b/examples/smoothies/app/Route/Profile/Edit.elm @@ -14,8 +14,8 @@ import Html.Attributes as Attr import MySession import Pages.Field as Field import Pages.FieldRenderer as FieldRenderer -import Pages.Form import Pages.FormParser as FormParser +import Pages.FormState import Pages.Msg import Pages.PageUrl exposing (PageUrl) import Pages.Url @@ -135,7 +135,7 @@ formParser = |> Maybe.withDefault [] errorsView field = - (if field.status == Pages.Form.Blurred then + (if field.status == Pages.FormState.Blurred then field |> errors |> List.map (\error -> Html.li [] [ Html.text error ]) diff --git a/generator/src/RouteBuilder.elm b/generator/src/RouteBuilder.elm index 576af127..6b1f83a4 100644 --- a/generator/src/RouteBuilder.elm +++ b/generator/src/RouteBuilder.elm @@ -93,7 +93,7 @@ import ErrorPage exposing (ErrorPage) import Head import Http import Pages.Fetcher -import Pages.Form +import Pages.FormState import Pages.Internal.NotFoundReason exposing (NotFoundReason) import Pages.Internal.RoutePattern exposing (RoutePattern) import Pages.Msg @@ -146,7 +146,7 @@ type alias StaticPayload data action routeParams = -> Pages.Fetcher.Fetcher (Result Http.Error action) , transition : Maybe Pages.Transition.Transition , fetchers : List Pages.Transition.FetcherState - , pageFormState : Pages.Form.PageFormState + , pageFormState : Pages.FormState.PageFormState } diff --git a/generator/src/generate-template-module-connector.js b/generator/src/generate-template-module-connector.js index 1b60ab64..affc53b4 100644 --- a/generator/src/generate-template-module-connector.js +++ b/generator/src/generate-template-module-connector.js @@ -49,7 +49,7 @@ import Effect exposing (Effect) import ErrorPage exposing (ErrorPage) import HtmlPrinter import Lamdera.Wire3 -import Pages.Form +import Pages.FormState import Pages.Internal.String import Pages.Internal.Platform.ToJsPayload import Pages.Internal.ResponseSketch exposing (ResponseSketch) @@ -161,7 +161,7 @@ type ActionData view : - Pages.Form.PageFormState + Pages.FormState.PageFormState -> List Pages.Transition.FetcherState -> Maybe Pages.Transition.Transition -> { path : Path @@ -373,7 +373,7 @@ init currentGlobalModel userFlags sharedData pageData actionData navigationKey m -update : Pages.Form.PageFormState -> List Pages.Transition.FetcherState -> Maybe Pages.Transition.Transition -> Shared.Data -> PageData -> Maybe Browser.Navigation.Key -> Msg -> Model -> ( Model, Effect Msg ) +update : Pages.FormState.PageFormState -> List Pages.Transition.FetcherState -> Maybe Pages.Transition.Transition -> Shared.Data -> PageData -> Maybe Browser.Navigation.Key -> Msg -> Model -> ( Model, Effect Msg ) update pageFormState fetchers transition sharedData pageData navigationKey msg model = case msg of MsgErrorPage____ msg_ -> diff --git a/src/Pages/FormParser.elm b/src/Pages/FormParser.elm index 5c312341..52f3a9cc 100644 --- a/src/Pages/FormParser.elm +++ b/src/Pages/FormParser.elm @@ -66,7 +66,7 @@ import Html.Styled.Attributes as StyledAttr import Html.Styled.Lazy import Json.Encode as Encode import Pages.Field as Field exposing (Field(..)) -import Pages.Form as Form +import Pages.FormState as Form import Pages.Msg import Pages.Transition diff --git a/src/Pages/Form.elm b/src/Pages/FormState.elm similarity index 99% rename from src/Pages/Form.elm rename to src/Pages/FormState.elm index ee80bf64..42690b53 100644 --- a/src/Pages/Form.elm +++ b/src/Pages/FormState.elm @@ -1,4 +1,4 @@ -module Pages.Form exposing (..) +module Pages.FormState exposing (..) import Dict exposing (Dict) import Html exposing (Attribute) diff --git a/src/Pages/Internal/Platform.elm b/src/Pages/Internal/Platform.elm index 37ff9379..a3f5a364 100644 --- a/src/Pages/Internal/Platform.elm +++ b/src/Pages/Internal/Platform.elm @@ -27,7 +27,7 @@ import Json.Encode import Pages.ContentCache as ContentCache import Pages.Fetcher import Pages.Flags -import Pages.Form +import Pages.FormState import Pages.Internal.NotFoundReason exposing (NotFoundReason) import Pages.Internal.ResponseSketch as ResponseSketch exposing (ResponseSketch) import Pages.Internal.String as String @@ -331,7 +331,7 @@ type alias Model userModel pageData actionData sharedData = , transition : Maybe ( Int, Pages.Transition.Transition ) , nextTransitionKey : Int , inFlightFetchers : Dict Int Pages.Transition.FetcherState - , pageFormState : Pages.Form.PageFormState + , pageFormState : Pages.FormState.PageFormState } @@ -383,7 +383,7 @@ update config appMsg model = ) SetField info -> - ( { model | pageFormState = Pages.Form.setField info model.pageFormState } + ( { model | pageFormState = Pages.FormState.setField info model.pageFormState } , NoEffect ) @@ -471,7 +471,7 @@ update config appMsg model = ( { model | pageFormState = model.pageFormState - |> Pages.Form.setSubmitAttempted + |> Pages.FormState.setSubmitAttempted -- TODO remove hardcoded fieldId "test" } @@ -485,7 +485,7 @@ update config appMsg model = Pages.Msg.FormFieldEvent value -> -- TODO when init is called for a new page, also need to clear out client-side `pageFormState` - ( { model | pageFormState = Pages.Form.update value model.pageFormState } + ( { model | pageFormState = Pages.FormState.update value model.pageFormState } , NoEffect ) diff --git a/src/Pages/ProgramConfig.elm b/src/Pages/ProgramConfig.elm index 4143da62..54d341f7 100644 --- a/src/Pages/ProgramConfig.elm +++ b/src/Pages/ProgramConfig.elm @@ -15,7 +15,7 @@ import Json.Encode import PageServerResponse exposing (PageServerResponse) import Pages.Fetcher import Pages.Flags -import Pages.Form +import Pages.FormState import Pages.Internal.NotFoundReason exposing (NotFoundReason) import Pages.Internal.Platform.ToJsPayload import Pages.Internal.ResponseSketch exposing (ResponseSketch) @@ -46,14 +46,14 @@ type alias ProgramConfig userMsg userModel route pageData actionData sharedData , pageUrl : Maybe PageUrl } -> ( userModel, effect ) - , update : Pages.Form.PageFormState -> List Pages.Transition.FetcherState -> Maybe Pages.Transition.Transition -> sharedData -> pageData -> Maybe Browser.Navigation.Key -> userMsg -> userModel -> ( userModel, effect ) + , update : Pages.FormState.PageFormState -> List Pages.Transition.FetcherState -> Maybe Pages.Transition.Transition -> sharedData -> pageData -> Maybe Browser.Navigation.Key -> userMsg -> userModel -> ( userModel, effect ) , subscriptions : route -> Path -> userModel -> Sub userMsg , sharedData : DataSource sharedData , data : route -> DataSource (PageServerResponse pageData errorPage) , action : route -> DataSource (PageServerResponse actionData errorPage) , onActionData : actionData -> Maybe userMsg , view : - Pages.Form.PageFormState + Pages.FormState.PageFormState -> List Pages.Transition.FetcherState -> Maybe Pages.Transition.Transition -> diff --git a/tests/FormParserTests.elm b/tests/FormParserTests.elm index 98ec999c..d8486ccb 100644 --- a/tests/FormParserTests.elm +++ b/tests/FormParserTests.elm @@ -4,8 +4,8 @@ import Date exposing (Date) import Dict exposing (Dict) import Expect import Pages.Field as Field -import Pages.Form import Pages.FormParser as FormParser exposing (field) +import Pages.FormState import Test exposing (Test, describe, test) @@ -231,11 +231,11 @@ expectNoErrors parsed = ] -field : String -> String -> ( String, Pages.Form.FieldState ) +field : String -> String -> ( String, Pages.FormState.FieldState ) field name value = ( name , { value = value - , status = Pages.Form.NotVisited + , status = Pages.FormState.NotVisited } )