Thu, 15 Oct 2020 14:01:49 +0200
add components to navmenu
--- a/src/main/java/de/uapcore/lightpit/modules/ProjectsModule.java Thu Oct 15 13:31:52 2020 +0200 +++ b/src/main/java/de/uapcore/lightpit/modules/ProjectsModule.java Thu Oct 15 14:01:49 2020 +0200 @@ -60,8 +60,10 @@ private static final String SESSION_ATTR_SELECTED_PROJECT = fqn(ProjectsModule.class, "selected_project"); private static final String SESSION_ATTR_SELECTED_VERSION = fqn(ProjectsModule.class, "selected_version"); + private static final String SESSION_ATTR_SELECTED_COMPONENT = fqn(ProjectsModule.class, "selected_component"); private static final String PARAMETER_SELECTED_PROJECT = "pid"; private static final String PARAMETER_SELECTED_VERSION = "vid"; + private static final String PARAMETER_SELECTED_COMPONENT = "cid"; @Override protected String getResourceBundleName() { @@ -84,6 +86,7 @@ private void populate(ProjectView viewModel, HttpServletRequest req, DataAccessObjects dao) throws SQLException { final var projectDao = dao.getProjectDao(); final var versionDao = dao.getVersionDao(); + final var componentDao = dao.getComponentDao(); projectDao.list().stream().map(ProjectInfo::new).forEach(viewModel.getProjectList()::add); @@ -96,6 +99,7 @@ } else { final var info = new ProjectInfo(project); info.setVersions(versionDao.list(project)); + info.setComponents(componentDao.list(project)); info.setIssueSummary(projectDao.getIssueSummary(project)); viewModel.setProjectInfo(info); } @@ -103,8 +107,20 @@ // Select Version final int vid = syncParamWithSession(req, PARAMETER_SELECTED_VERSION, SESSION_ATTR_SELECTED_VERSION); - if (vid >= 0) { + if (vid > 0) { viewModel.setVersionFilter(versionDao.find(vid)); + } else { + // NULL for version means: show all unassigned + viewModel.setVersionFilter(null); + } + + // Select Component + final int cid = syncParamWithSession(req, PARAMETER_SELECTED_COMPONENT, SESSION_ATTR_SELECTED_COMPONENT); + if (cid > 0) { + viewModel.setComponentFilter(componentDao.find(cid)); + } else if (cid <= 0) { + // -1 means: filter for unassigned, null means: show all + viewModel.setComponentFilter(new Component(-1)); } }
--- a/src/main/java/de/uapcore/lightpit/viewmodel/ProjectInfo.java Thu Oct 15 13:31:52 2020 +0200 +++ b/src/main/java/de/uapcore/lightpit/viewmodel/ProjectInfo.java Thu Oct 15 14:01:49 2020 +0200 @@ -1,5 +1,6 @@ package de.uapcore.lightpit.viewmodel; +import de.uapcore.lightpit.entities.Component; import de.uapcore.lightpit.entities.IssueSummary; import de.uapcore.lightpit.entities.Project; import de.uapcore.lightpit.entities.Version; @@ -11,6 +12,7 @@ private final Project project; private List<Version> versions = Collections.emptyList(); + private List<Component> components = Collections.emptyList(); private IssueSummary issueSummary = new IssueSummary(); public ProjectInfo(Project project) { @@ -29,6 +31,14 @@ this.versions = versions; } + public List<Component> getComponents() { + return components; + } + + public void setComponents(List<Component> components) { + this.components = components; + } + public Version getLatestVersion() { // expects versions to be sorted by status descending for (var v : versions) {
--- a/src/main/java/de/uapcore/lightpit/viewmodel/ProjectView.java Thu Oct 15 13:31:52 2020 +0200 +++ b/src/main/java/de/uapcore/lightpit/viewmodel/ProjectView.java Thu Oct 15 14:01:49 2020 +0200 @@ -1,5 +1,6 @@ package de.uapcore.lightpit.viewmodel; +import de.uapcore.lightpit.entities.Component; import de.uapcore.lightpit.entities.Version; import java.util.ArrayList; @@ -10,6 +11,7 @@ private final List<ProjectInfo> projectList = new ArrayList<>(); private ProjectInfo projectInfo; private Version versionFilter; + private Component componentFilter; public List<ProjectInfo> getProjectList() { return projectList; @@ -30,4 +32,12 @@ public void setVersionFilter(Version versionFilter) { this.versionFilter = versionFilter; } + + public Component getComponentFilter() { + return componentFilter; + } + + public void setComponentFilter(Component componentFilter) { + this.componentFilter = componentFilter; + } }
--- a/src/main/resources/localization/projects.properties Thu Oct 15 13:31:52 2020 +0200 +++ b/src/main/resources/localization/projects.properties Thu Oct 15 14:01:49 2020 +0200 @@ -32,9 +32,10 @@ no-projects=Welcome to LightPIT. Start off by creating a new project! -menu.versions=Versions -menu.versions.unassigned=unassigned -menu.issues=Issues +navmenu.versions=Versions +navmenu.components=Components +navmenu.unassigned=unassigned +navmenu.all=all name=Name description=Description
--- a/src/main/resources/localization/projects_de.properties Thu Oct 15 13:31:52 2020 +0200 +++ b/src/main/resources/localization/projects_de.properties Thu Oct 15 14:01:49 2020 +0200 @@ -32,9 +32,10 @@ no-projects=Wilkommen bei LightPIT. Beginnen Sie mit der Erstellung eines Projektes! -menu.versions=Versionen -menu.versions.unassigned=Nicht Zugewiesen -menu.issues=Vorg\u00e4nge +navmenu.versions=Versionen +navmenu.components=Komponenten +navmenu.unassigned=Nicht Zugewiesen +navmenu.all=Alle name=Name description=Beschreibung
--- a/src/main/webapp/WEB-INF/jsp/project-navmenu.jsp Thu Oct 15 13:31:52 2020 +0200 +++ b/src/main/webapp/WEB-INF/jsp/project-navmenu.jsp Thu Oct 15 14:01:49 2020 +0200 @@ -38,26 +38,54 @@ </a> </div> <c:if test="${isActive}"> + <!-- VERSIONS --> <div class="menuEntry level-1"> <a href="projects/versions?pid=${projectInfo.project.id}"> - <fmt:message key="menu.versions"/> + <fmt:message key="navmenu.versions"/> </a> </div> <div class="menuEntry level-2"> - <div class="version-icon" style="background: black"></div> + <div class="navmenu-icon" style="background: black"></div> <a href="projects/view?pid=${projectInfo.project.id}&vid=-1"> - <fmt:message key="menu.versions.unassigned" /> + <fmt:message key="navmenu.unassigned" /> </a> </div> <c:forEach var="version" items="${viewmodel.projectInfo.versions}"> <c:set var="isVersionActive" value="${viewmodel.versionFilter eq version}" /> <div class="menuEntry level-2" <c:if test="${isVersionActive}">data-active</c:if> title="<fmt:message key="version.status.${version.status}" />"> - <div class="version-icon version-${version.status}"></div> + <div class="navmenu-icon version-${version.status}"></div> <a href="projects/view?pid=${projectInfo.project.id}&vid=${version.id}"> <c:out value="${version.name}"/> </a> </div> </c:forEach> + <!-- COMPONENTS --> + <div class="menuEntry level-1"> + <a href="projects/components?pid=${projectInfo.project.id}"> + <fmt:message key="navmenu.components"/> + </a> + </div> + <div class="menuEntry level-2"> + <div class="navmenu-icon" style="background: black"></div> + <a href="projects/view?pid=${projectInfo.project.id}&cid=0"> + <fmt:message key="navmenu.all" /> + </a> + </div> + <div class="menuEntry level-2"> + <div class="navmenu-icon" style="background: black"></div> + <a href="projects/view?pid=${projectInfo.project.id}&cid=-1"> + <fmt:message key="navmenu.unassigned" /> + </a> + </div> + <c:forEach var="component" items="${viewmodel.projectInfo.components}"> + <c:set var="isComponentActive" value="${viewmodel.componentFilter eq component}" /> + <div class="menuEntry level-2" <c:if test="${isVersionActive}">data-active</c:if> > + <div class="navmenu-icon" style="background-color: ${component.color}"></div> + <a href="projects/view?pid=${projectInfo.project.id}&cid=${component.id}"> + <c:out value="${component.name}"/> + </a> + </div> + </c:forEach> </c:if> </c:forEach>