Mon, 04 Jan 2021 15:25:59 +0100
adds project ordering - fixes #34
1.1 --- a/setup/postgres/psql_create_tables.sql Mon Jan 04 15:14:26 2021 +0100 1.2 +++ b/setup/postgres/psql_create_tables.sql Mon Jan 04 15:25:59 2021 +0100 1.3 @@ -13,6 +13,7 @@ 1.4 projectid serial primary key, 1.5 name varchar(20) not null unique, 1.6 node varchar(20) not null unique, 1.7 + ordinal integer not null default 0, 1.8 description varchar(200), 1.9 repoUrl varchar(50), 1.10 owner integer references lpit_user(userid)
2.1 --- a/src/main/java/de/uapcore/lightpit/modules/ProjectsModule.java Mon Jan 04 15:14:26 2021 +0100 2.2 +++ b/src/main/java/de/uapcore/lightpit/modules/ProjectsModule.java Mon Jan 04 15:25:59 2021 +0100 2.3 @@ -187,6 +187,7 @@ 2.4 2.5 final var node = getParameter(req, String.class, "node").orElse(null); 2.6 project.setNode(sanitizeNode(node, project.getName())); 2.7 + getParameter(req, Integer.class, "ordinal").ifPresent(project::setOrdinal); 2.8 2.9 getParameter(req, String.class, "description").ifPresent(project::setDescription); 2.10 getParameter(req, String.class, "repoUrl").ifPresent(project::setRepoUrl);
3.1 --- a/src/main/kotlin/de/uapcore/lightpit/dao/PostgresDataAccessObject.kt Mon Jan 04 15:14:26 2021 +0100 3.2 +++ b/src/main/kotlin/de/uapcore/lightpit/dao/PostgresDataAccessObject.kt Mon Jan 04 15:25:59 2021 +0100 3.3 @@ -338,6 +338,7 @@ 3.4 yield(Project(rs.getInt("projectid")).apply { 3.5 name = rs.getString("name") 3.6 node = rs.getString("node") 3.7 + ordinal = rs.getInt("ordinal") 3.8 description = rs.getString("description") 3.9 repoUrl = rs.getString("repourl") 3.10 owner = selectUserInfo(rs) 3.11 @@ -350,17 +351,18 @@ 3.12 with(obj) { 3.13 stmt.setStringSafe(1, name) 3.14 stmt.setStringSafe(2, node) 3.15 - stmt.setStringOrNull(3, description) 3.16 - stmt.setStringOrNull(4, repoUrl) 3.17 - stmt.setIntOrNull(5, owner?.id) 3.18 + stmt.setInt(3, ordinal) 3.19 + stmt.setStringOrNull(4, description) 3.20 + stmt.setStringOrNull(5, repoUrl) 3.21 + stmt.setIntOrNull(6, owner?.id) 3.22 } 3.23 - return 6 3.24 + return 7 3.25 } 3.26 3.27 //language=SQL 3.28 private val projectQuery = 3.29 """ 3.30 - select projectid, name, node, description, repourl, 3.31 + select projectid, name, node, ordinal, description, repourl, 3.32 userid, username, lastname, givenname, mail 3.33 from lpit_project 3.34 left join lpit_user owner on lpit_project.owner = owner.userid 3.35 @@ -369,7 +371,7 @@ 3.36 private val stmtProjects by lazy { 3.37 connection.prepareStatement( 3.38 """${projectQuery} 3.39 - order by lower(name) 3.40 + order by ordinal, lower(name) 3.41 """ 3.42 ) 3.43 } 3.44 @@ -389,12 +391,12 @@ 3.45 } 3.46 private val stmtInsertProject by lazy { 3.47 connection.prepareStatement( 3.48 - "insert into lpit_project (name, node, description, repourl, owner) values (?, ?, ?, ?, ?)" 3.49 + "insert into lpit_project (name, node, ordinal, description, repourl, owner) values (?, ?, ?, ?, ?, ?)" 3.50 ) 3.51 } 3.52 private val stmtUpdateProject by lazy { 3.53 connection.prepareStatement( 3.54 - "update lpit_project set name = ?, node = ?, description = ?, repourl = ?, owner = ? where projectid = ?" 3.55 + "update lpit_project set name = ?, node = ?, ordinal = ?, description = ?, repourl = ?, owner = ? where projectid = ?" 3.56 ) 3.57 } 3.58 private val stmtIssueSummary by lazy {
4.1 --- a/src/main/kotlin/de/uapcore/lightpit/entities/Project.kt Mon Jan 04 15:14:26 2021 +0100 4.2 +++ b/src/main/kotlin/de/uapcore/lightpit/entities/Project.kt Mon Jan 04 15:25:59 2021 +0100 4.3 @@ -28,6 +28,7 @@ 4.4 data class Project(override val id: Int) : Entity { 4.5 var name: String = "" 4.6 var node: String = name 4.7 + var ordinal = 0 4.8 var description: String? = null 4.9 var repoUrl: String? = null 4.10 var owner: User? = null
5.1 --- a/src/main/resources/localization/projects.properties Mon Jan 04 15:14:26 2021 +0100 5.2 +++ b/src/main/resources/localization/projects.properties Mon Jan 04 15:25:59 2021 +0100 5.3 @@ -43,6 +43,7 @@ 5.4 5.5 name=Name 5.6 node=Node 5.7 +ordinal=Ordering 5.8 node.tooltip=Name of the path node that will be used in URL construction. 5.9 description=Description 5.10 repoUrl=Repository
6.1 --- a/src/main/resources/localization/projects_de.properties Mon Jan 04 15:14:26 2021 +0100 6.2 +++ b/src/main/resources/localization/projects_de.properties Mon Jan 04 15:25:59 2021 +0100 6.3 @@ -43,6 +43,7 @@ 6.4 6.5 name=Name 6.6 node=Pfadname 6.7 +ordinal=Sequenznummer 6.8 node.tooltip=Name, der zur Konstruktion der URL genutzt werden soll. 6.9 description=Beschreibung 6.10 repoUrl=Repository
7.1 --- a/src/main/webapp/WEB-INF/jsp/project-form.jsp Mon Jan 04 15:14:26 2021 +0100 7.2 +++ b/src/main/webapp/WEB-INF/jsp/project-form.jsp Mon Jan 04 15:25:59 2021 +0100 7.3 @@ -67,6 +67,12 @@ 7.4 </select> 7.5 </td> 7.6 </tr> 7.7 + <tr title="<fmt:message key="tooltip.ordinal" />"> 7.8 + <th><fmt:message key="ordinal"/></th> 7.9 + <td> 7.10 + <input name="ordinal" type="number" min="0" value="${project.ordinal}"/> 7.11 + </td> 7.12 + </tr> 7.13 </tbody> 7.14 <tfoot> 7.15 <tr>