only show relevant versions in issue editor

Sun, 21 Jun 2020 11:56:36 +0200

author
Mike Becker <universe@uap-core.de>
date
Sun, 21 Jun 2020 11:56:36 +0200
changeset 90
2c74e36752f9
parent 89
c69d5cb11d6c
child 91
c3a6c65b3729

only show relevant versions in issue editor

src/main/java/de/uapcore/lightpit/entities/VersionStatus.java file | annotate | diff | comparison | revisions
src/main/java/de/uapcore/lightpit/viewmodel/IssueEditView.java file | annotate | diff | comparison | revisions
src/main/java/de/uapcore/lightpit/viewmodel/ProjectInfo.java file | annotate | diff | comparison | revisions
src/main/webapp/WEB-INF/jsp/issue-form.jsp file | annotate | diff | comparison | revisions
src/main/webapp/WEB-INF/jspf/version-list.jsp file | annotate | diff | comparison | revisions
--- a/src/main/java/de/uapcore/lightpit/entities/VersionStatus.java	Sun Jun 21 11:43:08 2020 +0200
+++ b/src/main/java/de/uapcore/lightpit/entities/VersionStatus.java	Sun Jun 21 11:56:36 2020 +0200
@@ -33,5 +33,9 @@
     Unreleased,
     Released,
     LTS,
-    Deprecated
+    Deprecated;
+
+    public boolean isReleased() {
+        return ordinal() >= VersionStatus.Released.ordinal();
+    }
 }
--- a/src/main/java/de/uapcore/lightpit/viewmodel/IssueEditView.java	Sun Jun 21 11:43:08 2020 +0200
+++ b/src/main/java/de/uapcore/lightpit/viewmodel/IssueEditView.java	Sun Jun 21 11:56:36 2020 +0200
@@ -2,6 +2,7 @@
 
 import de.uapcore.lightpit.entities.*;
 
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
@@ -9,7 +10,8 @@
     private final Issue issue;
 
     private List<Project> projects = Collections.emptyList();
-    private List<Version> versions = Collections.emptyList();
+    private List<Version> versionsUpcoming = new ArrayList<>();
+    private List<Version> versionsRecent = new ArrayList<>();
     private List<User> users;
 
     public IssueEditView(Issue issue) {
@@ -28,12 +30,24 @@
         this.projects = projects;
     }
 
-    public List<Version> getVersions() {
-        return versions;
+    public List<Version> getVersionsUpcoming() {
+        return versionsUpcoming;
+    }
+
+    public List<Version> getVersionsRecent() {
+        return versionsRecent;
     }
 
     public void setVersions(List<Version> versions) {
-        this.versions = versions;
+        versionsRecent.clear();
+        versionsUpcoming.clear();
+        for (var v : versions) {
+            if (v.getStatus().isReleased()) {
+                versionsRecent.add(v);
+            } else {
+                versionsUpcoming.add(v);
+            }
+        }
     }
 
     public List<User> getUsers() {
--- a/src/main/java/de/uapcore/lightpit/viewmodel/ProjectInfo.java	Sun Jun 21 11:43:08 2020 +0200
+++ b/src/main/java/de/uapcore/lightpit/viewmodel/ProjectInfo.java	Sun Jun 21 11:56:36 2020 +0200
@@ -3,7 +3,6 @@
 import de.uapcore.lightpit.entities.IssueSummary;
 import de.uapcore.lightpit.entities.Project;
 import de.uapcore.lightpit.entities.Version;
-import de.uapcore.lightpit.entities.VersionStatus;
 
 import java.util.Collections;
 import java.util.List;
@@ -31,17 +30,19 @@
     }
 
     public Version getLatestVersion() {
+        // expects versions to be sorted by status descending
         for (var v : versions) {
-            if (v.getStatus().ordinal() >= VersionStatus.Released.ordinal())
+            if (v.getStatus().isReleased())
                 return v;
         }
         return null;
     }
 
     public Version getNextVersion() {
+        // expects versions to be sorted by status descending
         Version next = null;
         for (var v : versions) {
-            if (v.getStatus().ordinal() >= VersionStatus.Released.ordinal())
+            if (v.getStatus().isReleased())
                 break;
             next = v;
         }
--- a/src/main/webapp/WEB-INF/jsp/issue-form.jsp	Sun Jun 21 11:43:08 2020 +0200
+++ b/src/main/webapp/WEB-INF/jsp/issue-form.jsp	Sun Jun 21 11:56:36 2020 +0200
@@ -30,7 +30,6 @@
 
 <jsp:useBean id="viewmodel" type="de.uapcore.lightpit.viewmodel.IssueEditView" scope="request"/>
 <c:set var="issue" scope="page" value="${viewmodel.issue}" />
-<c:set var="versions" value="${viewmodel.versions}" />
 
 <form action="./projects/issues/commit" method="post">
     <table class="formtable">
@@ -115,6 +114,7 @@
             <th class="vtop"><fmt:message key="issue.affected-versions"/></th>
             <td>
                 <c:set var="fieldname" value="affected"/>
+                <c:set var="selectionList" value="${viewmodel.versionsRecent}"/>
                 <c:set var="data" value="${issue.affectedVersions}" />
                 <%@include file="../jspf/version-list.jsp"%>
             </td>
@@ -123,6 +123,7 @@
             <th class="vtop"><fmt:message key="issue.resolved-versions"/></th>
             <td>
                 <c:set var="fieldname" value="resolved"/>
+                <c:set var="selectionList" value="${viewmodel.versionsUpcoming}"/>
                 <c:set var="data" value="${issue.resolvedVersions}" />
                 <%@include file="../jspf/version-list.jsp"%>
             </td>
--- a/src/main/webapp/WEB-INF/jspf/version-list.jsp	Sun Jun 21 11:43:08 2020 +0200
+++ b/src/main/webapp/WEB-INF/jspf/version-list.jsp	Sun Jun 21 11:56:36 2020 +0200
@@ -1,13 +1,13 @@
 <%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
 
 <select name="${fieldname}" multiple>
-    <c:forEach var="version" items="${versions}">
-        <option value="${version.id}"
+    <c:forEach var="vselitem" items="${selectionList}">
+        <option value="${vselitem.id}"
                 <c:forEach var="v" items="${data}">
-                    <c:if test="${v eq version}">selected</c:if>
+                    <c:if test="${v eq vselitem}">selected</c:if>
                 </c:forEach>
         >
-            <c:out value="${version.name}" />
+            <c:out value="${vselitem.name}" />
         </option>
     </c:forEach>
 </select>

mercurial