mirror of
https://github.com/dillonkearns/elm-pages.git
synced 2024-09-11 09:05:28 +03:00
Update AddStaticRoute script.
This commit is contained in:
parent
e8221ff85f
commit
cf55583108
@ -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" ]
|
||||
]
|
||||
)
|
||||
)
|
||||
|
@ -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" ]
|
||||
]
|
||||
)
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user