#162 adds active flag to component

Wed, 18 Aug 2021 15:30:49 +0200

author
Mike Becker <universe@uap-core.de>
date
Wed, 18 Aug 2021 15:30:49 +0200
changeset 227
f0ede8046b59
parent 226
c8e1b5282f69
child 228
d68b08c8f6d0

#162 adds active flag to component

setup/postgres/psql_create_tables.sql file | annotate | diff | comparison | revisions
src/main/kotlin/de/uapcore/lightpit/RequestMapping.kt 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/Component.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/NavMenus.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/component-form.jsp file | annotate | diff | comparison | revisions
src/main/webapp/WEB-INF/jsp/components.jsp file | annotate | diff | comparison | revisions
src/main/webapp/WEB-INF/jsp/issue-form.jsp file | annotate | diff | comparison | revisions
--- a/setup/postgres/psql_create_tables.sql	Wed Aug 18 15:04:59 2021 +0200
+++ b/setup/postgres/psql_create_tables.sql	Wed Aug 18 15:30:49 2021 +0200
@@ -52,7 +52,8 @@
     color       char(6) not null default '000000',
     ordinal     integer not null default 0,
     description text,
-    lead        integer references lpit_user (userid)
+    lead        integer references lpit_user (userid),
+    active      boolean not null default true
 );
 
 create unique index lpit_component_node_unique on lpit_component (project, node);
--- a/src/main/kotlin/de/uapcore/lightpit/RequestMapping.kt	Wed Aug 18 15:04:59 2021 +0200
+++ b/src/main/kotlin/de/uapcore/lightpit/RequestMapping.kt	Wed Aug 18 15:30:49 2021 +0200
@@ -304,4 +304,12 @@
     }
 }
 
+fun boolValidator(input: String?): ValidationResult<Boolean> {
+    return if (input.isNullOrBlank()) {
+        ValidatedValue(false)
+    } else {
+        ValidatedValue(!(input.equals("false", true) || input == "0"))
+    }
+}
+
 // </editor-fold>
--- a/src/main/kotlin/de/uapcore/lightpit/dao/PostgresDataAccessObject.kt	Wed Aug 18 15:04:59 2021 +0200
+++ b/src/main/kotlin/de/uapcore/lightpit/dao/PostgresDataAccessObject.kt	Wed Aug 18 15:30:49 2021 +0200
@@ -249,7 +249,7 @@
     //language=SQL
     private val componentQuery =
         """
-        select id, project, name, node, color, ordinal, description,
+        select id, project, name, node, color, ordinal, description, active,
             userid, username, givenname, lastname, mail
         from lpit_component
         left join lpit_user on lead = userid
@@ -266,6 +266,7 @@
             }
             ordinal = getInt("ordinal")
             description = getString("description")
+            active = getBoolean("active")
             lead = extractOptionalUser()
         }
 
@@ -277,6 +278,7 @@
             setStringSafe(i++, color.hex)
             setInt(i++, ordinal)
             setStringOrNull(i++, description)
+            setBoolean(i++, active)
             setIntOrNull(i++, lead?.id)
             return i
         }
@@ -302,13 +304,13 @@
                 from lpit_component c
                 left join issues i on c.id = i.component 
             )
-            select c.id, project, name, node, color, ordinal, description,
+            select c.id, project, name, node, color, ordinal, description, active,
                 userid, username, givenname, lastname, mail,
-                open.total as open, active.total as active, done.total as done
+                open.total as open, wip.total as wip, done.total as done
             from lpit_component c
             left join lpit_user on lead = userid
             left join summary open on c.id = open.id and open.phase = 0
-            left join summary active on c.id = active.id and active.phase = 1
+            left join summary wip on c.id = wip.id and wip.phase = 1
             left join summary done on c.id = done.id and done.phase = 2
             where c.project = ?
             order by ordinal, name
@@ -318,7 +320,7 @@
             queryAll { rs ->
                 ComponentSummary(rs.extractComponent()).apply {
                     issueSummary.open = rs.getInt("open")
-                    issueSummary.active = rs.getInt("active")
+                    issueSummary.active = rs.getInt("wip")
                     issueSummary.done = rs.getInt("done")
                 }
             }
@@ -338,7 +340,7 @@
         }
 
     override fun insertComponent(component: Component) {
-        withStatement("insert into lpit_component (name, node, color, ordinal, description, lead, project) values (?, ?, ?, ?, ?, ?, ?)") {
+        withStatement("insert into lpit_component (name, node, color, ordinal, description, active, lead, project) values (?, ?, ?, ?, ?, ?, ?, ?)") {
             val col = setComponent(1, component)
             setInt(col, component.projectid)
             executeUpdate()
@@ -346,7 +348,7 @@
     }
 
     override fun updateComponent(component: Component) {
-        withStatement("update lpit_component set name = ?, node = ?, color = ?, ordinal = ?, description = ?, lead = ? where id = ?") {
+        withStatement("update lpit_component set name = ?, node = ?, color = ?, ordinal = ?, description = ?, active = ?, lead = ? where id = ?") {
             val col = setComponent(1, component)
             setInt(col, component.id)
             executeUpdate()
--- a/src/main/kotlin/de/uapcore/lightpit/entities/Component.kt	Wed Aug 18 15:04:59 2021 +0200
+++ b/src/main/kotlin/de/uapcore/lightpit/entities/Component.kt	Wed Aug 18 15:30:49 2021 +0200
@@ -34,4 +34,5 @@
     var color = WebColor("000000")
     var description: String? = null
     var lead: User? = null
+    var active = true
 }
\ No newline at end of file
--- a/src/main/kotlin/de/uapcore/lightpit/servlet/ProjectServlet.kt	Wed Aug 18 15:04:59 2021 +0200
+++ b/src/main/kotlin/de/uapcore/lightpit/servlet/ProjectServlet.kt	Wed Aug 18 15:30:49 2021 +0200
@@ -27,6 +27,7 @@
 
 import de.uapcore.lightpit.AbstractServlet
 import de.uapcore.lightpit.HttpRequest
+import de.uapcore.lightpit.boolValidator
 import de.uapcore.lightpit.dao.DataAccessObject
 import de.uapcore.lightpit.dateOptValidator
 import de.uapcore.lightpit.entities.*
@@ -419,6 +420,8 @@
             ordinal = http.param("ordinal")?.toIntOrNull() ?: 0
             color = WebColor(http.param("color") ?: "#000000")
             description = http.param("description")
+            // TODO: process error message
+            active = http.param("active", ::boolValidator, true, mutableListOf())
             lead = (http.param("lead")?.toIntOrNull() ?: -1).let {
                 if (it < 0) null else dao.findUser(it)
             }
--- a/src/main/kotlin/de/uapcore/lightpit/viewmodel/NavMenus.kt	Wed Aug 18 15:04:59 2021 +0200
+++ b/src/main/kotlin/de/uapcore/lightpit/viewmodel/NavMenus.kt	Wed Aug 18 15:30:49 2021 +0200
@@ -113,6 +113,7 @@
                     )
                 )
                 for (component in components) {
+                    if (!component.active && component != selectedComponent) continue
                     yield(
                         NavMenuEntry(
                             level = 2,
--- a/src/main/resources/localization/strings.properties	Wed Aug 18 15:04:59 2021 +0200
+++ b/src/main/resources/localization/strings.properties	Wed Aug 18 15:30:49 2021 +0200
@@ -43,6 +43,7 @@
 button.version.edit=Edit Version
 commit.redirect-link=If redirection does not work, click the following link:
 commit.success=Operation successful - you will be redirected in a second.
+component.active=Active
 component.color=Color
 component.lead=Lead
 component=Component
--- a/src/main/resources/localization/strings_de.properties	Wed Aug 18 15:04:59 2021 +0200
+++ b/src/main/resources/localization/strings_de.properties	Wed Aug 18 15:30:49 2021 +0200
@@ -42,6 +42,7 @@
 button.version.edit=Version Bearbeiten
 commit.redirect-link=Falls die Weiterleitung nicht klappt, klicken Sie bitte hier:
 commit.success=Operation erfolgreich - Sie werden jeden Moment weitergeleitet.
+component.active=Aktiv
 component.color=Farbe
 component.lead=Leitung
 component=Komponente
--- a/src/main/webapp/WEB-INF/changelogs/changelog-de.jspf	Wed Aug 18 15:04:59 2021 +0200
+++ b/src/main/webapp/WEB-INF/changelogs/changelog-de.jspf	Wed Aug 18 15:30:49 2021 +0200
@@ -27,6 +27,7 @@
 <h3>Version 1.0 (Vorschau)</h3>
 
 <ul>
+    <li>Möglichkeit zum Deaktivieren einer Komponente hinzugefügt.</li>
     <li>Datum der Veröffentlichung und des Supportendes zu Versionen hinzugefügt.</li>
     <li>Gesamtanzahl der Kommentare wird nun angezeigt.</li>
     <li>Spalte für zugewiesener Entwickler zu den Vorgangstabellen hinzugefügt.</li>
--- a/src/main/webapp/WEB-INF/changelogs/changelog.jspf	Wed Aug 18 15:04:59 2021 +0200
+++ b/src/main/webapp/WEB-INF/changelogs/changelog.jspf	Wed Aug 18 15:30:49 2021 +0200
@@ -27,6 +27,7 @@
 <h3>Version 1.0 (snapshot)</h3>
 
 <ul>
+    <li>Adds possibility to deactivate a component.</li>
     <li>Adds release and end of life dates to versions.</li>
     <li>Adds the total number of comments to the caption.</li>
     <li>Adds assignee to the issue overview tables.</li>
--- a/src/main/webapp/WEB-INF/jsp/component-form.jsp	Wed Aug 18 15:04:59 2021 +0200
+++ b/src/main/webapp/WEB-INF/jsp/component-form.jsp	Wed Aug 18 15:30:49 2021 +0200
@@ -47,21 +47,21 @@
             </td>
         </tr>
         <tr>
-            <th><fmt:message key="component"/></th>
-            <td><input name="name" type="text" maxlength="20" required value="<c:out value="${component.name}"/>" /></td>
+            <th><label for="component-name"><fmt:message key="component"/></label></th>
+            <td><input id="component-name" name="name" type="text" maxlength="20" required value="<c:out value="${component.name}"/>" /></td>
         </tr>
         <tr title="<fmt:message key="node.tooltip"/>">
-            <th><fmt:message key="node"/></th>
-            <td><input name="node" type="text" maxlength="20" value="<c:out value="${component.node}"/>" /></td>
+            <th><label for="component-node"><fmt:message key="node"/></label></th>
+            <td><input id="component-node" ame="node" type="text" maxlength="20" value="<c:out value="${component.node}"/>" /></td>
         </tr>
         <tr>
-            <th><fmt:message key="component.color"/></th>
-            <td><input name="color" type="color" required value="${component.color}" /></td>
+            <th><label for="component-color"><fmt:message key="component.color"/></label></th>
+            <td><input id="component-color" name="color" type="color" required value="${component.color}" /></td>
         </tr>
         <tr>
-            <th><fmt:message key="component.lead"/></th>
+            <th><label for="component-lead"><fmt:message key="component.lead"/></label></th>
             <td>
-                <select name="lead">
+                <select id="component-lead" name="lead">
                     <option value="-1"><fmt:message key="placeholder.null-lead"/></option>
                     <c:forEach var="user" items="${viewmodel.users}">
                         <option
@@ -72,15 +72,21 @@
             </td>
         </tr>
         <tr title="<fmt:message key="ordinal.tooltip" />">
-            <th><fmt:message key="ordinal"/></th>
+            <th><label for="component-ordinal"><fmt:message key="ordinal"/></label></th>
             <td>
-                <input name="ordinal" type="number" value="${component.ordinal}"/>
+                <input id="component-ordinal" name="ordinal" type="number" value="${component.ordinal}"/>
             </td>
         </tr>
         <tr>
-            <th class="vtop"><fmt:message key="description"/></th>
+            <th class="vtop"><label for="component-description"><fmt:message key="description"/></label></th>
             <td>
-                <textarea name="description" rows="5"><c:out value="${component.description}"/></textarea>
+                <textarea id="component-description" name="description" rows="5"><c:out value="${component.description}"/></textarea>
+            </td>
+        </tr>
+        <tr>
+            <th><label for="component-active"><fmt:message key="component.active"/></label></th>
+            <td>
+                <input type="checkbox" id="component-active" name="active" <c:if test="${component.active}">checked</c:if> >
             </td>
         </tr>
         </tbody>
--- a/src/main/webapp/WEB-INF/jsp/components.jsp	Wed Aug 18 15:04:59 2021 +0200
+++ b/src/main/webapp/WEB-INF/jsp/components.jsp	Wed Aug 18 15:30:49 2021 +0200
@@ -75,7 +75,9 @@
             <td rowspan="2" style="width: 2em;"><a href="./projects/${project.node}/components/${componentInfo.component.node}/edit">&#x270e;</a></td>
             <td rowspan="2">
                 <div class="navmenu-icon" style="background-color: ${componentInfo.component.color}"></div>
-                <a href="./projects/${project.node}/issues/-/${componentInfo.component.node}/">
+                <a href="./projects/${project.node}/issues/-/${componentInfo.component.node}/"
+                        <c:if test="${not componentInfo.component.active}">style="text-decoration: line-through;"</c:if>
+                >
                     <c:out value="${componentInfo.component.name}"/>
                 </a>
             </td>
--- a/src/main/webapp/WEB-INF/jsp/issue-form.jsp	Wed Aug 18 15:04:59 2021 +0200
+++ b/src/main/webapp/WEB-INF/jsp/issue-form.jsp	Wed Aug 18 15:30:49 2021 +0200
@@ -57,9 +57,12 @@
                 <select id="issue-component" name="component">
                     <option value="-1"><fmt:message key="placeholder.null-component"/></option>
                     <c:forEach var="comp" items="${viewmodel.components}">
+                        <c:set var="isSelectedComponent" value="${not empty issue.component and comp eq issue.component}" scope="page"/>
+                        <c:if test="${isSelectedComponent or comp.active}">
                         <option
-                                <c:if test="${not empty issue.component and comp eq issue.component}">selected</c:if>
+                                <c:if test="${isSelectedComponent}">selected</c:if>
                                 value="${comp.id}"><c:out value="${comp.name}"/></option>
+                        </c:if>
                     </c:forEach>
                 </select>
             </td>

mercurial