# HG changeset patch # User Mike Becker # Date 1603357575 -7200 # Node ID 7281bdf43c60fe2511dbf2ca478be993049b3980 # Parent bafc315294fd1cd40c60e812f2e163c9dd8cf42b automatic assignment of component lead (if available) - fixes #28 diff -r bafc315294fd -r 7281bdf43c60 src/main/java/de/uapcore/lightpit/modules/ProjectsModule.java --- a/src/main/java/de/uapcore/lightpit/modules/ProjectsModule.java Sat Oct 17 20:06:14 2020 +0200 +++ b/src/main/java/de/uapcore/lightpit/modules/ProjectsModule.java Thu Oct 22 11:06:15 2020 +0200 @@ -46,6 +46,7 @@ import java.sql.SQLException; import java.util.List; import java.util.NoSuchElementException; +import java.util.Optional; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -453,16 +454,28 @@ public ResponseType commitIssue(HttpServletRequest req, HttpServletResponse resp, DataAccessObjects dao) throws IOException { try { final var issue = new Issue(getParameter(req, Integer.class, "id").orElseThrow()); + final var componentId = getParameter(req, Integer.class, "component"); + final Component component; + if (componentId.isPresent()) { + component = dao.getComponentDao().find(componentId.get()); + } else { + component = null; + } issue.setProject(new Project(getParameter(req, Integer.class, "pid").orElseThrow())); getParameter(req, String.class, "category").map(IssueCategory::valueOf).ifPresent(issue::setCategory); getParameter(req, String.class, "status").map(IssueStatus::valueOf).ifPresent(issue::setStatus); issue.setSubject(getParameter(req, String.class, "subject").orElseThrow()); - getParameter(req, Integer.class, "assignee").map( - userid -> userid >= 0 ? new User(userid) : null + issue.setComponent(component); + getParameter(req, Integer.class, "assignee").map(userid -> { + if (userid >= 0) { + return new User(userid); + } else if (userid == -2) { + return Optional.ofNullable(component).map(Component::getLead).orElse(null); + } else { + return null; + } + } ).ifPresent(issue::setAssignee); - getParameter(req, Integer.class, "component").map( - cid -> cid >= 0 ? new Component(cid) : null - ).ifPresent(issue::setComponent); getParameter(req, String.class, "description").ifPresent(issue::setDescription); getParameter(req, Date.class, "eta").ifPresent(issue::setEta); diff -r bafc315294fd -r 7281bdf43c60 src/main/resources/localization/projects.properties --- a/src/main/resources/localization/projects.properties Sat Oct 17 20:06:14 2020 +0200 +++ b/src/main/resources/localization/projects.properties Thu Oct 22 11:06:15 2020 +0200 @@ -73,6 +73,8 @@ placeholder.null-owner=Unassigned placeholder.null-lead=Unassigned placeholder.null-assignee=Unassigned +placeholder.auto-assignee=Automatic +placeholder.auto-assignee.tooltip=Assigns the component lead, if available. placeholder.null-component=Unassigned version.status.Future=Future diff -r bafc315294fd -r 7281bdf43c60 src/main/resources/localization/projects_de.properties --- a/src/main/resources/localization/projects_de.properties Sat Oct 17 20:06:14 2020 +0200 +++ b/src/main/resources/localization/projects_de.properties Thu Oct 22 11:06:15 2020 +0200 @@ -73,6 +73,8 @@ placeholder.null-owner=Nicht Zugewiesen placeholder.null-lead=Niemand placeholder.null-assignee=Niemandem +placeholder.auto-assignee=Automatisch +placeholder.auto-assignee.tooltip=Weist, wenn m\u00f6glich, den Vorgang dem Leiter der Komponente. placeholder.null-component=Keine version.status.Future=Geplant diff -r bafc315294fd -r 7281bdf43c60 src/main/webapp/WEB-INF/jsp/issue-form.jsp --- a/src/main/webapp/WEB-INF/jsp/issue-form.jsp Sat Oct 17 20:06:14 2020 +0200 +++ b/src/main/webapp/WEB-INF/jsp/issue-form.jsp Thu Oct 22 11:06:15 2020 +0200 @@ -128,7 +128,10 @@