mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-11-30 03:11:30 +03:00
Merge two branches into one with Elm.Pattern.
This commit is contained in:
parent
975eff210c
commit
762102e74f
@ -781,76 +781,77 @@ otherFile routes phaseString =
|
|||||||
, just =
|
, just =
|
||||||
( "justRouteAndPath"
|
( "justRouteAndPath"
|
||||||
, \justRouteAndPath ->
|
, \justRouteAndPath ->
|
||||||
branchHelper (Gen.Tuple.first justRouteAndPath)
|
Elm.Case.custom (Elm.tuple (Gen.Tuple.first justRouteAndPath) pageData)
|
||||||
(\route routeParams ->
|
Type.unit
|
||||||
Elm.Case.custom pageData
|
((routes
|
||||||
Type.unit
|
|> List.map
|
||||||
[ Elm.Case.branch1
|
(\route ->
|
||||||
("Data" ++ (RoutePattern.toModuleName route |> String.join "__"))
|
Elm.Pattern.tuple
|
||||||
( "thisPageData", Type.unit )
|
(routeToSyntaxPattern route)
|
||||||
(\thisPageData ->
|
(route |> destructureRouteVariant Data "thisPageData")
|
||||||
Elm.apply
|
|> Elm.Case.patternToBranch
|
||||||
(Elm.value
|
(\( maybeRouteParams, thisPageData ) ->
|
||||||
{ name = "route"
|
Elm.apply
|
||||||
, importFrom = "Route" :: RoutePattern.toModuleName route
|
(Elm.value
|
||||||
, annotation = Nothing
|
{ name = "route"
|
||||||
}
|
, importFrom = "Route" :: RoutePattern.toModuleName route
|
||||||
|> Elm.get "init"
|
, annotation = Nothing
|
||||||
)
|
}
|
||||||
[ Gen.Maybe.andThen (Elm.get "pageUrl") maybePagePath
|
|> Elm.get "init"
|
||||||
, sharedModel
|
)
|
||||||
, Elm.record
|
[ Gen.Maybe.andThen (Elm.get "pageUrl") maybePagePath
|
||||||
[ ( "data", thisPageData )
|
, sharedModel
|
||||||
, ( "sharedData", sharedData )
|
, Elm.record
|
||||||
, ( "action"
|
[ ( "data", thisPageData )
|
||||||
, actionData
|
, ( "sharedData", sharedData )
|
||||||
|> Gen.Maybe.andThen
|
, ( "action"
|
||||||
(\justActionData ->
|
, actionData
|
||||||
Elm.Case.custom justActionData
|
|> Gen.Maybe.andThen
|
||||||
Type.unit
|
(\justActionData ->
|
||||||
[ Elm.Case.branch1
|
Elm.Case.custom justActionData
|
||||||
("ActionData" ++ (RoutePattern.toModuleName route |> String.join "__"))
|
Type.unit
|
||||||
( "thisActionData", Type.unit )
|
[ Elm.Case.branch1
|
||||||
(\_ ->
|
("ActionData" ++ (RoutePattern.toModuleName route |> String.join "__"))
|
||||||
Elm.just (Elm.val "thisActionData")
|
( "thisActionData", Type.unit )
|
||||||
)
|
(\_ ->
|
||||||
, Elm.Case.otherwise (\_ -> Elm.nothing)
|
Elm.just (Elm.val "thisActionData")
|
||||||
]
|
)
|
||||||
)
|
, Elm.Case.otherwise (\_ -> Elm.nothing)
|
||||||
)
|
]
|
||||||
, ( "routeParams", routeParams |> Maybe.withDefault (Elm.record []) )
|
)
|
||||||
, ( "path"
|
)
|
||||||
, Elm.apply (Elm.val ".path") [ justRouteAndPath |> Gen.Tuple.second ]
|
, ( "routeParams", maybeRouteParams |> Maybe.withDefault (Elm.record []) )
|
||||||
)
|
, ( "path"
|
||||||
, ( "submit"
|
, Elm.apply (Elm.val ".path") [ justRouteAndPath |> Gen.Tuple.second ]
|
||||||
, Elm.apply
|
)
|
||||||
(Elm.value
|
, ( "submit"
|
||||||
{ importFrom = [ "Pages", "Fetcher" ]
|
, Elm.apply
|
||||||
, name = "submit"
|
(Elm.value
|
||||||
, annotation = Nothing
|
{ importFrom = [ "Pages", "Fetcher" ]
|
||||||
}
|
, name = "submit"
|
||||||
)
|
, annotation = Nothing
|
||||||
[ route |> decodeRouteType ActionData
|
}
|
||||||
|
)
|
||||||
|
[ route |> decodeRouteType ActionData
|
||||||
|
]
|
||||||
|
)
|
||||||
|
, ( "transition", Elm.nothing )
|
||||||
|
, ( "fetchers", Gen.Dict.empty )
|
||||||
|
, ( "pageFormState", Gen.Dict.empty )
|
||||||
]
|
]
|
||||||
)
|
|
||||||
, ( "transition", Elm.nothing )
|
|
||||||
, ( "fetchers", Gen.Dict.empty )
|
|
||||||
, ( "pageFormState", Gen.Dict.empty )
|
|
||||||
]
|
|
||||||
]
|
|
||||||
|> Gen.Tuple.call_.mapBoth
|
|
||||||
(route |> routeVariantExpression Model)
|
|
||||||
(Elm.apply
|
|
||||||
(Elm.value { name = "map", importFrom = [ "Effect" ], annotation = Nothing })
|
|
||||||
[ route |> routeVariantExpression Msg
|
|
||||||
]
|
]
|
||||||
)
|
|> Gen.Tuple.call_.mapBoth
|
||||||
)
|
(route |> routeVariantExpression Model)
|
||||||
, Elm.Case.otherwise
|
(Elm.apply
|
||||||
(\_ ->
|
(Elm.value { name = "map", importFrom = [ "Effect" ], annotation = Nothing })
|
||||||
initErrorPage.call pageData
|
[ route |> routeVariantExpression Msg
|
||||||
)
|
]
|
||||||
]
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
++ [ Elm.Pattern.ignore |> Elm.Case.patternToBranch (\() -> initErrorPage.call pageData)
|
||||||
|
]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user