浏览代码

Death Certificate Form - start

Andrew Grant 4 月之前
父节点
当前提交
6aad9b033f

+ 21 - 1
src/main/java/scot/carricksoftware/grants/controllers/certificates/deathcertificates/DeathCertificateFormControllerImpl.java

@@ -25,6 +25,8 @@ import scot.carricksoftware.grants.converters.certificates.deathcertificates.Dea
 import scot.carricksoftware.grants.converters.certificates.deathcertificates.DeathCertificateConverterImpl;
 import scot.carricksoftware.grants.services.certificates.deathcertificates.DeathCertificateService;
 import scot.carricksoftware.grants.services.people.PersonService;
+import scot.carricksoftware.grants.services.places.organisations.OrganisationService;
+import scot.carricksoftware.grants.services.places.places.PlaceService;
 import scot.carricksoftware.grants.validators.certificates.deathcertificate.DeathCertificateCommandValidator;
 
 @SuppressWarnings("LoggingSimilarMessage")
@@ -38,12 +40,17 @@ public class DeathCertificateFormControllerImpl implements DeathCertificateFormC
     private final DeathCertificateConverterImpl deathCertificateConverter;
     private final DeathCertificateCommandValidator deathCertificateCommandValidator;
     private final PersonService personService;
+    private final PlaceService placeService;
+    private final OrganisationService organisationService;
 
 
     public DeathCertificateFormControllerImpl(DeathCertificateService deathCertificateService,
                                               DeathCertificateCommandConverterImpl deathCertificateCommandConverter,
                                               DeathCertificateConverterImpl deathCertificateConverter,
-                                              DeathCertificateCommandValidator deathCertificateCommandValidator, PersonService personService) {
+                                              DeathCertificateCommandValidator deathCertificateCommandValidator,
+                                              PersonService personService,
+                                              PlaceService placeService,
+                                              OrganisationService organisationService) {
         this.deathCertificateService = deathCertificateService;
         this.deathCertificateCommandConverter = deathCertificateCommandConverter;
 
@@ -51,6 +58,9 @@ public class DeathCertificateFormControllerImpl implements DeathCertificateFormC
         this.deathCertificateConverter = deathCertificateConverter;
         this.deathCertificateCommandValidator = deathCertificateCommandValidator;
         this.personService = personService;
+        this.placeService = placeService;
+
+        this.organisationService = organisationService;
     }
 
     @SuppressWarnings("SameReturnValue")
@@ -60,6 +70,8 @@ public class DeathCertificateFormControllerImpl implements DeathCertificateFormC
         logger.debug("DeathCertificateFormControllerImpl::getNewDeathCertificate");
         model.addAttribute(AttributeConstants.DEATH_CERTIFICATE_COMMAND, new DeathCertificateCommandImpl());
         model.addAttribute(AttributeConstants.PEOPLE, personService.findAll());
+        model.addAttribute(AttributeConstants.PLACES, placeService.findAll());
+        model.addAttribute(AttributeConstants.ORGANISATIONS, organisationService.findAll());
         return ViewConstants.DEATH_CERTIFICATE_FORM;
     }
 
@@ -70,6 +82,8 @@ public class DeathCertificateFormControllerImpl implements DeathCertificateFormC
         logger.debug("DeathCertificateFormControllerImpl::deathCertificateEdit");
         model.addAttribute(AttributeConstants.DEATH_CERTIFICATE_COMMAND, deathCertificateService.findById(Long.valueOf(id)));
         model.addAttribute(AttributeConstants.PEOPLE, personService.findAll());
+        model.addAttribute(AttributeConstants.PLACES, placeService.findAll());
+        model.addAttribute(AttributeConstants.ORGANISATIONS, organisationService.findAll());
         return ViewConstants.DEATH_CERTIFICATE_FORM;
     }
 
@@ -85,12 +99,16 @@ public class DeathCertificateFormControllerImpl implements DeathCertificateFormC
         if (bindingResult.hasErrors()) {
             bindingResult.getAllErrors().forEach(error -> logger.debug(error.getDefaultMessage()));
             model.addAttribute(AttributeConstants.PEOPLE, personService.findAll());
+            model.addAttribute(AttributeConstants.PLACES, placeService.findAll());
+            model.addAttribute(AttributeConstants.ORGANISATIONS, organisationService.findAll());
             return ViewConstants.DEATH_CERTIFICATE_FORM;
         }
 
         DeathCertificateCommand savedCommand = deathCertificateService.saveDeathCertificateCommand(deathCertificateCommand);
         model.addAttribute(AttributeConstants.DEATH_CERTIFICATE_COMMAND, savedCommand);
         model.addAttribute(AttributeConstants.PEOPLE, personService.findAll());
+        model.addAttribute(AttributeConstants.PLACES, placeService.findAll());
+        model.addAttribute(AttributeConstants.ORGANISATIONS, organisationService.findAll());
         return MappingConstants.REDIRECT + CertificateMappingConstants.DEATH_CERTIFICATE_SHOW.replace("{id}", "" + savedCommand.getId());
     }
 
@@ -103,6 +121,8 @@ public class DeathCertificateFormControllerImpl implements DeathCertificateFormC
         DeathCertificateCommand savedCommand = deathCertificateConverter.convert(deathCertificateService.findById(Long.valueOf(id)));
         model.addAttribute(AttributeConstants.DEATH_CERTIFICATE_COMMAND, savedCommand);
         model.addAttribute(AttributeConstants.PEOPLE, personService.findAll());
+        model.addAttribute(AttributeConstants.PLACES, placeService.findAll());
+        model.addAttribute(AttributeConstants.ORGANISATIONS, organisationService.findAll());
         return ViewConstants.DEATH_CERTIFICATE_FORM;
     }
 

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

@@ -126,38 +126,7 @@
                     </div>
                 </td>
             </tr>
-            <tr>
-                <td style="text-align: right;">
-                    <label for="volume">Volume :&nbsp;</label>
-                </td>
-                <td style="text-align: left;">
-                    <div>
-                        <input class="volume" id="volume"
-                               th:field="*{volume}" type="text">
-                        <div th:if="${#fields.hasErrors('volume')}">
-                            <ul class="text-danger">
-                                <li th:each="err : ${#fields.errors('volume')}" th:text="${err}"/>
-                            </ul>
-                        </div>
-                    </div>
-                </td>
-            </tr>
-            <tr style="border-bottom: 5px solid #ccc;">
-                <td style="text-align: right;">
-                    <label for="number">Number :&nbsp;</label>
-                </td>
-                <td style="text-align: left;">
-                    <div>
-                        <input class="number" id="number"
-                               th:field="*{number}" type="text">
-                        <div th:if="${#fields.hasErrors('number')}">
-                            <ul class="text-danger">
-                                <li th:each="err : ${#fields.errors('number')}" th:text="${err}"/>
-                            </ul>
-                        </div>
-                    </div>
-                </td>
-            </tr>
+
             <tr>
                 <td style="text-align: right;">
                     <label for="newBorn">NewBorn :&nbsp;</label>

+ 106 - 2
src/main/resources/templates/certificates/deathCertificate/form.html

@@ -30,11 +30,10 @@
 
         <table style="width:100%;">
             <tr>
-                <td>
                 <td style="text-align: right;">
                     <label for="id"><span style="color: rgb(255,0,0);">*</span>Database Id :&nbsp;</label>
                 </td>
-                <td>
+                <td style="text-align: left;">
                     <input class="form-control" id="id"
                            th:field="*{id}" type="text" readonly>
                 </td>
@@ -52,6 +51,111 @@
                         </ul>
                     </div>
                 </td>
+            </tr> <tr>
+            <td style="text-align: right;">
+                <label for="certificateSource">Certificate Source&nbsp;:&nbsp;</label>
+            </td>
+            <td style="text-align: left;">
+                <div>
+                    <select id="certificateSource" name="certificateSource" th:field="*{certificateSource}">
+                        <option th:value="${''}" th:text="${''}"></option>
+                        <!--/*@thymesVar id="organisations" type="scot.carricksoftware.grants.domains.places.Organisation"*/-->
+                        <option th:each="organisation : ${organisations}"
+                                th:value="${organisation.id}" th:text="${organisation.toString()}"></option>
+                    </select>
+                    <div th:if="${#fields.hasErrors('certificateSource')}">
+                        <ul class="text-danger">
+                            <li th:each="err : ${#fields.errors('certificateSource')}" th:text="${err}"/>
+                        </ul>
+                    </div>
+                </div>
+            </td>
+        </tr>
+            <tr>
+                <td style="text-align: right;">
+                    <label for="certificateDate">Certificate Date (dd/mm/yyyy) :&nbsp;</label>
+                </td>
+                <td style="text-align: left;">
+                    <input class="form-control" id="certificateDate"
+                           th:field="*{certificateDate}" type="text">
+                    <div th:if="${#fields.hasErrors('certificateDate')}">
+                        <ul class="text-danger">
+                            <li th:each="err : ${#fields.errors('certificateDate')}" th:text="${err}"/>
+                        </ul>
+                    </div>
+                </td>
+            </tr>
+            <tr style="border-bottom: 5px solid #ccc;">
+                <td style="text-align: right;">
+                    <label for="certificateType">Certificate Type :&nbsp;</label>
+                </td>
+                <td style="text-align: left;">
+                    <div>
+                        <select id="certificateType" style="width: 200px;" name="certificateType"
+                                th:field="*{certificateType}">
+                            <option th:value="${''}" th:text="${''}"></option>
+                            <option th:each="value : ${T(scot.carricksoftware.grants.enums.certificates.CertificateType).values()}"
+                                    th:value="${value}" th:text="${value.label}"></option>
+                        </select>
+                    </div>
+                    <div th:if="${#fields.hasErrors('certificateType')}">
+                        <ul class="text-danger">
+                            <li th:each="err : ${#fields.errors('certificateType')}" th:text="${err}"/>
+                        </ul>
+                    </div>
+            </tr>
+            <tr>
+                <td style="text-align: right;">
+                    <label for="registrationAuthority">Registration Authority :&nbsp;</label>
+                </td>
+                <td style="text-align: left;">
+                    <div>
+                        <select id="registrationAuthority" style="width: 200px;" name="registrationAuthority"
+                                th:field="*{registrationAuthority}">
+                            <option th:value="${''}" th:text="${''}"></option>
+                            <!--/*@thymesVar id="organisations" type="scot.carricksoftware.grants.domains.places.Organisation"*/-->
+                            <option th:each="organisation : ${organisations}"
+                                    th:value="${organisation.id}" th:text="${organisation.name}"></option>
+                        </select>
+                    </div>
+                    <div th:if="${#fields.hasErrors('registrationAuthority')}">
+                        <ul class="text-danger">
+                            <li th:each="err : ${#fields.errors('registrationAuthority')}" th:text="${err}"/>
+                        </ul>
+                    </div>
+                </td>
+            </tr>
+            <tr>
+                <td style="text-align: right;">
+                    <label for="volume">Volume :&nbsp;</label>
+                </td>
+                <td style="text-align: left;">
+                    <div>
+                        <input class="volume" id="volume"
+                               th:field="*{volume}" type="text">
+                        <div th:if="${#fields.hasErrors('volume')}">
+                            <ul class="text-danger">
+                                <li th:each="err : ${#fields.errors('volume')}" th:text="${err}"/>
+                            </ul>
+                        </div>
+                    </div>
+                </td>
+            </tr>
+            <tr style="border-bottom: 5px solid #ccc;">
+                <td style="text-align: right;">
+                    <label for="number">Number :&nbsp;</label>
+                </td>
+                <td style="text-align: left;">
+                    <div>
+                        <input class="number" id="number"
+                               th:field="*{number}" type="text">
+                        <div th:if="${#fields.hasErrors('number')}">
+                            <ul class="text-danger">
+                                <li th:each="err : ${#fields.errors('number')}" th:text="${err}"/>
+                            </ul>
+                        </div>
+                    </div>
+                </td>
             </tr>
         </table>
             <button type="submit" class="btn btn-primary">Commit</button>