Skip to content

Commit

Permalink
Fixed new line missing in generated code in Routes.hs
Browse files Browse the repository at this point in the history
  • Loading branch information
mpscholten committed Nov 1, 2020
1 parent 05f7266 commit e21f5d7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion IHP/IDE/CodeGen/ControllerGenerator.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ buildPlan' schema applicationName controllerName modelName =
viewPlans = generateViews schema applicationName controllerName
in
[ CreateFile { filePath = applicationName <> "/Controller/" <> controllerName <> ".hs", fileContent = (generateController schema config) }
, AppendToFile { filePath = applicationName <> "/Routes.hs", fileContent = (controllerInstance config) }
, AppendToFile { filePath = applicationName <> "/Routes.hs", fileContent = "\n" <> (controllerInstance config) }
, AppendToFile { filePath = applicationName <> "/Types.hs", fileContent = (generateControllerData config) }
, AppendToMarker { marker = "-- Controller Imports", filePath = applicationName <> "/FrontController.hs", fileContent = ("import " <> applicationName <> ".Controller." <> controllerName) }
, AppendToMarker { marker = "-- Generator Marker", filePath = applicationName <> "/FrontController.hs", fileContent = (" , parseRoute @" <> controllerName <> "Controller") }
Expand Down
8 changes: 4 additions & 4 deletions Test/IDE/CodeGeneration/ControllerGenerator.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ tests = do

builtPlan `shouldBe` [
CreateFile {filePath = "Web/Controller/Pages.hs", fileContent = "module Web.Controller.Pages where\n\nimport Web.Controller.Prelude\nimport Web.View.Pages.Index\nimport Web.View.Pages.New\nimport Web.View.Pages.Edit\nimport Web.View.Pages.Show\n\ninstance Controller PagesController where\n action PagesAction = do\n pages <- query @Page |> fetch\n render IndexView { .. }\n\n action NewPageAction = do\n let page = newRecord\n render NewView { .. }\n\n action ShowPageAction { pageId } = do\n page <- fetch pageId\n render ShowView { .. }\n\n action EditPageAction { pageId } = do\n page <- fetch pageId\n render EditView { .. }\n\n action UpdatePageAction { pageId } = do\n page <- fetch pageId\n page\n |> buildPage\n |> ifValid \\case\n Left page -> render EditView { .. }\n Right page -> do\n page <- page |> updateRecord\n setSuccessMessage \"Page updated\"\n redirectTo EditPageAction { .. }\n\n action CreatePageAction = do\n let page = newRecord @Page\n page\n |> buildPage\n |> ifValid \\case\n Left page -> render NewView { .. } \n Right page -> do\n page <- page |> createRecord\n setSuccessMessage \"Page created\"\n redirectTo PagesAction\n\n action DeletePageAction { pageId } = do\n page <- fetch pageId\n deleteRecord page\n setSuccessMessage \"Page deleted\"\n redirectTo PagesAction\n\nbuildPage page = page\n |> fill @'[]\n"}
, AppendToFile {filePath = "Web/Routes.hs", fileContent = "instance AutoRoute PagesController\ntype instance ModelControllerMap WebApplication Page = PagesController\n\n"}
, AppendToFile {filePath = "Web/Routes.hs", fileContent = "\ninstance AutoRoute PagesController\ntype instance ModelControllerMap WebApplication Page = PagesController\n\n"}
, AppendToFile {filePath = "Web/Types.hs", fileContent = "\ndata PagesController\n = PagesAction\n | NewPageAction\n | ShowPageAction { pageId :: !(Id Page) }\n | CreatePageAction\n | EditPageAction { pageId :: !(Id Page) }\n | UpdatePageAction { pageId :: !(Id Page) }\n | DeletePageAction { pageId :: !(Id Page) }\n deriving (Eq, Show, Data)\n"}
, AppendToMarker {marker = "-- Controller Imports", filePath = "Web/FrontController.hs", fileContent = "import Web.Controller.Pages"}
, AppendToMarker {marker = "-- Generator Marker", filePath = "Web/FrontController.hs", fileContent = " , parseRoute @PagesController"}
Expand All @@ -68,7 +68,7 @@ tests = do

builtPlan `shouldBe` [
CreateFile {filePath = "Web/Controller/Page.hs", fileContent = "module Web.Controller.Page where\n\nimport Web.Controller.Prelude\nimport Web.View.Page.Index\nimport Web.View.Page.New\nimport Web.View.Page.Edit\nimport Web.View.Page.Show\n\ninstance Controller PageController where\n action PagesAction = do\n page <- query @Page |> fetch\n render IndexView { .. }\n\n action NewPageAction = do\n let page = newRecord\n render NewView { .. }\n\n action ShowPageAction { pageId } = do\n page <- fetch pageId\n render ShowView { .. }\n\n action EditPageAction { pageId } = do\n page <- fetch pageId\n render EditView { .. }\n\n action UpdatePageAction { pageId } = do\n page <- fetch pageId\n page\n |> buildPage\n |> ifValid \\case\n Left page -> render EditView { .. }\n Right page -> do\n page <- page |> updateRecord\n setSuccessMessage \"Page updated\"\n redirectTo EditPageAction { .. }\n\n action CreatePageAction = do\n let page = newRecord @Page\n page\n |> buildPage\n |> ifValid \\case\n Left page -> render NewView { .. } \n Right page -> do\n page <- page |> createRecord\n setSuccessMessage \"Page created\"\n redirectTo PagesAction\n\n action DeletePageAction { pageId } = do\n page <- fetch pageId\n deleteRecord page\n setSuccessMessage \"Page deleted\"\n redirectTo PagesAction\n\nbuildPage page = page\n |> fill @'[]\n"}
, AppendToFile {filePath = "Web/Routes.hs", fileContent = "instance AutoRoute PageController\ntype instance ModelControllerMap WebApplication Page = PageController\n\n"}
, AppendToFile {filePath = "Web/Routes.hs", fileContent = "\ninstance AutoRoute PageController\ntype instance ModelControllerMap WebApplication Page = PageController\n\n"}
, AppendToFile {filePath = "Web/Types.hs", fileContent = "\ndata PageController\n = PagesAction\n | NewPageAction\n | ShowPageAction { pageId :: !(Id Page) }\n | CreatePageAction\n | EditPageAction { pageId :: !(Id Page) }\n | UpdatePageAction { pageId :: !(Id Page) }\n | DeletePageAction { pageId :: !(Id Page) }\n deriving (Eq, Show, Data)\n"}
, AppendToMarker {marker = "-- Controller Imports", filePath = "Web/FrontController.hs", fileContent = "import Web.Controller.Page"}
, AppendToMarker {marker = "-- Generator Marker", filePath = "Web/FrontController.hs", fileContent = " , parseRoute @PageController"}
Expand All @@ -95,7 +95,7 @@ tests = do

builtPlan `shouldBe` [
CreateFile {filePath = "Web/Controller/PageComment.hs", fileContent = "module Web.Controller.PageComment where\n\nimport Web.Controller.Prelude\nimport Web.View.PageComment.Index\nimport Web.View.PageComment.New\nimport Web.View.PageComment.Edit\nimport Web.View.PageComment.Show\n\ninstance Controller PageCommentController where\n action PageCommentsAction = do\n pageComment <- query @PageComment |> fetch\n render IndexView { .. }\n\n action NewPageCommentAction = do\n let pageComment = newRecord\n render NewView { .. }\n\n action ShowPageCommentAction { pageCommentId } = do\n pageComment <- fetch pageCommentId\n render ShowView { .. }\n\n action EditPageCommentAction { pageCommentId } = do\n pageComment <- fetch pageCommentId\n render EditView { .. }\n\n action UpdatePageCommentAction { pageCommentId } = do\n pageComment <- fetch pageCommentId\n pageComment\n |> buildPageComment\n |> ifValid \\case\n Left pageComment -> render EditView { .. }\n Right pageComment -> do\n pageComment <- pageComment |> updateRecord\n setSuccessMessage \"PageComment updated\"\n redirectTo EditPageCommentAction { .. }\n\n action CreatePageCommentAction = do\n let pageComment = newRecord @PageComment\n pageComment\n |> buildPageComment\n |> ifValid \\case\n Left pageComment -> render NewView { .. } \n Right pageComment -> do\n pageComment <- pageComment |> createRecord\n setSuccessMessage \"PageComment created\"\n redirectTo PageCommentsAction\n\n action DeletePageCommentAction { pageCommentId } = do\n pageComment <- fetch pageCommentId\n deleteRecord pageComment\n setSuccessMessage \"PageComment deleted\"\n redirectTo PageCommentsAction\n\nbuildPageComment pageComment = pageComment\n |> fill @'[]\n"}
, AppendToFile {filePath = "Web/Routes.hs", fileContent = "instance AutoRoute PageCommentController\ntype instance ModelControllerMap WebApplication PageComment = PageCommentController\n\n"}
, AppendToFile {filePath = "Web/Routes.hs", fileContent = "\ninstance AutoRoute PageCommentController\ntype instance ModelControllerMap WebApplication PageComment = PageCommentController\n\n"}
, AppendToFile {filePath = "Web/Types.hs", fileContent = "\ndata PageCommentController\n = PageCommentsAction\n | NewPageCommentAction\n | ShowPageCommentAction { pageCommentId :: !(Id PageComment) }\n | CreatePageCommentAction\n | EditPageCommentAction { pageCommentId :: !(Id PageComment) }\n | UpdatePageCommentAction { pageCommentId :: !(Id PageComment) }\n | DeletePageCommentAction { pageCommentId :: !(Id PageComment) }\n deriving (Eq, Show, Data)\n"}
, AppendToMarker {marker = "-- Controller Imports", filePath = "Web/FrontController.hs", fileContent = "import Web.Controller.PageComment"}
, AppendToMarker {marker = "-- Generator Marker", filePath = "Web/FrontController.hs", fileContent = " , parseRoute @PageCommentController"}
Expand All @@ -121,7 +121,7 @@ tests = do

builtPlan `shouldBe` [
CreateFile {filePath = "Web/Controller/PageComment.hs", fileContent = "module Web.Controller.PageComment where\n\nimport Web.Controller.Prelude\nimport Web.View.PageComment.Index\nimport Web.View.PageComment.New\nimport Web.View.PageComment.Edit\nimport Web.View.PageComment.Show\n\ninstance Controller PageCommentController where\n action PageCommentsAction = do\n pageComment <- query @PageComment |> fetch\n render IndexView { .. }\n\n action NewPageCommentAction = do\n let pageComment = newRecord\n render NewView { .. }\n\n action ShowPageCommentAction { pageCommentId } = do\n pageComment <- fetch pageCommentId\n render ShowView { .. }\n\n action EditPageCommentAction { pageCommentId } = do\n pageComment <- fetch pageCommentId\n render EditView { .. }\n\n action UpdatePageCommentAction { pageCommentId } = do\n pageComment <- fetch pageCommentId\n pageComment\n |> buildPageComment\n |> ifValid \\case\n Left pageComment -> render EditView { .. }\n Right pageComment -> do\n pageComment <- pageComment |> updateRecord\n setSuccessMessage \"PageComment updated\"\n redirectTo EditPageCommentAction { .. }\n\n action CreatePageCommentAction = do\n let pageComment = newRecord @PageComment\n pageComment\n |> buildPageComment\n |> ifValid \\case\n Left pageComment -> render NewView { .. } \n Right pageComment -> do\n pageComment <- pageComment |> createRecord\n setSuccessMessage \"PageComment created\"\n redirectTo PageCommentsAction\n\n action DeletePageCommentAction { pageCommentId } = do\n pageComment <- fetch pageCommentId\n deleteRecord pageComment\n setSuccessMessage \"PageComment deleted\"\n redirectTo PageCommentsAction\n\nbuildPageComment pageComment = pageComment\n |> fill @'[]\n"}
, AppendToFile {filePath = "Web/Routes.hs", fileContent = "instance AutoRoute PageCommentController\ntype instance ModelControllerMap WebApplication PageComment = PageCommentController\n\n"}
, AppendToFile {filePath = "Web/Routes.hs", fileContent = "\ninstance AutoRoute PageCommentController\ntype instance ModelControllerMap WebApplication PageComment = PageCommentController\n\n"}
, AppendToFile {filePath = "Web/Types.hs", fileContent = "\ndata PageCommentController\n = PageCommentsAction\n | NewPageCommentAction\n | ShowPageCommentAction { pageCommentId :: !(Id PageComment) }\n | CreatePageCommentAction\n | EditPageCommentAction { pageCommentId :: !(Id PageComment) }\n | UpdatePageCommentAction { pageCommentId :: !(Id PageComment) }\n | DeletePageCommentAction { pageCommentId :: !(Id PageComment) }\n deriving (Eq, Show, Data)\n"}
, AppendToMarker {marker = "-- Controller Imports", filePath = "Web/FrontController.hs", fileContent = "import Web.Controller.PageComment"}
, AppendToMarker {marker = "-- Generator Marker", filePath = "Web/FrontController.hs", fileContent = " , parseRoute @PageCommentController"}
Expand Down

0 comments on commit e21f5d7

Please sign in to comment.