Sat, 05 Jun 2021 09:04:13 +0200
fixes project creation not working
src/main/kotlin/de/uapcore/lightpit/servlet/ProjectServlet.kt | file | annotate | diff | comparison | revisions |
--- a/src/main/kotlin/de/uapcore/lightpit/servlet/ProjectServlet.kt Sat May 15 16:19:29 2021 +0200 +++ b/src/main/kotlin/de/uapcore/lightpit/servlet/ProjectServlet.kt Sat Jun 05 09:04:13 2021 +0200 @@ -210,21 +210,23 @@ } private fun projectForm(http: HttpRequest, dao: DataAccessObject) { - val projectInfo = obtainProjectInfo(http, dao) - if (projectInfo == null) { - http.response.sendError(404) - return - } - - with(http) { - view = ProjectEditView(projectInfo.project, dao.listUsers()) - navigationMenu = activeProjectNavMenu( + if (!http.pathParams.containsKey("project")) { + http.view = ProjectEditView(Project(-1), dao.listUsers()) + http.navigationMenu = projectNavMenu(dao.listProjects()) + } else { + val projectInfo = obtainProjectInfo(http, dao) + if (projectInfo == null) { + http.response.sendError(404) + return + } + http.view = ProjectEditView(projectInfo.project, dao.listUsers()) + http.navigationMenu = activeProjectNavMenu( dao.listProjects(), projectInfo ) - styleSheets = listOf("projects") - render("project-form") } + http.styleSheets = listOf("projects") + http.render("project-form") } private fun projectCommit(http: HttpRequest, dao: DataAccessObject) {