fixes some minor migration regressions

Sun, 04 Apr 2021 13:03:41 +0200

author
Mike Becker <universe@uap-core.de>
date
Sun, 04 Apr 2021 13:03:41 +0200
changeset 186
05eec764facd
parent 185
5ec9fcfbdf9c
child 187
0bf35031a918

fixes some minor migration regressions

src/main/kotlin/de/uapcore/lightpit/entities/Issue.kt file | annotate | diff | comparison | revisions
src/main/kotlin/de/uapcore/lightpit/servlet/ProjectServlet.kt file | annotate | diff | comparison | revisions
src/main/kotlin/de/uapcore/lightpit/viewmodel/Issues.kt file | annotate | diff | comparison | revisions
src/main/webapp/WEB-INF/jsp/issue-form.jsp file | annotate | diff | comparison | revisions
--- a/src/main/kotlin/de/uapcore/lightpit/entities/Issue.kt	Sun Apr 04 11:52:30 2021 +0200
+++ b/src/main/kotlin/de/uapcore/lightpit/entities/Issue.kt	Sun Apr 04 13:03:41 2021 +0200
@@ -38,7 +38,7 @@
     var category = IssueCategory.Feature
 
     var subject: String = ""
-    var description: String = ""
+    var description: String? = null
     var assignee: User? = null
 
     var created: Timestamp = Timestamp.from(Instant.now())
--- a/src/main/kotlin/de/uapcore/lightpit/servlet/ProjectServlet.kt	Sun Apr 04 11:52:30 2021 +0200
+++ b/src/main/kotlin/de/uapcore/lightpit/servlet/ProjectServlet.kt	Sun Apr 04 13:03:41 2021 +0200
@@ -63,9 +63,9 @@
 
         get("/%project/issues/%version/%component/%issue", this::issue)
         get("/%project/issues/%version/%component/%issue/edit", this::issueForm)
-        get("/%project/issues/%version/%component/%issue/comment", this::issueComment)
+        post("/%project/issues/%version/%component/%issue/comment", this::issueComment)
         get("/%project/issues/%version/%component/-/create", this::issueForm)
-        get("/%project/issues/%version/%component/-/commit", this::issueCommit)
+        post("/%project/issues/%version/%component/-/commit", this::issueCommit)
     }
 
     fun projects(http: HttpRequest, dao: DataAccessObject) {
@@ -508,7 +508,7 @@
                         else -> dao.findUser(it)
                     }
                 }
-                eta = http.param("eta")?.let { Date.valueOf(it) }
+                eta = http.param("eta")?.let { if (it.isBlank()) null else Date.valueOf(it) }
 
                 affectedVersions = http.paramArray("affected")
                     .mapNotNull { param -> param.toIntOrNull()?.let { Version(it, projectInfo.project.id) } }
@@ -516,10 +516,17 @@
                     .mapNotNull { param -> param.toIntOrNull()?.let { Version(it, projectInfo.project.id) } }
             }
 
-            if (http.param("more").toBoolean()) {
+            val openId = if (issue.id < 0) {
+                dao.insertIssue(issue)
+            } else {
+                dao.updateIssue(issue)
+                issue.id
+            }
+
+            if (http.param("more") != null) {
                 http.renderCommit("${issuesHref}-/create")
             } else {
-                http.renderCommit("${issuesHref}${issue.id}")
+                http.renderCommit("${issuesHref}${openId}")
             }
         }
     }
--- a/src/main/kotlin/de/uapcore/lightpit/viewmodel/Issues.kt	Sun Apr 04 11:52:30 2021 +0200
+++ b/src/main/kotlin/de/uapcore/lightpit/viewmodel/Issues.kt	Sun Apr 04 13:03:41 2021 +0200
@@ -76,7 +76,7 @@
         val renderer = HtmlRenderer.builder(options).build()
         val process = fun(it: String) = renderer.render(parser.parse(it))
 
-        issue.description = process(issue.description)
+        issue.description = process(issue.description?:"")
         for (comment in comments) {
             comment.comment = process(comment.comment)
         }
@@ -111,8 +111,8 @@
                 upcoming.add(v)
             }
         }
-        versionsRecent = recent
-        versionsUpcoming = upcoming
+        versionsRecent = recent.distinct()
+        versionsUpcoming = upcoming.distinct()
     }
 }
 
--- a/src/main/webapp/WEB-INF/jsp/issue-form.jsp	Sun Apr 04 11:52:30 2021 +0200
+++ b/src/main/webapp/WEB-INF/jsp/issue-form.jsp	Sun Apr 04 13:03:41 2021 +0200
@@ -37,7 +37,7 @@
 
 <c:set var="issuesHref" value="./projects/${project.node}/issues/${empty version ? '-' : version.node }/${empty component ? '-' : component.node}/"/>
 
-<form action="${issuesHref}-/commit-issue" method="post">
+<form action="${issuesHref}-/commit" method="post">
     <table class="formtable fullwidth">
         <colgroup>
             <col>
@@ -89,11 +89,11 @@
             <td>
                 <select name="component">
                     <option value="-1"><fmt:message key="placeholder.null-component"/></option>
-                    <c:forEach var="component" items="${viewmodel.components}">
+                    <c:forEach var="comp" items="${viewmodel.components}">
                         <option
-                                <c:if test="${not empty issue.component and component eq issue.component}">selected</c:if>
-                                <c:if test="${empty issue.component and component.id eq cid}">selected</c:if>
-                                value="${component.id}"><c:out value="${component.name}"/></option>
+                                <c:if test="${not empty issue.component and comp eq issue.component}">selected</c:if>
+                                <c:if test="${empty issue.component and comp eq comp}">selected</c:if>
+                                value="${comp.id}"><c:out value="${comp.name}"/></option>
                     </c:forEach>
                 </select>
             </td>

mercurial