瀏覽代碼

Document Texts List Controller (2)

Andrew Grant 6 月之前
父節點
當前提交
ec1c6d90f7

+ 8 - 7
src/main/java/scot/carricksoftware/grants/controllers/text/documenttext/DocumentTextListControllerImpl.java

@@ -13,7 +13,7 @@ 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.image.ImageService;
+import scot.carricksoftware.grants.services.text.documenttext.DocumentTextService;
 
 import static java.lang.Integer.max;
 
@@ -25,14 +25,15 @@ public class DocumentTextListControllerImpl implements DocumentTextListControlle
 
     private int currentPage = 0;
     private final ControllerHelper controllerHelper;
-    private final ImageService imageService;
+    private final DocumentTextService documentTextService;
 
     public DocumentTextListControllerImpl(ControllerHelper controllerHelper,
-                                          ImageService imageService) {
+                                          DocumentTextService documentTextService) {
         this.controllerHelper = controllerHelper;
-        this.imageService = imageService;
+        this.documentTextService = documentTextService;
     }
 
+
     @SuppressWarnings("SameReturnValue")
     @GetMapping(TextMappingConstants.DOCUMENT_TEXT_LIST)
     @Override
@@ -44,7 +45,7 @@ public class DocumentTextListControllerImpl implements DocumentTextListControlle
 
     @SuppressWarnings("SameReturnValue")
     private String sendAttributesAndReturn(Model model) {
-        model.addAttribute(TextAttributeConstants.DOCUMENT_TEXTS, imageService.getPagedImages(currentPage));
+        model.addAttribute(TextAttributeConstants.DOCUMENT_TEXTS, documentTextService.getPagedDocumentTexts(currentPage));
         controllerHelper.addAttributes(model);
         return ViewConstants.DOCUMENT_TEXT_LIST;
     }
@@ -80,7 +81,7 @@ public class DocumentTextListControllerImpl implements DocumentTextListControlle
     @Override
     public final String getLastPage(final Model model) {
         logger.debug("DocumentTextListControllerImpl::getLastPage");
-        long imageCount = imageService.count();
+        long imageCount = documentTextService.count();
         currentPage = (int) (imageCount / ApplicationConstants.DEFAULT_PAGE_SIZE);
         return sendAttributesAndReturn(model);
     }
@@ -91,7 +92,7 @@ public class DocumentTextListControllerImpl implements DocumentTextListControlle
     @Override
     public final String DocumentTextDelete(@PathVariable final String id) {
         logger.debug("DocumentTextListControllerImpl::imageDelete");
-        imageService.deleteById(Long.valueOf(id));
+        documentTextService.deleteById(Long.valueOf(id));
         return MappingConstants.REDIRECT + TextMappingConstants.DOCUMENT_TEXT;
     }
 

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

@@ -29,34 +29,34 @@
             </tr>
             </thead>
 
-            <tr th:each="image : ${images}">
-                <!--/*@thymesVar id="person" type="scot.carricksoftware.grants.domains.people.Person"*/-->
-                <td th:text="${image.id}">123</td>
+            <!--/*@thymesVar id="text" type="scot.carricksoftware.grants.domains.text.DocumentText"*/-->
+            <tr th:each="text : ${document_texts}">
+                <td th:text="${text.id}">123</td>
                 <td></td>
                 <td></td>
                 <td><span>
                         <a th:action="delete" class="btn btn-danger btn-sm" href=""
-                           th:href="'image/' + ${image.id} + '/delete'"
+                           th:href="'documentText/' + ${text.id} + '/delete'"
                            th:text="Delete"></a>
                     <a th:action="edit" class="btn btn-warning btn-sm"
-                       th:href="'image/' + ${image.id} + '/edit'"
+                       th:href="'documentText/' + ${text.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="@{/images/rewind}"
+                        <a th:action="rewind" class="btn btn-secondary btn-sm" th:href="@{/documentTexts/rewind}"
                            th:text="'<<'"></a>
                          <a th:action="back" class="btn btn-secondary btn-sm"
-                            th:href="@{/images/prev}" th:text="'<'"></a>
-                         <a th:action="new" class="btn btn-primary btn-sm" th:href="@{image/new}"
-                            th:text="'New Image'"></a>
+                            th:href="@{/documentTexts/prev}" th:text="'<'"></a>
+                         <a th:action="new" class="btn btn-primary btn-sm" th:href="@{/documentText/new}"
+                            th:text="'New Document'"></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="@{/images/next}" th:text="'>'"></a>
-                         <a th:action="end" class="btn btn-secondary btn-sm" th:href="@{/images/ff}"
+                            th:href="@{/documentTexts/next}" th:text="'>'"></a>
+                         <a th:action="end" class="btn btn-secondary btn-sm" th:href="@{/documentTexts/ff}"
                             th:text="'>>'"></a>
                         </span></td>
             </tr>