mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-12-25 12:52:27 +03:00
Use Scaffold namespace for generator modules.
This commit is contained in:
parent
2fa6c41d72
commit
5a2545329e
3
elm.json
3
elm.json
@ -38,7 +38,8 @@
|
||||
"Form.Value",
|
||||
"Pages.FormState",
|
||||
"Pages.Transition",
|
||||
"Pages.Generate",
|
||||
"Scaffold.Route",
|
||||
"Scaffold.Form",
|
||||
"Form.Validation",
|
||||
"Pages.Script",
|
||||
"Pages.Internal.Platform",
|
||||
|
@ -1,6 +1,5 @@
|
||||
module AddRoute exposing (run)
|
||||
|
||||
import AddFormHelp
|
||||
import BackendTask
|
||||
import Cli.Option as Option
|
||||
import Cli.OptionsParser as OptionsParser
|
||||
@ -24,13 +23,14 @@ import Gen.Platform.Sub
|
||||
import Gen.Server.Request as Request
|
||||
import Gen.Server.Response as Response
|
||||
import Gen.View
|
||||
import Pages.Generate exposing (Type(..))
|
||||
import Pages.Script as Script exposing (Script)
|
||||
import Scaffold.Form
|
||||
import Scaffold.Route exposing (Type(..))
|
||||
|
||||
|
||||
type alias CliOptions =
|
||||
{ moduleName : List String
|
||||
, fields : List ( String, AddFormHelp.Kind )
|
||||
, fields : List ( String, Scaffold.Form.Kind )
|
||||
}
|
||||
|
||||
|
||||
@ -50,8 +50,8 @@ program =
|
||||
Program.config
|
||||
|> Program.add
|
||||
(OptionsParser.build CliOptions
|
||||
|> OptionsParser.with (Option.requiredPositionalArg "module" |> Pages.Generate.moduleNameCliArg)
|
||||
|> OptionsParser.withRestArgs AddFormHelp.restArgsParser
|
||||
|> OptionsParser.with (Option.requiredPositionalArg "module" |> Scaffold.Route.moduleNameCliArg)
|
||||
|> OptionsParser.withRestArgs Scaffold.Form.restArgsParser
|
||||
)
|
||||
|
||||
|
||||
@ -65,7 +65,7 @@ createFile { moduleName, fields } =
|
||||
, declarations : List Elm.Declaration
|
||||
}
|
||||
formHelpers =
|
||||
AddFormHelp.provide
|
||||
Scaffold.Form.provide
|
||||
{ fields = fields
|
||||
, elmCssView = False
|
||||
, view =
|
||||
@ -108,7 +108,7 @@ createFile { moduleName, fields } =
|
||||
|> Elm.Let.toExpression
|
||||
}
|
||||
in
|
||||
Pages.Generate.serverRender
|
||||
Scaffold.Route.serverRender
|
||||
{ moduleName = moduleName
|
||||
, action =
|
||||
( Alias
|
||||
@ -171,13 +171,13 @@ createFile { moduleName, fields } =
|
||||
)
|
||||
, head = \app -> Elm.list []
|
||||
}
|
||||
|> Pages.Generate.addDeclarations
|
||||
|> Scaffold.Route.addDeclarations
|
||||
(formHelpers
|
||||
|> Maybe.map .declarations
|
||||
|> Maybe.map ((::) errorsView.declaration)
|
||||
|> Maybe.withDefault []
|
||||
)
|
||||
|> Pages.Generate.buildWithLocalState
|
||||
|> Scaffold.Route.buildWithLocalState
|
||||
{ view =
|
||||
\{ maybeUrl, sharedModel, model, app } ->
|
||||
Gen.View.make_.view
|
||||
|
@ -28,7 +28,7 @@ import Gen.Server.Request
|
||||
import Gen.Server.Response
|
||||
import Gen.View
|
||||
import List.Extra
|
||||
import Pages.Generate exposing (Type(..))
|
||||
import Pages.Route exposing (Type(..))
|
||||
import Pages.Script as Script exposing (Script)
|
||||
|
||||
|
||||
@ -291,7 +291,7 @@ createFile moduleName fields =
|
||||
form =
|
||||
formWithFields fields
|
||||
in
|
||||
Pages.Generate.serverRender
|
||||
Pages.Route.serverRender
|
||||
{ moduleName = moduleName
|
||||
, action =
|
||||
( Alias
|
||||
@ -336,7 +336,7 @@ createFile moduleName fields =
|
||||
)
|
||||
, head = \app -> Elm.list []
|
||||
}
|
||||
|> Pages.Generate.addDeclarations
|
||||
|> Pages.Route.addDeclarations
|
||||
[ formWithFields fields |> .declaration
|
||||
, Elm.alias "ParsedForm"
|
||||
(fields
|
||||
@ -370,7 +370,7 @@ createFile moduleName fields =
|
||||
)
|
||||
, errorsView.declaration
|
||||
]
|
||||
|> Pages.Generate.buildWithLocalState
|
||||
|> Pages.Route.buildWithLocalState
|
||||
{ view =
|
||||
\{ maybeUrl, sharedModel, model, app } ->
|
||||
Gen.View.make_.view
|
||||
|
@ -15,7 +15,7 @@ import Gen.Platform.Sub
|
||||
import Gen.Server.Request
|
||||
import Gen.Server.Response
|
||||
import Gen.View
|
||||
import Pages.Generate exposing (Type(..))
|
||||
import Pages.Route exposing (Type(..))
|
||||
import Pages.Script as Script exposing (Script)
|
||||
|
||||
|
||||
@ -60,7 +60,7 @@ moduleNameRegex =
|
||||
|
||||
buildFile : List String -> Elm.File
|
||||
buildFile moduleName =
|
||||
Pages.Generate.serverRender
|
||||
Pages.Route.serverRender
|
||||
{ moduleName = moduleName
|
||||
, action =
|
||||
( Alias (Elm.Annotation.record [])
|
||||
@ -84,7 +84,7 @@ buildFile moduleName =
|
||||
)
|
||||
, head = \app -> Elm.list []
|
||||
}
|
||||
|> Pages.Generate.buildWithLocalState
|
||||
|> Pages.Route.buildWithLocalState
|
||||
{ view =
|
||||
\{ maybeUrl, sharedModel, model, app } ->
|
||||
Gen.View.make_.view
|
||||
|
@ -1,6 +1,15 @@
|
||||
module AddFormHelp exposing (Kind(..), parseField, provide, restArgsParser)
|
||||
module Scaffold.Form exposing
|
||||
( Kind(..), provide, restArgsParser
|
||||
, Context
|
||||
)
|
||||
|
||||
{-| -}
|
||||
{-|
|
||||
|
||||
@docs Kind, provide, restArgsParser
|
||||
|
||||
@docs Context
|
||||
|
||||
-}
|
||||
|
||||
import Cli.Option
|
||||
import Elm
|
||||
@ -21,6 +30,7 @@ type Kind
|
||||
| FieldCheckbox
|
||||
|
||||
|
||||
{-| -}
|
||||
type alias Context =
|
||||
{ errors : Elm.Expression
|
||||
, isTransitioning : Elm.Expression
|
||||
@ -150,6 +160,7 @@ fieldToParam ( name, kind ) =
|
||||
( name, Nothing )
|
||||
|
||||
|
||||
{-| -}
|
||||
restArgsParser : Cli.Option.Option (List String) (List ( String, Kind )) Cli.Option.RestArgsOption
|
||||
restArgsParser =
|
||||
Cli.Option.restArgs "formFields"
|
||||
@ -161,7 +172,6 @@ restArgsParser =
|
||||
)
|
||||
|
||||
|
||||
{-| -}
|
||||
parseField : String -> Result String ( String, Kind )
|
||||
parseField rawField =
|
||||
case String.split ":" rawField of
|
@ -1,4 +1,4 @@
|
||||
module Pages.Generate exposing
|
||||
module Scaffold.Route exposing
|
||||
( buildWithLocalState, buildWithSharedState, buildNoState, Builder
|
||||
, Type(..)
|
||||
, serverRender
|
Loading…
Reference in New Issue
Block a user