From 10fe7e8a4e3d96edc6581b16691792c4d1bbd719 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D0=BC=D0=B5=D0=BD=D0=BE=D0=B2=D0=B0=20=D0=9C?= =?UTF-8?q?=D0=B0=D1=80=D0=B8=D1=8F?= Date: Sun, 24 Mar 2019 12:42:21 +0400 Subject: [PATCH] paper files list fragment, latex attachs upload --- .../java/ru/ulstu/file/model/FileDataDto.java | 19 ++++++ .../ru/ulstu/file/service/FileService.java | 1 + src/main/resources/public/css/paper.css | 2 +- .../fragments/paperFilesListFragment.html | 45 +++++++++++++ .../resources/templates/papers/paper.html | 67 ++++++++++--------- 5 files changed, 101 insertions(+), 33 deletions(-) create mode 100644 src/main/resources/templates/papers/fragments/paperFilesListFragment.html diff --git a/src/main/java/ru/ulstu/file/model/FileDataDto.java b/src/main/java/ru/ulstu/file/model/FileDataDto.java index 919cd80..65ef275 100644 --- a/src/main/java/ru/ulstu/file/model/FileDataDto.java +++ b/src/main/java/ru/ulstu/file/model/FileDataDto.java @@ -9,6 +9,7 @@ public class FileDataDto { private String fileName; private String tmpFileName; private boolean deleted; + private boolean isLatexAttach; public FileDataDto() { } @@ -16,17 +17,20 @@ public class FileDataDto { @JsonCreator public FileDataDto(@JsonProperty("id") Integer id, @JsonProperty("name") String name, + @JsonProperty("isLatexAttach") boolean isLatexAttach, @JsonProperty("fileName") String fileName, @JsonProperty("tmpFileName") String tmpFileName) { this.id = id; this.name = name; this.fileName = fileName; this.tmpFileName = tmpFileName; + this.isLatexAttach = isLatexAttach; } public FileDataDto(FileData fileData) { this.id = fileData.getId(); this.name = fileData.getName(); + this.isLatexAttach = fileData.isLatexAttach(); } public FileDataDto(String fileName, String tmpFileName) { @@ -73,4 +77,19 @@ public class FileDataDto { this.deleted = deleted; } + public boolean isLatexAttach() { + return isLatexAttach; + } + + public boolean getIsLatexAttach() { + return isLatexAttach; + } + + public void setLatexAttach(boolean latexAttach) { + isLatexAttach = latexAttach; + } + + public void setIsLatexAttach(boolean latexAttach) { + isLatexAttach = latexAttach; + } } diff --git a/src/main/java/ru/ulstu/file/service/FileService.java b/src/main/java/ru/ulstu/file/service/FileService.java index ad9f946..234ea2a 100644 --- a/src/main/java/ru/ulstu/file/service/FileService.java +++ b/src/main/java/ru/ulstu/file/service/FileService.java @@ -107,6 +107,7 @@ public class FileService { private FileData copyFromDto(FileData fileData, FileDataDto fileDataDto) { fileData.setName(fileDataDto.getName()); + fileData.setLatexAttach(fileDataDto.isLatexAttach()); return fileData; } diff --git a/src/main/resources/public/css/paper.css b/src/main/resources/public/css/paper.css index 159bbe1..824209f 100644 --- a/src/main/resources/public/css/paper.css +++ b/src/main/resources/public/css/paper.css @@ -1,4 +1,4 @@ -#files-list .row > div:nth-child(6) { +#files-list .row > div:nth-child(7) { display: flex; justify-content: center; flex-direction: column; diff --git a/src/main/resources/templates/papers/fragments/paperFilesListFragment.html b/src/main/resources/templates/papers/fragments/paperFilesListFragment.html new file mode 100644 index 0000000..fcc875c --- /dev/null +++ b/src/main/resources/templates/papers/fragments/paperFilesListFragment.html @@ -0,0 +1,45 @@ + + + + + + + +
+ + + + +
+ + + + + +
+ + + +
+
+ + +
+
+
+
+
+ + + + + \ No newline at end of file diff --git a/src/main/resources/templates/papers/paper.html b/src/main/resources/templates/papers/paper.html index 2953b93..f2c5332 100644 --- a/src/main/resources/templates/papers/paper.html +++ b/src/main/resources/templates/papers/paper.html @@ -106,33 +106,10 @@ class="alert alert-danger">Incorrect title

-
+
- -
- - - - -
- - - -
-
- - -
-
-
+ +
@@ -156,11 +133,18 @@ placeholder="Latex.." th:field="*{latexText}"/>
+
+ +
+
+
+ +
+
+
-
-
@@ -231,14 +215,26 @@ showFeedbackMessage("Файл успешно загружен"); console.debug(response); - addNewFile(response); + addNewFile(response, $("#files-list"), false); + } + }); + new FileLoader({ + div: "latex-loader", + url: urlFileUpload, + maxSize: -1, + extensions: [], + callback: function (response) { + showFeedbackMessage("Файл успешно загружен"); + console.debug(response); + + addNewFile(response, $("#latex-files-list"), true); } }); $('.selectpicker').selectpicker(); }); /*]]>*/ - function addNewFile(fileDto) { - var fileNumber = $("#files-list div.row").length; + function addNewFile(fileDto, listElement, isLatexAttach) { + var fileNumber = $('.files-list div.row').length; var newFileRow = $("
") .attr("id", 'files' + fileNumber) @@ -272,6 +268,13 @@ .attr("name", "files[" + fileNumber + "].tmpFileName"); newFileRow.append(tmpFileNameInput); + var isLatexInput = $("") + .attr("type", "hidden") + .attr("id", "files" + fileNumber + ".isLatexAttach") + .attr("value", isLatexAttach) + .attr("name", "files[" + fileNumber + "].isLatexAttach"); + newFileRow.append(isLatexInput); + var nextDiv = $("
") .addClass("col-2"); @@ -290,7 +293,7 @@ .attr("onclick", "downloadFile('" + fileDto.tmpFileName + "',null,'" + fileDto.fileName + "')")); newFileRow.append(nameDiv); - $("#files-list").append(newFileRow); + listElement.append(newFileRow); }