Bläddra i källkod

Census Boundary Type added to census form

Andrew Grant 7 månader sedan
förälder
incheckning
2ffb02da39

+ 2 - 1
docs/enums.txt

@@ -1,6 +1,6 @@
 0:Switch to dev
 1:Create Enum
-2: Domain
+2: Domain (enumerated as a string)
 3: Domain getter and setter
 4 :Random Value
 5: Test getter and setter in Domain Enums Test
@@ -10,6 +10,7 @@
 10: Converter Test
 11: Bootstrap
 12: Bootstrap Test
+12a: Check using the h2 console
 13: Modify the form
 14: Switch to uat
 15: Generate changelog (ctrl-shift-A) as sql

+ 2 - 0
src/main/java/scot/carricksoftware/grants/bootstrap/DataLoadCensus.java

@@ -14,6 +14,7 @@ import scot.carricksoftware.grants.commands.census.CensusCommandImpl;
 import scot.carricksoftware.grants.commands.census.CensusEntryCommand;
 import scot.carricksoftware.grants.commands.census.CensusEntryCommandImpl;
 import scot.carricksoftware.grants.domains.places.Place;
+import scot.carricksoftware.grants.enums.census.CensusBoundaryType;
 import scot.carricksoftware.grants.enums.censusentry.CensusEntryCondition;
 import scot.carricksoftware.grants.enums.censusentry.CensusEntryGaelic;
 import scot.carricksoftware.grants.enums.censusentry.CensusEntryRelationship;
@@ -62,6 +63,7 @@ public class DataLoadCensus {
         Place place = placeService.findById(1L);
         censusCommand.setDate(LocalDate.now());
         censusCommand.setPlace(place);
+        censusCommand.setBoundaryType(CensusBoundaryType.ISLAND);
         censusService.saveCensusCommand(censusCommand);
     }
 

+ 1 - 0
src/main/java/scot/carricksoftware/grants/domains/census/Census.java

@@ -26,6 +26,7 @@ public class Census extends BaseEntity {
     @JoinColumn(name = "census_place_id")
     private Place place;
 
+    @Enumerated(EnumType.STRING)
     private CensusBoundaryType boundaryType;
 
 

+ 10 - 0
src/main/resources/templates/census/form.html

@@ -55,6 +55,16 @@ rounded-3 text-center p-4">
                     </ul>
                 </div>
             </div>
+            <div class="col-md-3">
+                <label for="boundaryType">Boundary Type</label>
+                <div>
+                    <select id="boundaryType" style="width: 200px;" name="boundaryType" th:field="*{boundaryType}">
+                        <option th:value="${''}" th:text="${''}"></option>
+                        <option th:each="value : ${T(scot.carricksoftware.grants.enums.census.CensusBoundaryType).values()}"
+                                th:value="${value}" th:text="${value}"></option>
+                    </select>
+                </div>
+            </div>
         </div>
         <button type="submit" class="btn btn-primary">Commit</button>
         <a class="btn btn-secondary" th:href="@{/censuses}" th:text="${'List all'}">List all</a>

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

@@ -32,7 +32,7 @@
 
             <tr th:each="census   : ${censuses}">
                 <td th:text="${census.id}">123</td>
-                <td th:text="${census.place.toString()}">123</td>
+                <td th:text="${census.place}">123</td>
                 <td th:text="${#temporals.format(census.date, 'dd-MMM-yyyy')}"></td>
                 <td><span>
                         <a th:action="delete" class="btn btn-danger btn-sm" href=""

+ 2 - 0
src/test/java/scot/carricksoftware/grants/bootstrap/DataLoadCensusTest.java

@@ -11,6 +11,7 @@ import scot.carricksoftware.grants.commands.census.CensusEntryCommand;
 import scot.carricksoftware.grants.domains.census.Census;
 import scot.carricksoftware.grants.domains.people.Person;
 import scot.carricksoftware.grants.domains.places.Place;
+import scot.carricksoftware.grants.enums.census.CensusBoundaryType;
 import scot.carricksoftware.grants.enums.censusentry.CensusEntryCondition;
 import scot.carricksoftware.grants.enums.censusentry.CensusEntryGaelic;
 import scot.carricksoftware.grants.enums.censusentry.CensusEntryRelationship;
@@ -67,6 +68,7 @@ public class DataLoadCensusTest {
 
         assertEquals(captor.getValue().getDate(), LocalDate.now());
         assertEquals(captor.getValue().getPlace(), place);
+        assertEquals(CensusBoundaryType.ISLAND, captor.getValue().getBoundaryType());
     }
 
     @Test