#163 removes multi selection for versions

Thu, 19 Aug 2021 14:51:04 +0200

author
Mike Becker <universe@uap-core.de>
date
Thu, 19 Aug 2021 14:51:04 +0200
changeset 231
dcb1d5a7ea3a
parent 230
95b419e054fa
child 232
296e12ff8d1c

#163 removes multi selection for versions

setup/postgres/psql_create_tables.sql file | annotate | diff | comparison | revisions
src/main/kotlin/de/uapcore/lightpit/dao/PostgresDataAccessObject.kt file | annotate | diff | comparison | revisions
src/main/kotlin/de/uapcore/lightpit/entities/Issue.kt file | annotate | diff | comparison | revisions
src/main/kotlin/de/uapcore/lightpit/servlet/ProjectServlet.kt file | annotate | diff | comparison | revisions
src/main/kotlin/de/uapcore/lightpit/viewmodel/Issues.kt file | annotate | diff | comparison | revisions
src/main/kotlin/de/uapcore/lightpit/viewmodel/Versions.kt file | annotate | diff | comparison | revisions
src/main/resources/localization/strings.properties file | annotate | diff | comparison | revisions
src/main/resources/localization/strings_de.properties file | annotate | diff | comparison | revisions
src/main/webapp/WEB-INF/changelogs/changelog-de.jspf file | annotate | diff | comparison | revisions
src/main/webapp/WEB-INF/changelogs/changelog.jspf file | annotate | diff | comparison | revisions
src/main/webapp/WEB-INF/jsp/issue-form.jsp file | annotate | diff | comparison | revisions
src/main/webapp/WEB-INF/jsp/issue-view.jsp file | annotate | diff | comparison | revisions
src/main/webapp/WEB-INF/jspf/version-list.jspf file | annotate | diff | comparison | revisions
     1.1 --- a/setup/postgres/psql_create_tables.sql	Wed Aug 18 16:02:40 2021 +0200
     1.2 +++ b/setup/postgres/psql_create_tables.sql	Thu Aug 19 14:51:04 2021 +0200
     1.3 @@ -96,21 +96,9 @@
     1.4      assignee    integer references lpit_user (userid),
     1.5      created     timestamp with time zone not null default now(),
     1.6      updated     timestamp with time zone not null default now(),
     1.7 -    eta         date
     1.8 -);
     1.9 -
    1.10 -create table lpit_issue_affected_version
    1.11 -(
    1.12 -    issueid   integer references lpit_issue (issueid),
    1.13 -    versionid integer references lpit_version (versionid),
    1.14 -    primary key (issueid, versionid)
    1.15 -);
    1.16 -
    1.17 -create table lpit_issue_resolved_version
    1.18 -(
    1.19 -    issueid   integer references lpit_issue (issueid),
    1.20 -    versionid integer references lpit_version (versionid),
    1.21 -    primary key (issueid, versionid)
    1.22 +    eta         date,
    1.23 +    affected    integer references lpit_version (versionid),
    1.24 +    resolved    integer references lpit_version (versionid)
    1.25  );
    1.26  
    1.27  create table lpit_issue_comment
     2.1 --- a/src/main/kotlin/de/uapcore/lightpit/dao/PostgresDataAccessObject.kt	Wed Aug 18 16:02:40 2021 +0200
     2.2 +++ b/src/main/kotlin/de/uapcore/lightpit/dao/PostgresDataAccessObject.kt	Thu Aug 19 14:51:04 2021 +0200
     2.3 @@ -153,18 +153,13 @@
     2.4  
     2.5      override fun listVersionSummaries(project: Project): List<VersionSummary> =
     2.6          withStatement(
     2.7 -            """
     2.8 -            with version_map(issueid, versionid, isresolved) as (
     2.9 -                select issueid, versionid, true
    2.10 -                from lpit_issue_resolved_version
    2.11 -                union
    2.12 -                select issueid, versionid, false
    2.13 -                from lpit_issue_affected_version
    2.14 -            ),
    2.15 -            issues as (
    2.16 -                select versionid, phase, isresolved, count(issueid) as total
    2.17 -                from lpit_issue
    2.18 -                join version_map using (issueid)
    2.19 +            """with
    2.20 +            version_map as (
    2.21 +                select issueid, status, resolved as versionid, true as isresolved from lpit_issue
    2.22 +                union all
    2.23 +                select issueid, status, affected as versionid, false as isresolved from lpit_issue
    2.24 +            ), issues as (
    2.25 +                select versionid, phase, isresolved, count(issueid) as total from version_map
    2.26                  join lpit_issue_phases using (status)
    2.27                  group by versionid, phase, isresolved
    2.28              ),
    2.29 @@ -461,7 +456,7 @@
    2.30              component, c.name as componentname, c.node as componentnode,
    2.31              status, category, subject, i.description,
    2.32              userid, username, givenname, lastname, mail,
    2.33 -            created, updated, eta
    2.34 +            created, updated, eta, affected, resolved
    2.35          from lpit_issue i
    2.36          join lpit_project p on i.project = projectid
    2.37          left join lpit_component c on component = c.id
    2.38 @@ -490,30 +485,10 @@
    2.39              created = getTimestamp("created")
    2.40              updated = getTimestamp("updated")
    2.41              eta = getDate("eta")
    2.42 +            affected = getInt("affected").takeIf { it > 0 }?.let { findVersion(it) }
    2.43 +            resolved = getInt("resolved").takeIf { it > 0 }?.let { findVersion(it) }
    2.44          }
    2.45  
    2.46 -        //language=SQL
    2.47 -        val queryAffected =
    2.48 -            """
    2.49 -            $versionQuery join lpit_issue_affected_version using (versionid)
    2.50 -            where issueid = ? order by ordinal, name
    2.51 -            """.trimIndent()
    2.52 -
    2.53 -        //language=SQL
    2.54 -        val queryResolved =
    2.55 -            """
    2.56 -            $versionQuery join lpit_issue_resolved_version using (versionid)
    2.57 -            where issueid = ? order by ordinal, name
    2.58 -            """.trimIndent()
    2.59 -
    2.60 -        issue.affectedVersions = withStatement(queryAffected) {
    2.61 -            setInt(1, issue.id)
    2.62 -            queryAll { it.extractVersion() }
    2.63 -        }
    2.64 -        issue.resolvedVersions = withStatement(queryResolved) {
    2.65 -            setInt(1, issue.id)
    2.66 -            queryAll { it.extractVersion() }
    2.67 -        }
    2.68          return issue
    2.69      }
    2.70  
    2.71 @@ -527,26 +502,18 @@
    2.72              setStringOrNull(i++, description)
    2.73              setIntOrNull(i++, assignee?.id)
    2.74              setDateOrNull(i++, eta)
    2.75 +            setIntOrNull(i++, affected?.id)
    2.76 +            setIntOrNull(i++, resolved?.id)
    2.77          }
    2.78          return i
    2.79      }
    2.80  
    2.81      override fun listIssues(filter: IssueFilter): List<Issue> =
    2.82          withStatement(
    2.83 -            """
    2.84 -            with issue_version as (
    2.85 -                select issueid, versionid from lpit_issue_affected_version
    2.86 -                union select issueid, versionid from lpit_issue_resolved_version
    2.87 -            ),
    2.88 -            filtered_issues as (
    2.89 -                select distinct issueid from lpit_issue
    2.90 -                left join issue_version using (issueid)
    2.91 -                where
    2.92 -                (not ? or project = ?) and 
    2.93 -                (not ? or versionid = ?) and (not ? or versionid is null) and
    2.94 +            """$issueQuery where
    2.95 +                (not ? or i.project = ?) and 
    2.96 +                (not ? or ? in (resolved, affected)) and (not ? or (resolved is null and affected is null)) and
    2.97                  (not ? or component = ?) and (not ? or component is null)
    2.98 -            )
    2.99 -            $issueQuery join filtered_issues using (issueid)
   2.100              """.trimIndent()
   2.101          ) {
   2.102              fun <T : Entity> applyFilter(filter: Filter<T>, fflag: Int, nflag: Int, idcol: Int) {
   2.103 @@ -594,27 +561,10 @@
   2.104              querySingle { it.extractIssue() }
   2.105          }
   2.106  
   2.107 -    private fun insertVersionInfo(id: Int, issue: Issue) {
   2.108 -        withStatement("insert into lpit_issue_affected_version (issueid, versionid) values (?,?)") {
   2.109 -            setInt(1, id)
   2.110 -            issue.affectedVersions.forEach {
   2.111 -                setInt(2, it.id)
   2.112 -                executeUpdate()
   2.113 -            }
   2.114 -        }
   2.115 -        withStatement("insert into lpit_issue_resolved_version (issueid, versionid) values (?,?)") {
   2.116 -            setInt(1, id)
   2.117 -            issue.resolvedVersions.forEach {
   2.118 -                setInt(2, it.id)
   2.119 -                executeUpdate()
   2.120 -            }
   2.121 -        }
   2.122 -    }
   2.123 -
   2.124      override fun insertIssue(issue: Issue): Int {
   2.125          val id = withStatement(
   2.126              """
   2.127 -            insert into lpit_issue (component, status, category, subject, description, assignee, eta, project)
   2.128 +            insert into lpit_issue (component, status, category, subject, description, assignee, eta, affected, resolved, project)
   2.129              values (?, ?::issue_status, ?::issue_category, ?, ?, ?, ?, ?)
   2.130              returning issueid
   2.131              """.trimIndent()
   2.132 @@ -623,7 +573,6 @@
   2.133              setInt(col, issue.project.id)
   2.134              querySingle { it.getInt(1) }!!
   2.135          }
   2.136 -        insertVersionInfo(id, issue)
   2.137          return id
   2.138      }
   2.139  
   2.140 @@ -632,7 +581,7 @@
   2.141              """
   2.142              update lpit_issue set updated = now(),
   2.143                  component = ?, status = ?::issue_status, category = ?::issue_category, subject = ?,
   2.144 -                description = ?, assignee = ?, eta = ?
   2.145 +                description = ?, assignee = ?, eta = ?, affected = ?, resolved = ?
   2.146              where issueid = ?
   2.147              """.trimIndent()
   2.148          ) {
   2.149 @@ -640,17 +589,6 @@
   2.150              setInt(col, issue.id)
   2.151              executeUpdate()
   2.152          }
   2.153 -
   2.154 -        // TODO: improve by only inserting / deleting changed version information
   2.155 -        withStatement("delete from lpit_issue_affected_version where issueid = ?") {
   2.156 -            setInt(1, issue.id)
   2.157 -            executeUpdate()
   2.158 -        }
   2.159 -        withStatement("delete from lpit_issue_resolved_version where issueid = ?") {
   2.160 -            setInt(1, issue.id)
   2.161 -            executeUpdate()
   2.162 -        }
   2.163 -        insertVersionInfo(issue.id, issue)
   2.164      }
   2.165  
   2.166      //</editor-fold>
     3.1 --- a/src/main/kotlin/de/uapcore/lightpit/entities/Issue.kt	Wed Aug 18 16:02:40 2021 +0200
     3.2 +++ b/src/main/kotlin/de/uapcore/lightpit/entities/Issue.kt	Thu Aug 19 14:51:04 2021 +0200
     3.3 @@ -45,8 +45,8 @@
     3.4      var updated: Timestamp = Timestamp.from(Instant.now())
     3.5      var eta: Date? = null
     3.6  
     3.7 -    var affectedVersions = emptyList<Version>()
     3.8 -    var resolvedVersions = emptyList<Version>()
     3.9 +    var affected: Version? = null
    3.10 +    var resolved: Version? = null
    3.11  
    3.12      /**
    3.13       * An issue is overdue, if it is not done and the ETA is before the current time.
     4.1 --- a/src/main/kotlin/de/uapcore/lightpit/servlet/ProjectServlet.kt	Wed Aug 18 16:02:40 2021 +0200
     4.2 +++ b/src/main/kotlin/de/uapcore/lightpit/servlet/ProjectServlet.kt	Thu Aug 19 14:51:04 2021 +0200
     4.3 @@ -482,9 +482,9 @@
     4.4                  // pre-select version, if available in the path info
     4.5                  if (version != null) {
     4.6                      if (version.status.isReleased) {
     4.7 -                        issue.affectedVersions = listOf(version)
     4.8 +                        issue.affected = version
     4.9                      } else {
    4.10 -                        issue.resolvedVersions = listOf(version)
    4.11 +                        issue.resolved = version
    4.12                      }
    4.13                  }
    4.14              }
    4.15 @@ -565,10 +565,8 @@
    4.16                  // TODO: process error messages
    4.17                  eta = http.param("eta", ::dateOptValidator, null, mutableListOf())
    4.18  
    4.19 -                affectedVersions = http.paramArray("affected")
    4.20 -                    .mapNotNull { param -> param.toIntOrNull()?.let { Version(it, project.id) } }
    4.21 -                resolvedVersions = http.paramArray("resolved")
    4.22 -                    .mapNotNull { param -> param.toIntOrNull()?.let { Version(it, project.id) } }
    4.23 +                affected = http.param("affected")?.toIntOrNull()?.takeIf { it > 0 }?.let { Version(it, project.id) }
    4.24 +                resolved = http.param("resolved")?.toIntOrNull()?.takeIf { it > 0 }?.let { Version(it, project.id) }
    4.25              }
    4.26  
    4.27              val openId = if (issue.id < 0) {
     5.1 --- a/src/main/kotlin/de/uapcore/lightpit/viewmodel/Issues.kt	Wed Aug 18 16:02:40 2021 +0200
     5.2 +++ b/src/main/kotlin/de/uapcore/lightpit/viewmodel/Issues.kt	Thu Aug 19 14:51:04 2021 +0200
     5.3 @@ -76,7 +76,7 @@
     5.4          val renderer = HtmlRenderer.builder(options).build()
     5.5          val process = fun(it: String) = renderer.render(parser.parse(it))
     5.6  
     5.7 -        issue.description = process(issue.description?:"")
     5.8 +        issue.description = process(issue.description ?: "")
     5.9          for (comment in comments) {
    5.10              comment.commentFormatted = process(comment.comment)
    5.11          }
    5.12 @@ -101,9 +101,10 @@
    5.13  
    5.14      init {
    5.15          val recent = mutableListOf<Version>()
    5.16 +        issue.affected?.let { recent.add(it) }
    5.17          val upcoming = mutableListOf<Version>()
    5.18 -        recent.addAll(issue.affectedVersions)
    5.19 -        upcoming.addAll(issue.resolvedVersions)
    5.20 +        issue.resolved?.let { upcoming.add(it) }
    5.21 +
    5.22          for (v in versions) {
    5.23              if (v.status.isReleased) {
    5.24                  if (v.status != VersionStatus.Deprecated) recent.add(v)
     6.1 --- a/src/main/kotlin/de/uapcore/lightpit/viewmodel/Versions.kt	Wed Aug 18 16:02:40 2021 +0200
     6.2 +++ b/src/main/kotlin/de/uapcore/lightpit/viewmodel/Versions.kt	Thu Aug 19 14:51:04 2021 +0200
     6.3 @@ -42,11 +42,11 @@
     6.4          val reported = mutableListOf<Issue>()
     6.5          val resolved = mutableListOf<Issue>()
     6.6          for (issue in issues) {
     6.7 -            if (issue.affectedVersions.contains(version)) {
     6.8 +            if (issue.affected == version) {
     6.9                  reportedTotal.add(issue)
    6.10                  reported.add(issue)
    6.11              }
    6.12 -            if (issue.resolvedVersions.contains(version)) {
    6.13 +            if (issue.resolved == version) {
    6.14                  resolvedTotal.add(issue)
    6.15                  resolved.add(issue)
    6.16              }
     7.1 --- a/src/main/resources/localization/strings.properties	Wed Aug 18 16:02:40 2021 +0200
     7.2 +++ b/src/main/resources/localization/strings.properties	Thu Aug 19 14:51:04 2021 +0200
     7.3 @@ -121,6 +121,7 @@
     7.4  placeholder.null-component=Unassigned
     7.5  placeholder.null-lead=Unassigned
     7.6  placeholder.null-owner=Unassigned
     7.7 +placeholder.null-version=None
     7.8  progress=Overall Progress
     7.9  project.name=Name
    7.10  project.owner=Project Lead
     8.1 --- a/src/main/resources/localization/strings_de.properties	Wed Aug 18 16:02:40 2021 +0200
     8.2 +++ b/src/main/resources/localization/strings_de.properties	Thu Aug 19 14:51:04 2021 +0200
     8.3 @@ -120,6 +120,7 @@
     8.4  placeholder.null-component=Keine
     8.5  placeholder.null-lead=Niemand
     8.6  placeholder.null-owner=Nicht Zugewiesen
     8.7 +placeholder.null-version=Keine
     8.8  progress=Gesamtfortschritt
     8.9  project.name=Name
    8.10  project.owner=Projektleitung
     9.1 --- a/src/main/webapp/WEB-INF/changelogs/changelog-de.jspf	Wed Aug 18 16:02:40 2021 +0200
     9.2 +++ b/src/main/webapp/WEB-INF/changelogs/changelog-de.jspf	Thu Aug 19 14:51:04 2021 +0200
     9.3 @@ -27,6 +27,7 @@
     9.4  <h3>Version 1.0 (Vorschau)</h3>
     9.5  
     9.6  <ul>
     9.7 +    <li>Mehrfachauswahl für Versionen im Vorgang entfernt.</li>
     9.8      <li>Möglichkeit zum Deaktivieren einer Komponente hinzugefügt.</li>
     9.9      <li>Datum der Veröffentlichung und des Supportendes zu Versionen hinzugefügt.</li>
    9.10      <li>Gesamtanzahl der Kommentare wird nun angezeigt.</li>
    10.1 --- a/src/main/webapp/WEB-INF/changelogs/changelog.jspf	Wed Aug 18 16:02:40 2021 +0200
    10.2 +++ b/src/main/webapp/WEB-INF/changelogs/changelog.jspf	Thu Aug 19 14:51:04 2021 +0200
    10.3 @@ -27,6 +27,7 @@
    10.4  <h3>Version 1.0 (snapshot)</h3>
    10.5  
    10.6  <ul>
    10.7 +    <li>Removes multi selection of versions within an issue.</li>
    10.8      <li>Adds possibility to deactivate a component.</li>
    10.9      <li>Adds release and end of life dates to versions.</li>
   10.10      <li>Adds the total number of comments to the caption.</li>
    11.1 --- a/src/main/webapp/WEB-INF/jsp/issue-form.jsp	Wed Aug 18 16:02:40 2021 +0200
    11.2 +++ b/src/main/webapp/WEB-INF/jsp/issue-form.jsp	Thu Aug 19 14:51:04 2021 +0200
    11.3 @@ -125,19 +125,27 @@
    11.4          <tr>
    11.5              <th class="vtop"><label for="issue-affected"><fmt:message key="issue.affected-versions"/></label></th>
    11.6              <td>
    11.7 -                <c:set var="fieldname" value="affected"/>
    11.8 -                <c:set var="selectionList" value="${viewmodel.versionsRecent}"/>
    11.9 -                <c:set var="data" value="${issue.affectedVersions}" />
   11.10 -                <%@include file="../jspf/version-list.jspf"%>
   11.11 +                <select id="issue-affected" name="affected">
   11.12 +                    <option value="-1"><fmt:message key="placeholder.null-version"/></option>
   11.13 +                    <c:forEach var="vselitem" items="${viewmodel.versionsRecent}">
   11.14 +                        <option value="${vselitem.id}" <c:if test="${issue.affected eq vselitem}">selected</c:if> >
   11.15 +                            <c:out value="${vselitem.name}" />
   11.16 +                        </option>
   11.17 +                    </c:forEach>
   11.18 +                </select>
   11.19              </td>
   11.20          </tr>
   11.21          <tr>
   11.22              <th class="vtop"><label for="issue-resolved"><fmt:message key="issue.resolved-versions"/></label></th>
   11.23              <td>
   11.24 -                <c:set var="fieldname" value="resolved"/>
   11.25 -                <c:set var="selectionList" value="${viewmodel.versionsUpcoming}"/>
   11.26 -                <c:set var="data" value="${issue.resolvedVersions}" />
   11.27 -                <%@include file="../jspf/version-list.jspf"%>
   11.28 +                <select id="issue-resolved" name="resolved">
   11.29 +                    <option value="-1"><fmt:message key="placeholder.null-version"/></option>
   11.30 +                    <c:forEach var="vselitem" items="${viewmodel.versionsUpcoming}">
   11.31 +                        <option value="${vselitem.id}" <c:if test="${issue.resolved eq vselitem}">selected</c:if> >
   11.32 +                            <c:out value="${vselitem.name}" />
   11.33 +                        </option>
   11.34 +                    </c:forEach>
   11.35 +                </select>
   11.36              </td>
   11.37          </tr>
   11.38          </c:if>
    12.1 --- a/src/main/webapp/WEB-INF/jsp/issue-view.jsp	Wed Aug 18 16:02:40 2021 +0200
    12.2 +++ b/src/main/webapp/WEB-INF/jsp/issue-view.jsp	Thu Aug 19 14:51:04 2021 +0200
    12.3 @@ -95,15 +95,11 @@
    12.4      <tr>
    12.5          <th><fmt:message key="issue.resolved-versions"/></th>
    12.6          <td>
    12.7 -            <c:forEach var="version" items="${issue.resolvedVersions}">
    12.8 -                <c:out value="${version.name}"/>
    12.9 -            </c:forEach>
   12.10 +            <c:out value="${issue.resolved.name}"/>
   12.11          </td>
   12.12          <th><fmt:message key="issue.affected-versions"/></th>
   12.13          <td>
   12.14 -            <c:forEach var="version" items="${issue.affectedVersions}">
   12.15 -                <c:out value="${version.name}"/>
   12.16 -            </c:forEach>
   12.17 +            <c:out value="${issue.affected.name}"/>
   12.18          </td>
   12.19      </tr>
   12.20      </tbody>
    13.1 --- a/src/main/webapp/WEB-INF/jspf/version-list.jspf	Wed Aug 18 16:02:40 2021 +0200
    13.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.3 @@ -1,14 +0,0 @@
    13.4 -<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
    13.5 -
    13.6 -<select id="issue-${fieldname}" name="${fieldname}" multiple>
    13.7 -    <c:forEach var="vselitem" items="${selectionList}">
    13.8 -        <option value="${vselitem.id}"
    13.9 -                <c:forEach var="v" items="${data}">
   13.10 -                    <c:if test="${v eq vselitem}">selected</c:if>
   13.11 -                </c:forEach>
   13.12 -                <c:if test="${vid eq vselitem.id}">selected</c:if>
   13.13 -        >
   13.14 -            <c:out value="${vselitem.name}" />
   13.15 -        </option>
   13.16 -    </c:forEach>
   13.17 -</select>

mercurial