simplifies issues per version view and re-adds edit version button

Sat, 29 Aug 2020 17:13:09 +0200

author
Mike Becker <universe@uap-core.de>
date
Sat, 29 Aug 2020 17:13:09 +0200
changeset 105
250c5cbb8276
parent 104
8be80ea4f52b
child 106
9c6ebf67afe9

simplifies issues per version view and re-adds edit version button

src/main/java/de/uapcore/lightpit/dao/IssueDao.java file | annotate | diff | comparison | revisions
src/main/java/de/uapcore/lightpit/dao/postgres/PGIssueDao.java file | annotate | diff | comparison | revisions
src/main/java/de/uapcore/lightpit/modules/ProjectsModule.java file | annotate | diff | comparison | revisions
src/main/java/de/uapcore/lightpit/viewmodel/ProjectDetails.java file | annotate | diff | comparison | revisions
src/main/resources/localization/projects.properties file | annotate | diff | comparison | revisions
src/main/resources/localization/projects_de.properties file | annotate | diff | comparison | revisions
src/main/webapp/WEB-INF/jsp/project-details.jsp file | annotate | diff | comparison | revisions
src/main/webapp/WEB-INF/jsp/version.jsp file | annotate | diff | comparison | revisions
--- a/src/main/java/de/uapcore/lightpit/dao/IssueDao.java	Sat Aug 29 16:48:15 2020 +0200
+++ b/src/main/java/de/uapcore/lightpit/dao/IssueDao.java	Sat Aug 29 17:13:09 2020 +0200
@@ -50,8 +50,9 @@
 
     /**
      * Lists all issues that are somehow related to the specified version.
+     * If version is null, search for issues that are not related to any version.
      *
-     * @param version the version
+     * @param version the version or null
      * @return a list of issues
      * @throws SQLException on any kind of SQL error
      */
--- a/src/main/java/de/uapcore/lightpit/dao/postgres/PGIssueDao.java	Sat Aug 29 16:48:15 2020 +0200
+++ b/src/main/java/de/uapcore/lightpit/dao/postgres/PGIssueDao.java	Sat Aug 29 17:13:09 2020 +0200
@@ -54,7 +54,7 @@
                         "userid, username, givenname, lastname, mail, " +
                         "created, updated, eta " +
                         "from lpit_issue i " +
-                        "left join lpit_project p on project = projectid " +
+                        "join lpit_project p on project = projectid " +
                         "left join lpit_user on userid = assignee " +
                         "where project = ? "+
                         "order by eta asc, updated desc");
@@ -67,10 +67,10 @@
                         "userid, username, givenname, lastname, mail, " +
                         "created, updated, eta " +
                         "from lpit_issue i " +
-                        "join issue_version using (issueid) "+
-                        "left join lpit_project p on project = projectid " +
+                        "join lpit_project p on project = projectid " +
+                        "left join issue_version using (issueid) "+
                         "left join lpit_user on userid = assignee " +
-                        "where versionid = ? "+
+                        "where coalesce(versionid,-1) = ? "+
                         "order by eta asc, updated desc"
         );
 
@@ -222,7 +222,7 @@
 
     @Override
     public List<Issue> list(Version version) throws SQLException {
-        return list(listForVersion, version.getId());
+        return list(listForVersion, version == null ? -1 : version.getId());
     }
 
     @Override
--- a/src/main/java/de/uapcore/lightpit/modules/ProjectsModule.java	Sat Aug 29 16:48:15 2020 +0200
+++ b/src/main/java/de/uapcore/lightpit/modules/ProjectsModule.java	Sat Aug 29 17:13:09 2020 +0200
@@ -43,7 +43,6 @@
 import java.sql.Date;
 import java.sql.SQLException;
 import java.util.ArrayList;
-import java.util.List;
 import java.util.NoSuchElementException;
 import java.util.Optional;
 import java.util.stream.Collectors;
@@ -112,7 +111,7 @@
                 final var level2 = new ArrayList<MenuEntry>();
                 {
                     final var entry = new MenuEntry(
-                            new ResourceKey(getResourceBundleName(), "filter.all"),
+                            new ResourceKey(getResourceBundleName(), "filter.none"),
                             "projects/view?" + queryParams(proj, null)
                     );
                     if (viewModel.getVersionFilter() == null) entry.setActive(true);
@@ -257,17 +256,12 @@
 
         final var issueDao = dao.getIssueDao();
 
-        final var project = viewModel.getProjectInfo().getProject();
+        final var version = viewModel.getVersionFilter();
 
         final var detailView = viewModel.getProjectDetails();
-        final var issues = issueDao.list(project);
+        final var issues = issueDao.list(version);
         for (var issue : issues) issueDao.joinVersionInformation(issue);
-        detailView.setIssues(issues);
-        if (viewModel.getVersionFilter() != null) {
-            detailView.updateVersionInfo(List.of(viewModel.getVersionFilter()));
-        } else {
-            detailView.updateVersionInfo(viewModel.getProjectInfo().getVersions());
-        }
+        detailView.updateDetails(issues, version);
 
         return forwardView(req, viewModel, "project-details");
     }
--- a/src/main/java/de/uapcore/lightpit/viewmodel/ProjectDetails.java	Sat Aug 29 16:48:15 2020 +0200
+++ b/src/main/java/de/uapcore/lightpit/viewmodel/ProjectDetails.java	Sat Aug 29 17:13:09 2020 +0200
@@ -4,54 +4,34 @@
 import de.uapcore.lightpit.entities.IssueSummary;
 import de.uapcore.lightpit.entities.Version;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
 import java.util.List;
 
 public class ProjectDetails {
 
-    private List<VersionInfo> versionInfos = Collections.emptyList();
+    private VersionInfo versionInfo = null;
+
+    private List<Issue> issues;
+    private IssueSummary issueSummary;
 
-    private List<Issue> issues = Collections.emptyList();
-    private List<Issue> issuesWithoutVersion;
-    private IssueSummary issuesWithoutVersionTotal;
+    public void updateDetails(List<Issue> issues, Version version) {
+        this.issues = issues;
+        issueSummary = new IssueSummary();
+        issues.forEach(issueSummary::add);
+        if (version != null) {
+            versionInfo = new VersionInfo(version);
+            versionInfo.collectIssues(issues);
+        }
+    }
 
     public List<Issue> getIssues() {
         return issues;
     }
 
-    public void setIssues(List<Issue> issues) {
-        this.issues = issues;
-        issuesWithoutVersion = new ArrayList<>();
-        issuesWithoutVersionTotal = new IssueSummary();
-        for (Issue issue : issues) {
-            // we want to list all issues that do not have a target version
-            if (issue.getResolvedVersions().isEmpty()) {
-                issuesWithoutVersion.add(issue);
-                issuesWithoutVersionTotal.add(issue);
-            }
-        }
+    public IssueSummary getIssueSummary() {
+        return issueSummary;
     }
 
-    public void updateVersionInfo(Collection<Version> versions) {
-        versionInfos = new ArrayList<>();
-        for (Version version : versions) {
-            final var info = new VersionInfo(version);
-            info.collectIssues(issues);
-            versionInfos.add(info);
-        }
-    }
-
-    public List<Issue> getIssuesWithoutVersion() {
-        return issuesWithoutVersion;
-    }
-
-    public IssueSummary getIssuesWithoutVersionTotal() {
-        return issuesWithoutVersionTotal;
-    }
-
-    public List<VersionInfo> getVersionInfos() {
-        return versionInfos;
+    public VersionInfo getVersionInfo() {
+        return versionInfo;
     }
 }
--- a/src/main/resources/localization/projects.properties	Sat Aug 29 16:48:15 2020 +0200
+++ b/src/main/resources/localization/projects.properties	Sat Aug 29 17:13:09 2020 +0200
@@ -32,6 +32,7 @@
 no-projects=Welcome to LightPIT. Start off by creating a new project!
 
 filter.all=all
+filter.none=none
 
 menu.versions=Versions
 menu.issues=Issues
--- a/src/main/resources/localization/projects_de.properties	Sat Aug 29 16:48:15 2020 +0200
+++ b/src/main/resources/localization/projects_de.properties	Sat Aug 29 17:13:09 2020 +0200
@@ -32,6 +32,7 @@
 no-projects=Wilkommen bei LightPIT. Beginnen Sie mit der Erstellung eines Projektes!
 
 filter.all=alle
+filter.none=keine
 
 menu.versions=Versionen
 menu.issues=Vorg\u00e4nge
--- a/src/main/webapp/WEB-INF/jsp/project-details.jsp	Sat Aug 29 16:48:15 2020 +0200
+++ b/src/main/webapp/WEB-INF/jsp/project-details.jsp	Sat Aug 29 17:13:09 2020 +0200
@@ -34,6 +34,9 @@
 <%@include file="../jspf/project-header.jsp"%>
 
 <div id="tool-area">
+    <c:if test="${not empty viewmodel.versionFilter}">
+        <a href="./projects/versions/edit?vid=${viewmodel.versionFilter.id}" class="button"><fmt:message key="button.version.edit"/></a>
+    </c:if>
     <a href="./projects/versions/edit" class="button"><fmt:message key="button.version.create"/></a>
     <a href="./projects/issues/edit?pid=${project.id}" class="button"><fmt:message key="button.issue.create"/></a>
 </div>
@@ -43,14 +46,8 @@
 <c:set var="summary" value="${viewmodel.projectInfo.issueSummary}" />
 <%@include file="../jspf/issue-summary.jsp"%>
 
-<h2><fmt:message key="issue.without-version" /></h2>
-
-<c:set var="issues" value="${viewmodel.projectDetails.issuesWithoutVersion}"/>
-<c:set var="summary" value="${viewmodel.projectDetails.issuesWithoutVersionTotal}" />
-<%@include file="../jspf/issue-summary.jsp"%>
-<%@include file="../jspf/issue-list.jsp"%>
-
-<c:forEach var="versionInfo" items="${viewmodel.projectDetails.versionInfos}">
+<c:if test="${not empty viewmodel.versionFilter}">
+    <c:set var="versionInfo" value="${viewmodel.projectDetails.versionInfo}"/>
     <h2>
         <fmt:message key="version.label" /> <c:out value="${versionInfo.version.name}" /> - <fmt:message key="version.status.${versionInfo.version.status}"/>
     </h2>
@@ -70,4 +67,15 @@
         <%@include file="../jspf/issue-summary.jsp"%>
         <%@include file="../jspf/issue-list.jsp"%>
     </c:if>
-</c:forEach>
\ No newline at end of file
+</c:if>
+<c:if test="${empty viewmodel.versionFilter}">
+    <h2>
+        <fmt:message key="issue.without-version" />
+    </h2>
+    <c:set var="summary" value="${viewmodel.projectDetails.issueSummary}"/>
+    <c:set var="issues" value="${viewmodel.projectDetails.issues}"/>
+    <%@include file="../jspf/issue-summary.jsp"%>
+    <c:if test="${not empty issues}">
+        <%@include file="../jspf/issue-list.jsp"%>
+    </c:if>
+</c:if>
--- a/src/main/webapp/WEB-INF/jsp/version.jsp	Sat Aug 29 16:48:15 2020 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-<%--
-DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
-
-Copyright 2018 Mike Becker. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-1. Redistributions of source code must retain the above copyright
-notice, this list of conditions and the following disclaimer.
-
-2. Redistributions in binary form must reproduce the above copyright
-notice, this list of conditions and the following disclaimer in the
-documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---%>
-<%@page pageEncoding="UTF-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="viewmodel" type="de.uapcore.lightpit.viewmodel.VersionView" scope="request"/>
-<c:set var="version" scope="page" value="${viewmodel.versionInfo.version}"/>
-
-<c:set var="project" scope="page" value="${version.project}"/>
-<%@include file="../jspf/project-header.jsp"%>
-
-
-<div id="tool-area">
-    <a href="./projects/issues/edit?pid=${project.id}" class="button"><fmt:message key="button.issue.create"/></a>
-    <a href="./projects/versions/edit?vid=${version.id}" class="button"><fmt:message key="button.version.edit"/></a>
-</div>
-
-<h2>
-<fmt:message key="version.label" /> <c:out value="${version.name}" /> - <fmt:message key="version.status.${version.status}"/>
-</h2>
-
-<c:if test="${not empty viewmodel.versionInfo.resolved}">
-    <h3><fmt:message key="issues.resolved"/> </h3>
-    <c:set var="summary" value="${viewmodel.versionInfo.resolvedTotal}"/>
-    <c:set var="issues" value="${viewmodel.versionInfo.resolved}"/>
-    <%@include file="../jspf/issue-summary.jsp"%>
-    <%@include file="../jspf/issue-list.jsp"%>
-</c:if>
-
-<c:if test="${not empty viewmodel.versionInfo.reported}">
-    <h3><fmt:message key="issues.reported"/> </h3>
-    <c:set var="summary" value="${viewmodel.versionInfo.reportedTotal}"/>
-    <c:set var="issues" value="${viewmodel.versionInfo.reported}"/>
-    <%@include file="../jspf/issue-summary.jsp"%>
-    <%@include file="../jspf/issue-list.jsp"%>
-</c:if>
-

mercurial