automatic assignment of component lead (if available) - fixes #28

Thu, 22 Oct 2020 11:06:15 +0200

author
Mike Becker <universe@uap-core.de>
date
Thu, 22 Oct 2020 11:06:15 +0200
changeset 136
7281bdf43c60
parent 135
bafc315294fd
child 137
a7e543ab0c5f

automatic assignment of component lead (if available) - fixes #28

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
     1.1 --- a/src/main/java/de/uapcore/lightpit/modules/ProjectsModule.java	Sat Oct 17 20:06:14 2020 +0200
     1.2 +++ b/src/main/java/de/uapcore/lightpit/modules/ProjectsModule.java	Thu Oct 22 11:06:15 2020 +0200
     1.3 @@ -46,6 +46,7 @@
     1.4  import java.sql.SQLException;
     1.5  import java.util.List;
     1.6  import java.util.NoSuchElementException;
     1.7 +import java.util.Optional;
     1.8  import java.util.stream.Collectors;
     1.9  import java.util.stream.Stream;
    1.10  
    1.11 @@ -453,16 +454,28 @@
    1.12      public ResponseType commitIssue(HttpServletRequest req, HttpServletResponse resp, DataAccessObjects dao) throws IOException {
    1.13          try {
    1.14              final var issue = new Issue(getParameter(req, Integer.class, "id").orElseThrow());
    1.15 +            final var componentId = getParameter(req, Integer.class, "component");
    1.16 +            final Component component;
    1.17 +            if (componentId.isPresent()) {
    1.18 +                component = dao.getComponentDao().find(componentId.get());
    1.19 +            } else {
    1.20 +                component = null;
    1.21 +            }
    1.22              issue.setProject(new Project(getParameter(req, Integer.class, "pid").orElseThrow()));
    1.23              getParameter(req, String.class, "category").map(IssueCategory::valueOf).ifPresent(issue::setCategory);
    1.24              getParameter(req, String.class, "status").map(IssueStatus::valueOf).ifPresent(issue::setStatus);
    1.25              issue.setSubject(getParameter(req, String.class, "subject").orElseThrow());
    1.26 -            getParameter(req, Integer.class, "assignee").map(
    1.27 -                    userid -> userid >= 0 ? new User(userid) : null
    1.28 +            issue.setComponent(component);
    1.29 +            getParameter(req, Integer.class, "assignee").map(userid -> {
    1.30 +                if (userid >= 0) {
    1.31 +                    return new User(userid);
    1.32 +                } else if (userid == -2) {
    1.33 +                    return Optional.ofNullable(component).map(Component::getLead).orElse(null);
    1.34 +                } else {
    1.35 +                    return null;
    1.36 +                }
    1.37 +            }
    1.38              ).ifPresent(issue::setAssignee);
    1.39 -            getParameter(req, Integer.class, "component").map(
    1.40 -                    cid -> cid >= 0 ? new Component(cid) : null
    1.41 -            ).ifPresent(issue::setComponent);
    1.42              getParameter(req, String.class, "description").ifPresent(issue::setDescription);
    1.43              getParameter(req, Date.class, "eta").ifPresent(issue::setEta);
    1.44  
     2.1 --- a/src/main/resources/localization/projects.properties	Sat Oct 17 20:06:14 2020 +0200
     2.2 +++ b/src/main/resources/localization/projects.properties	Thu Oct 22 11:06:15 2020 +0200
     2.3 @@ -73,6 +73,8 @@
     2.4  placeholder.null-owner=Unassigned
     2.5  placeholder.null-lead=Unassigned
     2.6  placeholder.null-assignee=Unassigned
     2.7 +placeholder.auto-assignee=Automatic
     2.8 +placeholder.auto-assignee.tooltip=Assigns the component lead, if available.
     2.9  placeholder.null-component=Unassigned
    2.10  
    2.11  version.status.Future=Future
     3.1 --- a/src/main/resources/localization/projects_de.properties	Sat Oct 17 20:06:14 2020 +0200
     3.2 +++ b/src/main/resources/localization/projects_de.properties	Thu Oct 22 11:06:15 2020 +0200
     3.3 @@ -73,6 +73,8 @@
     3.4  placeholder.null-owner=Nicht Zugewiesen
     3.5  placeholder.null-lead=Niemand
     3.6  placeholder.null-assignee=Niemandem
     3.7 +placeholder.auto-assignee=Automatisch
     3.8 +placeholder.auto-assignee.tooltip=Weist, wenn m\u00f6glich, den Vorgang dem Leiter der Komponente.
     3.9  placeholder.null-component=Keine
    3.10  
    3.11  version.status.Future=Geplant
     4.1 --- a/src/main/webapp/WEB-INF/jsp/issue-form.jsp	Sat Oct 17 20:06:14 2020 +0200
     4.2 +++ b/src/main/webapp/WEB-INF/jsp/issue-form.jsp	Thu Oct 22 11:06:15 2020 +0200
     4.3 @@ -128,7 +128,10 @@
     4.4              <th><fmt:message key="issue.assignee"/></th>
     4.5              <td>
     4.6                  <select name="assignee">
     4.7 -                    <option value="-1"><fmt:message key="placeholder.null-assignee"/></option>
     4.8 +                    <option value="-2" title="<fmt:message key="placeholder.auto-assignee.tooltip"/>"><fmt:message key="placeholder.auto-assignee"/></option>
     4.9 +                    <option value="-1"
    4.10 +                            <c:if test="${issue.id ge 0 and empty issue.assignee}">selected</c:if>
    4.11 +                    ><fmt:message key="placeholder.null-assignee"/></option>
    4.12                      <c:forEach var="user" items="${viewmodel.users}">
    4.13                          <option
    4.14                                  <c:if test="${not empty issue.assignee and user eq issue.assignee}">selected</c:if>

mercurial