Sat, 16 May 2020 15:11:07 +0200
adds project selection
1.1 --- a/src/main/java/de/uapcore/lightpit/modules/ProjectsModule.java Sat May 16 13:29:44 2020 +0200 1.2 +++ b/src/main/java/de/uapcore/lightpit/modules/ProjectsModule.java Sat May 16 15:11:07 2020 +0200 1.3 @@ -39,6 +39,8 @@ 1.4 import java.sql.SQLException; 1.5 import java.util.Optional; 1.6 1.7 +import static de.uapcore.lightpit.Functions.fqn; 1.8 + 1.9 @LightPITModule( 1.10 bundleBaseName = "localization.projects", 1.11 modulePath = "projects", 1.12 @@ -50,10 +52,31 @@ 1.13 ) 1.14 public final class ProjectsModule extends AbstractLightPITServlet { 1.15 1.16 + public static final String SESSION_ATTR_SELECTED_PROJECT = fqn(ProjectsModule.class, "selected-project"); 1.17 + 1.18 @RequestMapping(method = HttpMethod.GET) 1.19 public ResponseType index(HttpServletRequest req, DataAccessObjects dao) throws SQLException { 1.20 - req.setAttribute("projects", dao.getProjectDao().list()); 1.21 + final var projectList = dao.getProjectDao().list(); 1.22 + req.setAttribute("projects", projectList); 1.23 setDynamicFragment(req, "projects"); 1.24 + setStylesheet(req, "projects"); 1.25 + 1.26 + final var session = req.getSession(); 1.27 + final var projectSelection = getParameter(req, Integer.class, "select"); 1.28 + if (projectSelection.isPresent()) { 1.29 + final var selectedId = projectSelection.get(); 1.30 + for (var proj : projectList) { 1.31 + if (proj.getId() == selectedId) { 1.32 + session.setAttribute(SESSION_ATTR_SELECTED_PROJECT, proj); 1.33 + break; 1.34 + } 1.35 + } 1.36 + } else { 1.37 + final var selectedProject = session.getAttribute(SESSION_ATTR_SELECTED_PROJECT); 1.38 + if (selectedProject == null) { 1.39 + projectList.stream().findFirst().ifPresent(proj -> session.setAttribute(SESSION_ATTR_SELECTED_PROJECT, proj)); 1.40 + } 1.41 + } 1.42 1.43 return ResponseType.HTML; 1.44 }
2.1 --- a/src/main/webapp/WEB-INF/dynamic_fragments/projects.jsp Sat May 16 13:29:44 2020 +0200 2.2 +++ b/src/main/webapp/WEB-INF/dynamic_fragments/projects.jsp Sat May 16 15:11:07 2020 +0200 2.3 @@ -26,10 +26,12 @@ 2.4 --%> 2.5 <%@page pageEncoding="UTF-8" %> 2.6 <%@page import="de.uapcore.lightpit.Constants" %> 2.7 +<%@page import="de.uapcore.lightpit.modules.ProjectsModule" %> 2.8 <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2.9 <%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> 2.10 2.11 <c:set scope="page" var="moduleInfo" value="${requestScope[Constants.REQ_ATTR_MODULE_INFO]}"/> 2.12 +<c:set scope="page" var="selectedProject" value="${sessionScope[ProjectsModule.SESSION_ATTR_SELECTED_PROJECT]}"/> 2.13 2.14 <jsp:useBean id="projects" type="java.util.List<de.uapcore.lightpit.entities.Project>" scope="request"/> 2.15 2.16 @@ -44,7 +46,7 @@ 2.17 </div> 2.18 2.19 <c:if test="${not empty projects}"> 2.20 -<table class="datatable medskip"> 2.21 +<table id="project-list" class="datatable medskip"> 2.22 <colgroup> 2.23 <col> 2.24 <col style="width: 10%"> 2.25 @@ -63,9 +65,9 @@ 2.26 </thead> 2.27 <tbody> 2.28 <c:forEach var="project" items="${projects}"> 2.29 - <tr> 2.30 + <tr class="nowrap" <c:if test="${project eq selectedProject}">data-selected</c:if> > 2.31 <td style="width: 2em;"><a href="./${moduleInfo.modulePath}/edit?id=${project.id}">✎</a></td> 2.32 - <td><c:out value="${project.name}"/></td> 2.33 + <td><a href="./${moduleInfo.modulePath}?select=${project.id}"><c:out value="${project.name}"/></a></td> 2.34 <td><c:out value="${project.description}"/></td> 2.35 <td> 2.36 <c:if test="${not empty project.repoUrl}">
3.1 --- a/src/main/webapp/lightpit.css Sat May 16 13:29:44 2020 +0200 3.2 +++ b/src/main/webapp/lightpit.css Sat May 16 15:11:07 2020 +0200 3.3 @@ -29,6 +29,7 @@ 3.4 3.5 html { 3.6 font-family: sans-serif; 3.7 + font-size: 11pt; 3.8 background: white; 3.9 color: #1c204e; 3.10 margin: 0; 3.11 @@ -57,6 +58,7 @@ 3.12 } 3.13 3.14 #mainMenu { 3.15 + font-size: large; 3.16 background: #e0e0e5; 3.17 } 3.18
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/src/main/webapp/projects.css Sat May 16 15:11:07 2020 +0200 4.3 @@ -0,0 +1,32 @@ 4.4 +/* 4.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 4.6 + * 4.7 + * Copyright 2018 Mike Becker. All rights reserved. 4.8 + * 4.9 + * Redistribution and use in source and binary forms, with or without 4.10 + * modification, are permitted provided that the following conditions are met: 4.11 + * 4.12 + * 1. Redistributions of source code must retain the above copyright 4.13 + * notice, this list of conditions and the following disclaimer. 4.14 + * 4.15 + * 2. Redistributions in binary form must reproduce the above copyright 4.16 + * notice, this list of conditions and the following disclaimer in the 4.17 + * documentation and/or other materials provided with the distribution. 4.18 + * 4.19 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 4.20 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 4.21 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 4.22 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 4.23 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 4.24 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 4.25 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 4.26 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 4.27 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 4.28 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 4.29 + * POSSIBILITY OF SUCH DAMAGE. 4.30 + * 4.31 + */ 4.32 + 4.33 +#project-list tr[data-selected] { 4.34 + background: lightgoldenrodyellow; 4.35 +}