Browse Source

Birth Certificate family in form

Andrew Grant 6 months ago
parent
commit
bddec8145e

+ 3 - 11
src/main/java/scot/carricksoftware/grants/bootstrap/DataLoadCertificates.java

@@ -12,7 +12,6 @@ import org.springframework.stereotype.Component;
 import scot.carricksoftware.grants.commands.certificates.birthcertificates.BirthCertificateCommand;
 import scot.carricksoftware.grants.commands.certificates.birthcertificates.BirthCertificateCommandImpl;
 import scot.carricksoftware.grants.domains.certificates.DeathCertificate;
-import scot.carricksoftware.grants.domains.people.Person;
 import scot.carricksoftware.grants.domains.places.Organisation;
 import scot.carricksoftware.grants.enums.general.Sex;
 import scot.carricksoftware.grants.enums.certificates.CertificateType;
@@ -53,9 +52,7 @@ public class DataLoadCertificates {
 
     private void loadBirthCertificates() {
         BirthCertificateCommand birthCertificateCommand = new BirthCertificateCommandImpl();
-        Person newBorn = new Person();
-        newBorn.setFirstName("new born");
-        birthCertificateCommand.setNewBorn(newBorn);
+        birthCertificateCommand.setNewBorn(personService.findById(3L));
         birthCertificateCommand.setCertificateDate("25/01/1953");
         birthCertificateCommand.setCertificateNumber("999");
         birthCertificateCommand.setCertificateType(CertificateType.EXTRACT);
@@ -70,14 +67,9 @@ public class DataLoadCertificates {
         birthCertificateCommand.setWhereBorn("where born");
         birthCertificateCommand.setDateAndPlaceOfMarriage("date and place of marriage");
         birthCertificateCommand.setFatherRank("fatherRank");
-
-        Person father = new Person();
-        father.setFirstName("father");
-        birthCertificateCommand.setFather(father);
+        birthCertificateCommand.setFather(personService.findById(1L));
         birthCertificateCommand.setUntrackedFather("untrackedFather");
-        Person mother = new Person();
-        mother.setFirstName("mother");
-        birthCertificateCommand.setMother(mother);
+        birthCertificateCommand.setMother(personService.findById(2L));
 
         birthCertificateService.saveBirthCertificateCommand(birthCertificateCommand);
     }

+ 9 - 0
src/main/java/scot/carricksoftware/grants/bootstrap/DataLoadPeople.java

@@ -29,6 +29,7 @@ public class DataLoadPeople {
         logger.debug("DataLoadPlaces::load");
         loadDad();
         loadMum();
+        loadMe();
     }
 
     private void loadDad() {
@@ -48,7 +49,15 @@ public class DataLoadPeople {
         mum.setCertifiedYearOfBirth("1910");
         mum.setRecordedYearOfBirth("1915");
         personService.save(mum);
+    }
 
+    private void loadMe() {
+        final Person mum = new Person();
+        mum.setFirstName("Andrew Peter");
+        mum.setLastName("Grant");
+        mum.setCertifiedYearOfBirth("1953");
+        mum.setRecordedYearOfBirth("1953");
+        personService.save(mum);
     }
 
 

+ 35 - 1
src/main/resources/templates/certificates/birthCertificate/form.html

@@ -222,8 +222,42 @@
                     </div>
                 </div>
             </td>
-
             </tr>
+            <tr>
+                <td style="text-align: right; background-color: #D6EEEE;">
+                    <label for="father">Father&nbsp;</label>
+                </td>
+                <td style="text-align: left;">
+                    <select id="father" name="father" th:field="*{father}">
+                        <option th:value="${''}" th:text="${''}"></option>
+                        <option th:each="person : ${people}"
+                                th:value="${person.id}" th:text="${person.toString()}"></option>
+                    </select>
+                    <div th:if="${#fields.hasErrors('father')}">
+                        <ul class="text-danger">
+                            <li th:each="err : ${#fields.errors('father')}" th:text="${err}"/>
+                        </ul>
+                    </div>
+                </td>
+            </tr>
+            <tr>
+                <td style="text-align: right;  background-color: #D6EEEE;">
+                    <label for="untrackedFather">Father (untracked)&nbsp;</label>
+                </td>
+                <td style="text-align: left; ">
+                    <div>
+                        <input class="number" id="untrackedFather"
+                               th:field="*{untrackedFather}" type="text">
+                        <div th:if="${#fields.hasErrors('untrackedFather')}">
+                            <ul class="text-danger">
+                                <li th:each="err : ${#fields.errors('untrackedFather')}" th:text="${err}"/>
+                            </ul>
+                        </div>
+                    </div>
+                </td>
+            </tr>
+
+
         </table>