src/main/webapp/WEB-INF/jsp/version-form.jsp

changeset 86
0a658e53177c
parent 84
5407d4ea0611
child 99
a369fb1b3aa2
--- a/src/main/webapp/WEB-INF/jsp/version-form.jsp	Sat May 30 18:12:38 2020 +0200
+++ b/src/main/webapp/WEB-INF/jsp/version-form.jsp	Mon Jun 01 14:46:58 2020 +0200
@@ -28,14 +28,8 @@
 <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
 <%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
 
-<jsp:useBean id="projects" type="java.util.List<de.uapcore.lightpit.entities.Project>" scope="request" />
-<jsp:useBean id="version" type="de.uapcore.lightpit.entities.Version" scope="request"/>
-<jsp:useBean id="versionStatusEnum" type="de.uapcore.lightpit.entities.VersionStatus[]" scope="request"/>
-
-<jsp:useBean id="statsAffected" type="de.uapcore.lightpit.entities.VersionStatistics" scope="request"/>
-<jsp:useBean id="statsScheduled" type="de.uapcore.lightpit.entities.VersionStatistics" scope="request"/>
-<jsp:useBean id="statsResolved" type="de.uapcore.lightpit.entities.VersionStatistics" scope="request"/>
-<jsp:useBean id="statsHideZeros" type="java.lang.Boolean" scope="request"/>
+<jsp:useBean id="viewmodel" type="de.uapcore.lightpit.viewmodel.VersionEditView" scope="request" />
+<c:set var="version" scope="page" value="${viewmodel.version}"/>
 
 <form action="./projects/versions/commit" method="post">
     <table class="formtable" style="width: 35ch">
@@ -47,19 +41,21 @@
         <tr>
             <th><fmt:message key="version.project"/></th>
             <td>
-                <c:if test="${version.project.id ge 0}">
-                    <c:out value="${version.project.name}" />
-                    <input type="hidden" name="pid" value="${version.project.id}" />
-                </c:if>
-                <c:if test="${empty version.project or version.project.id lt 0}">
-                    <select name="pid" required>
-                        <c:forEach var="project" items="${projects}">
-                            <option value="${project.id}">
-                                <c:out value="${project.name}" />
-                            </option>
-                        </c:forEach>
-                    </select>
-                </c:if>
+                <c:choose>
+                    <c:when test="${not empty version.project}">
+                        <c:out value="${version.project.name}" />
+                        <input type="hidden" name="pid" value="${version.project.id}" />
+                    </c:when>
+                    <c:otherwise>
+                        <select name="pid" required>
+                            <c:forEach var="project" items="${viewmodel.projects}">
+                                <option value="${project.id}">
+                                    <c:out value="${project.name}" />
+                                </option>
+                            </c:forEach>
+                        </select>
+                    </c:otherwise>
+                </c:choose>
             </td>
         </tr>
         <tr>
@@ -70,7 +66,7 @@
             <th><fmt:message key="version.status"/></th>
             <td>
                 <select name="status" required>
-                    <c:forEach var="elem" items="${versionStatusEnum}">
+                    <c:forEach var="elem" items="${viewmodel.versionStatus}">
                         <option
                                 <c:if test="${elem eq version.status}">selected</c:if> value="${elem}"><fmt:message
                                 key="version.status.${elem}"/></option>
@@ -90,7 +86,7 @@
             <td colspan="2">
                 <input type="hidden" name="id" value="${version.id}"/>
                 <c:choose>
-                    <c:when test="${not empty version.project and version.project.id ge 0}">
+                    <c:when test="${not empty version.project}">
                         <c:set var="cancelUrl">./projects/view?pid=${version.project.id}</c:set>
                     </c:when>
                     <c:otherwise>

mercurial