Update AddStaticRoute script.

This commit is contained in:
Dillon Kearns 2024-01-09 13:27:27 -08:00
parent e8221ff85f
commit cf55583108
2 changed files with 6 additions and 112 deletions

View File

@ -7,13 +7,9 @@ import Cli.Program as Program
import Elm
import Elm.Annotation as Type
import Elm.Case
import Elm.Declare
import Gen.BackendTask
import Gen.Effect as Effect
import Gen.Form as Form
import Gen.Html as Html
import Gen.Html.Attributes as Attr
import Gen.List
import Gen.Platform.Sub
import Gen.View
import Pages.Script as Script exposing (Script)
@ -49,7 +45,9 @@ createFile : CliOptions -> { path : String, body : String }
createFile { moduleName } =
Scaffold.Route.preRender
{ moduleName = moduleName
, pages = Gen.BackendTask.succeed (Elm.list [])
, pages =
Gen.BackendTask.succeed
(Elm.list [])
, data =
( Alias (Type.record [])
, \routeParams ->
@ -87,54 +85,3 @@ createFile { moduleName } =
, msg =
Custom [ Elm.variant "NoOp" ]
}
errorsView :
{ declaration : Elm.Declaration
, call : Elm.Expression -> Elm.Expression -> Elm.Expression
, callFrom : List String -> Elm.Expression -> Elm.Expression -> Elm.Expression
, value : List String -> Elm.Expression
}
errorsView =
Elm.Declare.fn2 "errorsView"
( "errors", Type.namedWith [ "Form" ] "Errors" [ Type.string ] |> Just )
( "field"
, Type.namedWith [ "Form", "Validation" ]
"Field"
[ Type.string
, Type.var "parsed"
, Type.var "kind"
]
|> Just
)
(\errors field ->
Elm.ifThen
(Gen.List.call_.isEmpty (Form.errorsForField field errors))
(Html.div [] [])
(Html.div
[]
[ Html.call_.ul (Elm.list [])
(Gen.List.call_.map
(Elm.fn ( "error", Nothing )
(\error ->
Html.li
[ Attr.style "color" "red"
]
[ Html.call_.text error
]
)
)
(Form.errorsForField field errors)
)
]
)
|> Elm.withType
(Type.namedWith [ "Html" ]
"Html"
[ Type.namedWith
[ "PagesMsg" ]
"PagesMsg"
[ Type.named [] "Msg" ]
]
)
)

View File

@ -7,13 +7,9 @@ import Cli.Program as Program
import Elm
import Elm.Annotation as Type
import Elm.Case
import Elm.Declare
import Gen.BackendTask
import Gen.Effect as Effect
import Gen.Form as Form
import Gen.Html as Html
import Gen.Html.Attributes as Attr
import Gen.List
import Gen.Platform.Sub
import Gen.View
import Pages.Script as Script exposing (Script)
@ -49,7 +45,9 @@ createFile : CliOptions -> { path : String, body : String }
createFile { moduleName } =
Scaffold.Route.preRender
{ moduleName = moduleName
, pages = Gen.BackendTask.succeed (Elm.list [])
, pages =
Gen.BackendTask.succeed
(Elm.list [])
, data =
( Alias (Type.record [])
, \routeParams ->
@ -87,54 +85,3 @@ createFile { moduleName } =
, msg =
Custom [ Elm.variant "NoOp" ]
}
errorsView :
{ declaration : Elm.Declaration
, call : Elm.Expression -> Elm.Expression -> Elm.Expression
, callFrom : List String -> Elm.Expression -> Elm.Expression -> Elm.Expression
, value : List String -> Elm.Expression
}
errorsView =
Elm.Declare.fn2 "errorsView"
( "errors", Type.namedWith [ "Form" ] "Errors" [ Type.string ] |> Just )
( "field"
, Type.namedWith [ "Form", "Validation" ]
"Field"
[ Type.string
, Type.var "parsed"
, Type.var "kind"
]
|> Just
)
(\errors field ->
Elm.ifThen
(Gen.List.call_.isEmpty (Form.errorsForField field errors))
(Html.div [] [])
(Html.div
[]
[ Html.call_.ul (Elm.list [])
(Gen.List.call_.map
(Elm.fn ( "error", Nothing )
(\error ->
Html.li
[ Attr.style "color" "red"
]
[ Html.call_.text error
]
)
)
(Form.errorsForField field errors)
)
]
)
|> Elm.withType
(Type.namedWith [ "Html" ]
"Html"
[ Type.namedWith
[ "PagesMsg" ]
"PagesMsg"
[ Type.named [] "Msg" ]
]
)
)