apg 3 недель назад
Родитель
Сommit
da0af158b2

+ 1 - 0
src/main/java/scot/carricksoftware/grants/bootstrap/DataLoadMarriageCertificates.java

@@ -20,6 +20,7 @@ import scot.carricksoftware.grants.services.people.PersonService;
 public class DataLoadMarriageCertificates {
 
     private static final Logger logger = LogManager.getLogger(DataLoadMarriageCertificates.class);
+
     private final PersonService personService;
     private final MarriageCertificateService marriageCertificateService;
 

+ 5 - 2
src/main/java/scot/carricksoftware/grants/bootstrap/DataLoadTexts.java

@@ -31,8 +31,11 @@ public class DataLoadTexts {
     private final AppendixTextService appendixTextService;
 
     public DataLoadTexts(DocumentTextService documentTextService,
-                         PersonTextService personTextService, PlaceTextService placeTextService,
-                         PersonService personService, PlaceService placeService, AppendixTextService appendixTextService) {
+                         PersonTextService personTextService,
+                         PlaceTextService placeTextService,
+                         PersonService personService,
+                         PlaceService placeService,
+                         AppendixTextService appendixTextService) {
         this.documentTextService = documentTextService;
         this.personTextService = personTextService;
         this.placeTextService = placeTextService;

+ 3 - 0
src/main/java/scot/carricksoftware/grants/constants/ImageAttributeConstants.java

@@ -26,6 +26,9 @@ public class ImageAttributeConstants {
     public static final String APPENDIX_IMAGES = "appendixImages";
     public static final String APPENDIX_IMAGE_COMMAND = "appendixImageCommand";
 
+    public static final String DOCUMENT_IMAGES = "documentImages";
+    public static final String DOCUMENT_IMAGE_COMMAND = "documentImageCommand";
+
 
 
 

+ 15 - 0
src/main/java/scot/carricksoftware/grants/constants/ImageMappingConstants.java

@@ -59,6 +59,19 @@ public class ImageMappingConstants {
     public static final String APPENDIX_IMAGE_SHOW = "/appendixImage/{id}/show";
     public static final String APPENDIX_IMAGE_DELETE = "/appendixImage/{id}/delete";
     public static final String APPENDIX_IMAGE_EDIT = "appendixImage/{id}/edit";
+
+
+    public static final String DOCUMENT_IMAGE_LIST = "/documentImages";
+    public static final String DOCUMENT_IMAGE_NEXT = "/documentImages/next";
+    public static final String DOCUMENT_IMAGE_PREVIOUS = "/documentImages/prev";
+    public static final String DOCUMENT_IMAGE_REWIND = "/documentImages/rewind";
+    public static final String DOCUMENT_IMAGE_FF = "/documentImages/ff";
+    public static final String DOCUMENT_IMAGE_NEW = "/documentImage/new";
+    public static final String DOCUMENT_IMAGE = "/documentImage";
+    public static final String DOCUMENT_IMAGE_SHOW = "/documentImage/{id}/show";
+    public static final String DOCUMENT_IMAGE_DELETE = "/documentImage/{id}/delete";
+    public static final String DOCUMENT_IMAGE_EDIT = "documentImage/{id}/edit";
+
 }
 
 
@@ -66,3 +79,5 @@ public class ImageMappingConstants {
 
 
 
+
+

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

@@ -64,6 +64,9 @@ public class ViewConstants {
     public static final String APPENDIX_IMAGE_LIST = "images/appendixImage/list";
     public static final String APPENDIX_IMAGE_FORM = "images/appendixImage/form";
 
+    public static final String DOCUMENT_IMAGE_LIST = "images/documentImage/list";
+    public static final String DOCUMENT_IMAGE_FORM = "images/documentImage/form";
+
     public static final String DOCUMENT_TEXT_LIST = "text/documentText/list";
     public static final String DOCUMENT_TEXT_FORM = "text/documentText/form";
 

+ 29 - 0
src/main/java/scot/carricksoftware/grants/controllers/images/documentImages/DocumentImageListController.java

@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) Andrew Grant of Carrick Software 29/03/2025, 13:08. All rights reserved.
+ *
+ */
+
+package scot.carricksoftware.grants.controllers.images.documentImages;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.PathVariable;
+
+@SuppressWarnings("unused")
+@Controller
+public interface DocumentImageListController {
+
+    String getListPage(final Model model);
+
+    String getNextPage(final Model model);
+
+    String getPreviousPage(final Model model);
+
+    String getFirstPage(final Model model);
+
+    String getLastPage(final Model model);
+
+    String documentImageDelete(@PathVariable String id);
+
+    int getPageNumber();
+}

+ 104 - 0
src/main/java/scot/carricksoftware/grants/controllers/images/documentImages/DocumentImageListControllerImpl.java

@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) Andrew Grant of Carrick Software 29/03/2025, 13:08. All rights reserved.
+ *
+ */
+
+package scot.carricksoftware.grants.controllers.images.documentImages;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import scot.carricksoftware.grants.constants.*;
+import scot.carricksoftware.grants.controllers.ControllerHelper;
+import scot.carricksoftware.grants.services.images.documentimage.DocumentImageService;
+
+import static java.lang.Integer.max;
+
+@Controller
+public class DocumentImageListControllerImpl implements DocumentImageListController {
+
+    private static final Logger logger = LogManager.getLogger(DocumentImageListControllerImpl.class);
+
+
+    private int currentPage = 0;
+    private final ControllerHelper controllerHelper;
+    private final DocumentImageService documentImageService;
+
+    public DocumentImageListControllerImpl(ControllerHelper controllerHelper,
+                                           DocumentImageService documentImageService) {
+        this.controllerHelper = controllerHelper;
+        this.documentImageService = documentImageService;
+    }
+
+    @SuppressWarnings("SameReturnValue")
+    @GetMapping(ImageMappingConstants.DOCUMENT_IMAGE_LIST)
+    @Override
+    public final String getListPage(final Model model) {
+        logger.debug("PersonListControllerImpl::getPersonImagePage");
+        currentPage = 0;
+        return sendAttributesAndReturn(model);
+    }
+
+    @SuppressWarnings("SameReturnValue")
+    private String sendAttributesAndReturn(Model model) {
+        model.addAttribute(ImageAttributeConstants.DOCUMENT_IMAGES, documentImageService.getPagedDocumentImages(currentPage));
+        controllerHelper.addAttributes(model);
+        return ViewConstants.DOCUMENT_IMAGE_LIST;
+    }
+
+    @SuppressWarnings("SameReturnValue")
+    @GetMapping(ImageMappingConstants.DOCUMENT_IMAGE_NEXT)
+    @Override
+    public final String getNextPage(final Model model) {
+        logger.debug("DocumentImageListControllerImpl::getNextPage");
+        currentPage++;
+        return sendAttributesAndReturn(model);
+    }
+
+    @SuppressWarnings("SameReturnValue")
+    @GetMapping(ImageMappingConstants.DOCUMENT_IMAGE_PREVIOUS)
+    @Override
+    public final String getPreviousPage(final Model model) {
+        logger.debug("DocumentImageListControllerImpl::getPreviousPage");
+        currentPage = max(0, currentPage - 1);
+        return sendAttributesAndReturn(model);
+    }
+
+    @SuppressWarnings("SameReturnValue")
+    @GetMapping(ImageMappingConstants.DOCUMENT_IMAGE_REWIND)
+    public final String getFirstPage(final Model model) {
+        logger.debug("DocumentImageListControllerImpl::getFirstPage");
+        currentPage = 0;
+        return sendAttributesAndReturn(model);
+    }
+
+    @SuppressWarnings("SameReturnValue")
+    @GetMapping(ImageMappingConstants.DOCUMENT_IMAGE_FF)
+    @Override
+    public final String getLastPage(final Model model) {
+        logger.debug("DocumentImageListControllerImpl::getLastPage");
+        long personImageCount = documentImageService.count();
+        currentPage = (int) (personImageCount / ApplicationConstants.DEFAULT_PAGE_SIZE);
+        return sendAttributesAndReturn(model);
+    }
+
+
+    @SuppressWarnings("SameReturnValue")
+    @GetMapping(ImageMappingConstants.DOCUMENT_IMAGE_DELETE)
+    @Override
+    public final String documentImageDelete(@PathVariable final String id) {
+        logger.debug("DocumentImageListControllerImpl::personImageDelete");
+        documentImageService.deleteById(Long.valueOf(id));
+        return MappingConstants.REDIRECT + ImageMappingConstants.DOCUMENT_IMAGE_LIST;
+    }
+
+    @Override
+    public int getPageNumber() {
+        return currentPage;
+    }
+
+
+}

+ 5 - 0
src/main/java/scot/carricksoftware/grants/converters/text/documenttext/DocumentTextCommandConverterImpl.java

@@ -23,6 +23,11 @@ public class DocumentTextCommandConverterImpl implements DocumentTextCommandConv
         logger.debug("DocumentTextCommandConverter::convert");
         DocumentText target = new DocumentText();
         target.setId(source.getId());
+        target.setId(source.getId());
+        target.setContent(source.getContent());
+        target.setLevel(source.getLevel());
+        target.setOrder(source.getOrder());
+        target.setHeading(source.getHeading());
         return target;
     }
 

+ 5 - 0
src/main/java/scot/carricksoftware/grants/converters/text/documenttext/DocumentTextConverterImpl.java

@@ -24,6 +24,11 @@ public class DocumentTextConverterImpl implements DocumentTextConverter {
         logger.debug("DocumentTextConverter::convert");
         DocumentTextCommand target = new DocumentTextCommandImpl();
         target.setId(source.getId());
+        target.setLevel(source.getLevel());
+        target.setOrder(source.getOrder());
+        target.setHeading(source.getHeading());
+        target.setContent(source.getContent());
+        target.setId(source.getId());
         return target;
     }
 

+ 139 - 0
src/main/resources/templates/images/documentImage/form.html

@@ -0,0 +1,139 @@
+<!DOCTYPE html>
+<!--suppress XmlHighlighting -->
+<html lang="en" xmlns:th="http://www.thymeleaf.org">
+<head>
+    <!-- Required meta tags -->
+    <meta charset="utf-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
+
+    <!-- Bootstrap CSS -->
+    <!--suppress SpellCheckingInspection -->
+    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
+          integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
+
+    <!--suppress SpellCheckingInspection -->
+    <script src="https://code.jquery.com/jquery-3.6.0.min.js"
+            integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
+    <title>Grants - appendix images</title>
+
+</head>
+<body>
+<!--/*@thymesVar id="appendixImageCommand" type="scot.carricksoftware.grants.commands.images.AppendixImageCommand"*/-->
+<div th:insert="~{fragments/layout::banner}"></div>
+
+<div class="container border border-info rounded-3 text-center p-4">
+    <h3>Appendix Image Details</h3>
+    <form th:object="${appendixImageCommand}" th:action="@{/appendixImage}" method="post">
+        <div th:if="${#fields.hasErrors('*')}" class="alert alert-danger">
+            <p>Please Correct The Errors Below</p>
+        </div>
+        <table style="width:100%;">
+            <tr>
+                <td style="text-align: right;">
+                    <label for="id"><span style="color: rgb(255,0,0);">*</span>Database Id :&nbsp;</label>
+                </td>
+                <td style="text-align: left;">
+                    <input class="form-control" id="id"
+                           th:field="*{id}" type="text" readonly>
+                </td>
+            </tr>
+            <tr>
+                <td style="text-align: right;">
+                    <label for="image">Image : &nbsp;</label>
+                </td>
+                <td style="text-align: left;">
+                    <select id="image" name="image" th:field="*{image}">
+                        <option th:value="${''}" th:text="${''}"></option>
+                        <option th:each="image : ${images}"
+                                th:value="${image.id}" th:text="${image.name}"></option>
+                    </select>
+                    <div th:if="${#fields.hasErrors('image')}">
+                        <ul class="text-danger">
+                            <li th:each="err : ${#fields.errors('image')}" th:text="${err}"/>
+                        </ul>
+                    </div>
+                </td>
+            </tr>
+            <tr>
+                <td style="text-align: right;">
+                    <label for="order">Order :&nbsp;</label>
+                </td>
+                <td style="text-align: left;">
+                    <input class="form-control" id="order"
+                           th:field="*{order}" type="text">
+                    <div th:if="${#fields.hasErrors('order')}">
+                        <ul class="text-danger">
+                            <li th:each="err : ${#fields.errors('order')}" th:text="${err}"/>
+                        </ul>
+                    </div>
+                </td>
+            </tr>
+            <tr>
+                <td style="text-align: right;">
+                    <label for="level">Level :&nbsp;</label>
+                </td>
+                <td style="text-align: left;">
+                    <input class="form-control" id="level"
+                           th:field="*{level}" type="text">
+                    <div th:if="${#fields.hasErrors('level')}">
+                        <ul class="text-danger">
+                            <li th:each="err : ${#fields.errors('level')}" th:text="${err}"/>
+                        </ul>
+                    </div>
+                </td>
+            </tr>
+            <tr>
+                <td style="text-align: right;">
+                    <label for="caption">Caption :&nbsp;</label>
+                </td>
+                <td style="text-align: left;">
+                    <input class="form-control" id="caption"
+                           th:field="*{caption}" type="text">
+                    <div th:if="${#fields.hasErrors('caption')}">
+                        <ul class="text-danger">
+                            <li th:each="err : ${#fields.errors('caption')}" th:text="${err}"/>
+                        </ul>
+                    </div>
+                </td>
+            </tr>
+
+            <tr>
+                <td style="text-align: right;">
+                    <label for="width">Width :&nbsp;</label>
+                </td>
+                <td style="text-align: left;">
+                    <input class="form-control" id="width"
+                           th:field="*{width}" type="text">
+                    <div th:if="${#fields.hasErrors('width')}">
+                        <ul class="text-danger">
+                            <li th:each="err : ${#fields.errors('width')}" th:text="${err}"/>
+                        </ul>
+                    </div>
+                </td>
+            </tr>
+            <tr>
+                <td style="text-align: right;">
+                    <label for="height">Height :&nbsp;</label>
+                </td>
+                <td style="text-align: left;">
+                    <input class="form-control" id="height"
+                           th:field="*{height}" type="text">
+                    <div th:if="${#fields.hasErrors('height')}">
+                        <ul class="text-danger">
+                            <li th:each="err : ${#fields.errors('height')}" th:text="${err}"/>
+                        </ul>
+                    </div>
+                </td>
+            </tr>
+            <tr>
+                <td>&nbsp;</td>
+            </tr>
+        </table>
+        <button type="submit" class="btn btn-primary">Commit</button>
+        <a class="btn btn-secondary" th:href="@{/appendixImages}" th:text="${'List all'}">List all</a>
+        <a class="btn btn-success" th:href="@{/}" th:text="${'Home'}">Home</a>
+        <h6><span style="color: rgb(255,0,0);">*</span><span> Cannot be edited</span></h6>
+    </form>
+</div>
+</body>
+</html>

+ 77 - 0
src/main/resources/templates/images/documentImage/list.html

@@ -0,0 +1,77 @@
+<!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">
+</head>
+<body>
+<div th:insert="~{fragments/layout::banner}"></div>
+
+<div class="container text-center">
+    <div class="container border border-info
+                    rounded-3 text-center p-4">
+        <h3> Document Images</h3>
+        <table class="table table-striped table-bordered">
+            <thead class="table-dark">
+            <tr>
+                <th>ID</th>
+                <th>Order</th>
+                <th>Level</th>
+                <th>Caption</th>
+                <th></th>
+                <th></th>
+            </tr>
+            </thead>
+
+            <tr th:each="image : ${documentImages}">
+                <!--/*@thymesVar id="person" type="scot.carricksoftware.grants.domains.people.Person"*/-->
+                <td th:text="${image.id}">123</td>
+                <td th:text="${image.order}"></td>
+                <td th:text="${image.level}"></td>
+                <td th:text="${image.caption}"></td>
+                <td>
+                    <div th:if="${image.image != null and !#strings.isEmpty(image.image)}">
+                        <img class='img-thumbnail' th:src="'data:image/jpeg;base64,' + ${image.image.imageData} "
+                             width="50" height="50" alt=""/>
+                    </div>
+                </td>
+                <td><span>
+                        <a th:action="delete" class="btn btn-danger btn-sm" href=""
+                           th:href="@{'documentImage/' + ${image.id} + '/delete'}"
+                           th:text="Delete"></a>
+                    <a th:action="edit" class="btn btn-warning btn-sm"
+                       th:href="@{'documentImage/' + ${image.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="@{/documentImages/rewind}"
+                           th:text="'<<'"></a>
+                         <a th:action="back" class="btn btn-secondary btn-sm"
+                            th:href="@{/documentImages/prev}" th:text="'<'"></a>
+                         <a th:action="new" class="btn btn-primary btn-sm" th:href="@{/documentImage/new}"
+                            th:text="'New Document Image'"></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="@{/documentImages/next}" th:text="'>'"></a>
+                         <a th:action="end" class="btn btn-secondary btn-sm" th:href="@{/documentImages/ff}"
+                            th:text="'>>'"></a>
+                        </span></td>
+            </tr>
+            </tfoot>
+        </table>
+    </div>
+</div>
+</body>
+</html>
+

+ 1 - 1
src/main/resources/templates/index.html

@@ -67,7 +67,7 @@
             <td>
                 <a class="btn btn-outline-secondary btn-sm btn-block" href="documentTexts">Document Texts</a>
             <td>
-            <a class="btn btn-outline-secondary btn-sm btn-block" href="documentImages">Document Images</a>
+            <a class="btn btn-outline-secondary btn-sm btn-block" href="/documentImages">Document Images</a>
             </td>
         </tr>
         <tr>

+ 57 - 0
src/main/resources/templates/text/documentText/form.html

@@ -37,6 +37,63 @@
                            th:field="*{id}" type="text" readonly>
                 </td>
             </tr>
+            <tr>
+                <td style="text-align: right;">
+                    <label for="order">Order :&nbsp;</label>
+                </td>
+                <td style="text-align: left;">
+                    <input class="form-control" id="order"
+                           th:field="*{order}" type="text">
+                    <div th:if="${#fields.hasErrors('order')}">
+                        <ul class="text-danger">
+                            <li th:each="err : ${#fields.errors('order')}" th:text="${err}"/>
+                        </ul>
+                    </div>
+                </td>
+            </tr>
+            <tr>
+                <td style="text-align: right;">
+                    <label for="level">Level :&nbsp;</label>
+                </td>
+                <td style="text-align: left;">
+                    <input class="form-control" id="level"
+                           th:field="*{level}" type="text">
+                    <div th:if="${#fields.hasErrors('level')}">
+                        <ul class="text-danger">
+                            <li th:each="err : ${#fields.errors('level')}" th:text="${err}"/>
+                        </ul>
+                    </div>
+                </td>
+            </tr>
+            <tr>
+                <td style="text-align: right;">
+                    <label for="heading">Heading :&nbsp;</label>
+                </td>
+                <td style="text-align: left;">
+                    <input class="form-control" id="heading"
+                           th:field="*{heading}" type="text">
+                    <div th:if="${#fields.hasErrors('heading')}">
+                        <ul class="text-danger">
+                            <li th:each="err : ${#fields.errors('heading')}" th:text="${err}"/>
+                        </ul>
+                    </div>
+                </td>
+            </tr>
+            <tr style="border-bottom: 5px solid #ccc;">
+                <td style="text-align: right;">
+                    <label for="content">Content :&nbsp;</label>
+                </td>
+                <td style="text-align: left;">
+                    <div>
+                        <textarea class="content" id="content" rows="25" cols="60"
+                                  th:field="*{content}" type="text"></textarea>
+                    </div>
+                </td>
+            </tr>
+            <tr>
+                <td>&nbsp;</td>
+            </tr>
+        </table>
             <tr><td>&nbsp;</td></tr>
         </table>
         <button type="submit" class="btn btn-primary">Commit</button>

+ 6 - 4
src/main/resources/templates/text/documentText/list.html

@@ -23,8 +23,9 @@
             <thead class="table-dark">
             <tr>
                 <th>ID</th>
-                <th></th>
-                <th></th>
+                <th>Order</th>
+                <th>Level</th>
+                <th>Heading</th>
                 <th></th>
             </tr>
             </thead>
@@ -32,8 +33,9 @@
             <!--/*@thymesVar id="text" type="scot.carricksoftware.grants.domains.text.DocumentText"*/-->
             <tr th:each="text : ${documentTexts}">
                 <td th:text="${text.id}">123</td>
-                <td></td>
-                <td></td>
+                <td th:text="${text.order}">123</td>
+                <td th:text="${text.level}">123</td>
+                <td th:text="${text.heading}">123</td>
                 <td><span>
                         <a th:action="delete" class="btn btn-danger btn-sm" href=""
                            th:href="@{'documentTexts/' + ${text.id} + '/delete'}"