浏览代码

Census Entries Mapping

Andrew Grant 7 月之前
父节点
当前提交
e89a33f346

+ 2 - 0
src/main/java/scot/carricksoftware/grants/constants/CensusMappingConstants.java

@@ -77,4 +77,6 @@ public class CensusMappingConstants {
     public static final String CENSUS_SELECTED_ENTRIES_DELETE = "/censusSelectedEntry/{id}/delete";
     @SuppressWarnings({"unused"})
     public static final String CENSUS_SELECTED_ENTRIES_EDIT = "censusSelectedEntry/{id}/edit";
+
+    public static final String CENSUS_SELECTED_ENTRIES_ENTRIES = "/censusSelectedEntry/{id}/entries";
 }

+ 2 - 0
src/main/java/scot/carricksoftware/grants/constants/ViewConstants.java

@@ -35,6 +35,8 @@ public class ViewConstants {
     public static final String CENSUS_ENTRY_LIST = "censusentry/list";
     public static final String CENSUS_ENTRY_FORM = "censusentry/form";
 
+    public static final String CENSUS_ENTRIES_LIST = "censusEntries/list";
+
     @SuppressWarnings("unused")
     public static final String BIRTH_CERTIFICATE_LIST = "certificates/birthCertificate/list";
     public static final String BIRTH_CERTIFICATE_FORM = "certificates/birthCertificate/form";

+ 4 - 0
src/main/java/scot/carricksoftware/grants/controllers/census/census/CensusEntriesListController.java

@@ -5,6 +5,7 @@
 
 package scot.carricksoftware.grants.controllers.census.census;
 
+import jakarta.validation.Valid;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
 import org.springframework.web.bind.annotation.PathVariable;
@@ -25,5 +26,8 @@ public interface CensusEntriesListController {
 
     String censusDelete(@PathVariable String id);
 
+    @SuppressWarnings("SameReturnValue")
+    String censusEntriesEntries(@Valid @PathVariable String id, Model model);
+
     int getPageNumber();
 }

+ 19 - 8
src/main/java/scot/carricksoftware/grants/controllers/census/census/CensusEntriesListControllerImpl.java

@@ -5,6 +5,7 @@
 
 package scot.carricksoftware.grants.controllers.census.census;
 
+import jakarta.validation.Valid;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.springframework.stereotype.Controller;
@@ -18,7 +19,7 @@ import scot.carricksoftware.grants.services.census.census.CensusService;
 import static java.lang.Integer.max;
 
 @Controller
-public class CensusEntriesListControllerImpl implements CensusListController {
+public class CensusEntriesListControllerImpl implements CensusEntriesListController {
 
     private static final Logger logger = LogManager.getLogger(CensusEntriesListControllerImpl.class);
 
@@ -41,6 +42,8 @@ public class CensusEntriesListControllerImpl implements CensusListController {
         return sendAttributesAndReturn(model);
     }
 
+
+
     @SuppressWarnings("SameReturnValue")
     private String sendAttributesAndReturn(Model model) {
         model.addAttribute(AttributeConstants.CENSUSES, censusService.getPagedCensuses(currentPage));
@@ -52,16 +55,17 @@ public class CensusEntriesListControllerImpl implements CensusListController {
     @GetMapping(CensusMappingConstants.CENSUS_SELECTED_ENTRIES_NEXT)
     @Override
     public final String getNextPage(final Model model) {
-        logger.debug("CensusListControllerImpl::getNextPage");
+        logger.debug("CensusEntriesListControllerImpl::getNextPage");
         currentPage++;
         return sendAttributesAndReturn(model);
     }
 
+
     @SuppressWarnings("SameReturnValue")
     @GetMapping(CensusMappingConstants.CENSUS_SELECTED_ENTRIES_PREVIOUS)
     @Override
     public final String getPreviousPage(final Model model) {
-        logger.debug("CensusListControllerImpl::getPreviousPage");
+        logger.debug("CensusEntriesListControllerImpl::getPreviousPage");
         currentPage = max(0, currentPage - 1);
         return sendAttributesAndReturn(model);
     }
@@ -69,31 +73,38 @@ public class CensusEntriesListControllerImpl implements CensusListController {
     @SuppressWarnings("SameReturnValue")
     @GetMapping(CensusMappingConstants.CENSUS_SELECTED_ENTRIES_REWIND)
     public final String getFirstPage(final Model model) {
-        logger.debug("CensusListControllerImpl::getFirstPage");
+        logger.debug("CensusEntriesListControllerImpl::getFirstPage");
         currentPage = 0;
         return sendAttributesAndReturn(model);
     }
 
     @SuppressWarnings("SameReturnValue")
     @GetMapping(CensusMappingConstants.CENSUS_SELECTED_ENTRIES_FF)
-    @Override
     public final String getLastPage(final Model model) {
-        logger.debug("CensusListControllerImpl::getLastPage");
+        logger.debug("CensusEntriesListControllerImpl::getLastPage");
         long censusCount = censusService.count();
         currentPage = (int) (censusCount / ApplicationConstants.DEFAULT_PAGE_SIZE);
         return sendAttributesAndReturn(model);
     }
 
-
     @SuppressWarnings("SameReturnValue")
     @GetMapping(CensusMappingConstants.CENSUS_SELECTED_ENTRIES_DELETE)
     @Override
     public final String censusDelete(@PathVariable final String id) {
-        logger.debug("CensusListControllerImpl::censusDelete");
+        logger.debug("CensusEntriesListControllerImpl::censusDelete");
         censusService.deleteById(Long.valueOf(id));
         return MappingConstants.REDIRECT + CensusMappingConstants.CENSUS_SELECTED_ENTRIES_LIST;
     }
 
+    @SuppressWarnings("SameReturnValue")
+    @GetMapping(CensusMappingConstants.CENSUS_SELECTED_ENTRIES_ENTRIES)
+    @Override
+    public String censusEntriesEntries(@Valid @PathVariable final String id, Model model) {
+        logger.debug("CensusEntriesListControllerImpl::censusEntriesEntries");
+        return ViewConstants.CENSUS_ENTRIES_LIST;
+    }
+
+
     @Override
     public int getPageNumber() {
         return currentPage;

+ 1 - 1
src/main/resources/templates/census/list.html

@@ -42,7 +42,7 @@
                        th:href="'census/' + ${census.id} + '/edit'"
                        th:text="Edit"></a>
                      <a th:action="entries" class="btn btn-info btn-sm"
-                        th:href="'census/' + ${census.id} + '/entries'"
+                        th:href="'censusSelectedEntry/' + ${census.id} + '/entries'"
                         th:text="Entries"></a>
                     </span></td>
             </tr>

+ 76 - 0
src/main/resources/templates/censusEntries/list.html

@@ -0,0 +1,76 @@
+<!DOCTYPE html>
+
+<!--
+  ~ Copyright (c) 2025 Andrew Grant of Carrick Software .
+  ~ All rights reserved.
+  -->
+<html lang="en" xmlns:th="http://www.thymeleaf.org">
+<head>
+    <meta charset="UTF-8"/>
+    <title>People </title>
+    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"
+          integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
+    <title>Grants - Census Entry List</title>
+</head>
+<body>
+<div th:insert="~{fragments/layout::banner}"></div>
+
+
+<div class="container text-center">
+    <!--/*@thymesVar id="censusEntry" type="scot.carricksoftware.grants.domains.census.CensusEntry"*/-->
+    <!--/*@thymesVar id="person" type="scot.carricksoftware.grants.domains.people.Person"*/-->
+    <!--/*@thymesVar id="census" type="scot.carricksoftware.grants.domains.census.Census"*/-->
+
+    <div class="container border border-info
+                    rounded-3 text-center p-4">
+        <h3>Census Entries for </h3>
+        <table class="table table-striped table-bordered">
+            <thead class="table-dark">
+            <tr>
+                <th>ID</th
+                ><th>Person</th>
+                <th>Untracked Person</th>
+                <th>Census</th>
+                <th></th>
+            </tr>
+            </thead>
+
+            <tr th:each="entry   : ${censusEntries}">
+                <td th:text="${entry.id}">123</td>
+                <td th:text="${entry.person?.toString()}">123</td>
+                <td th:text="${entry.name}">123</td>
+                <td th:text="${entry.toString()}">123</td>
+
+                <td><span>
+                        <a th:action="delete" class="btn btn-danger btn-sm" href=""
+                           th:href="'censusEntry/' + ${entry.id} + '/delete'"
+                           th:text="Delete"></a>
+                    <a th:action="edit" class="btn btn-warning btn-sm"
+                       th:href="'censusEntry/' + ${entry.id} + '/edit'"
+                       th:text="Edit"></a>
+                    </span></td>
+            </tr>
+            <tfoot>
+            <tr>
+                <td colspan="4"><span>
+                        <a th:action="rewind" class="btn btn-secondary btn-sm" th:href="@{/censusEntries/rewind}"
+                           th:text="'<<'"></a>
+                         <a th:action="back" class="btn btn-secondary btn-sm"
+                            th:href="@{/censusEntries/prev}" th:text="'<'"></a>
+                         <a th:action="new" class="btn btn-primary btn-sm" th:href="@{censusEntry/new}"
+                            th:text="'New Entry'"></a>
+                         <a th:action="home" class="btn btn-success btn-sm"
+                            th:href="@{/}" th:text="'Home'"></a>
+                         <a th:action="forward" class="btn btn-secondary btn-sm"
+                            th:href="@{/censusEntries/next}" th:text="'>'"></a>
+                         <a th:action="end" class="btn btn-secondary btn-sm" th:href="@{/censusEntries/ff}"
+                            th:text="'>>'"></a>
+                        </span></td>
+            </tr>
+            </tfoot>
+        </table>
+    </div>
+</div>
+</body>
+</html>
+