adds "Create another" checkbox to issue form - fixes #110

Sat, 26 Dec 2020 20:19:09 +0100

author
Mike Becker <universe@uap-core.de>
date
Sat, 26 Dec 2020 20:19:09 +0100
changeset 168
1c3694ae224c
parent 167
3f30adba1c63
child 173
1dc56ab7845e

adds "Create another" checkbox to issue form - fixes #110

src/main/java/de/uapcore/lightpit/AbstractLightPITServlet.java file | annotate | diff | comparison | revisions
src/main/java/de/uapcore/lightpit/modules/ProjectsModule.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/issue-form.jsp file | annotate | diff | comparison | revisions
--- a/src/main/java/de/uapcore/lightpit/AbstractLightPITServlet.java	Mon Dec 21 18:29:34 2020 +0100
+++ b/src/main/java/de/uapcore/lightpit/AbstractLightPITServlet.java	Sat Dec 26 20:19:09 2020 +0100
@@ -275,7 +275,7 @@
     private <T> Optional<T> parseParameter(String paramValue, Class<T> clazz) {
         if (paramValue == null) return Optional.empty();
         if (clazz.equals(Boolean.class)) {
-            if (paramValue.toLowerCase().equals("false") || paramValue.equals("0")) {
+            if (paramValue.equalsIgnoreCase("false") || paramValue.equals("0")) {
                 return Optional.of((T) Boolean.FALSE);
             } else {
                 return Optional.of((T) Boolean.TRUE);
@@ -349,6 +349,13 @@
         }
     }
 
+    protected void setAttributeFromParameter(HttpServletRequest req, String name) {
+        final var parm = req.getParameter(name);
+        if (parm != null) {
+            req.setAttribute(name, parm);
+        }
+    }
+
     private String sanitizeRequestPath(HttpServletRequest req) {
         return Optional.ofNullable(req.getPathInfo()).orElse("/");
     }
--- a/src/main/java/de/uapcore/lightpit/modules/ProjectsModule.java	Mon Dec 21 18:29:34 2020 +0100
+++ b/src/main/java/de/uapcore/lightpit/modules/ProjectsModule.java	Sat Dec 26 20:19:09 2020 +0100
@@ -537,7 +537,7 @@
     }
 
     @RequestMapping(requestPath = "$project/create-issue", method = HttpMethod.GET)
-    public void createIssue(HttpServletRequest req, HttpServletResponse resp, PathParameters pathParameters, DataAccessObject dao) throws IOException, SQLException, ServletException {
+    public void createIssue(HttpServletRequest req, HttpServletResponse resp, PathParameters pathParameters, DataAccessObject dao) throws IOException, ServletException {
         final var viewModel = new IssueEditView();
         populate(viewModel, pathParameters, dao);
 
@@ -547,7 +547,10 @@
             return;
         }
 
-        // TODO: fix #38 - automatically select component (and version)
+        setAttributeFromParameter(req, "more");
+        setAttributeFromParameter(req, "component");
+        setAttributeFromParameter(req, "version");
+
         final var issue = new Issue(-1, projectInfo.getProject(), null);
         issue.setProject(projectInfo.getProject());
         configureIssueEditor(viewModel, issue, dao);
@@ -607,8 +610,12 @@
                 dao.insertIssue(issue);
             }
 
-            // TODO: implement #110
-            setRedirectLocation(req, "./projects/" + issue.getProject().getNode()+"/issues/"+issue.getId()+"/view");
+            if (getParameter(req, Boolean.class, "create-another").orElse(false)) {
+                // TODO: fix #38 - automatically select component (and version)
+                setRedirectLocation(req, "./projects/" + issue.getProject().getNode() + "/create-issue?more=true");
+            } else{
+                setRedirectLocation(req, "./projects/" + issue.getProject().getNode() + "/issues/" + issue.getId() + "/view");
+            }
             setContentPage(req, Constants.JSP_COMMIT_SUCCESSFUL);
 
             renderSite(req, resp);
--- a/src/main/resources/localization/projects.properties	Mon Dec 21 18:29:34 2020 +0100
+++ b/src/main/resources/localization/projects.properties	Sat Dec 26 20:19:09 2020 +0100
@@ -29,6 +29,7 @@
 button.version.create=New Version
 button.version.edit=Edit Version
 button.issue.create=New Issue
+button.issue.create.another=Create another Issue
 button.issue.edit=Edit Issue
 button.issue.all=All Issues
 button.comment=Comment
--- a/src/main/resources/localization/projects_de.properties	Mon Dec 21 18:29:34 2020 +0100
+++ b/src/main/resources/localization/projects_de.properties	Sat Dec 26 20:19:09 2020 +0100
@@ -29,6 +29,7 @@
 button.version.create=Neue Version
 button.version.edit=Version Bearbeiten
 button.issue.create=Neuer Vorgang
+button.issue.create.another=Weiteren Vorgang erstellen
 button.issue.edit=Vorgang Bearbeiten
 button.issue.all=Alle Vorg\u00e4nge
 button.comment=Kommentieren
--- a/src/main/webapp/WEB-INF/jsp/issue-form.jsp	Mon Dec 21 18:29:34 2020 +0100
+++ b/src/main/webapp/WEB-INF/jsp/issue-form.jsp	Sat Dec 26 20:19:09 2020 +0100
@@ -1,7 +1,7 @@
 <%--
 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 
-Copyright 2018 Mike Becker. All rights reserved.
+Copyright 2020 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:
@@ -174,6 +174,8 @@
         <tfoot>
         <tr>
             <td colspan="2">
+                <input type="checkbox" id="create-another" name="create-another" <c:if test="${more}">checked</c:if> />
+                <label for="create-another"><fmt:message key="button.issue.create.another"/> </label>
                 <input type="hidden" name="id" value="${issue.id}"/>
                 <c:if test="${issue.id ge 0}">
                 <a href="./projects/${issue.project.node}/issues/${issue.id}/view" class="button">

mercurial