paper files list fragment, latex attachs upload
This commit is contained in:
parent
c86f58d1b2
commit
10fe7e8a4e
@ -9,6 +9,7 @@ public class FileDataDto {
|
|||||||
private String fileName;
|
private String fileName;
|
||||||
private String tmpFileName;
|
private String tmpFileName;
|
||||||
private boolean deleted;
|
private boolean deleted;
|
||||||
|
private boolean isLatexAttach;
|
||||||
|
|
||||||
public FileDataDto() {
|
public FileDataDto() {
|
||||||
}
|
}
|
||||||
@ -16,17 +17,20 @@ public class FileDataDto {
|
|||||||
@JsonCreator
|
@JsonCreator
|
||||||
public FileDataDto(@JsonProperty("id") Integer id,
|
public FileDataDto(@JsonProperty("id") Integer id,
|
||||||
@JsonProperty("name") String name,
|
@JsonProperty("name") String name,
|
||||||
|
@JsonProperty("isLatexAttach") boolean isLatexAttach,
|
||||||
@JsonProperty("fileName") String fileName,
|
@JsonProperty("fileName") String fileName,
|
||||||
@JsonProperty("tmpFileName") String tmpFileName) {
|
@JsonProperty("tmpFileName") String tmpFileName) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.fileName = fileName;
|
this.fileName = fileName;
|
||||||
this.tmpFileName = tmpFileName;
|
this.tmpFileName = tmpFileName;
|
||||||
|
this.isLatexAttach = isLatexAttach;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileDataDto(FileData fileData) {
|
public FileDataDto(FileData fileData) {
|
||||||
this.id = fileData.getId();
|
this.id = fileData.getId();
|
||||||
this.name = fileData.getName();
|
this.name = fileData.getName();
|
||||||
|
this.isLatexAttach = fileData.isLatexAttach();
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileDataDto(String fileName, String tmpFileName) {
|
public FileDataDto(String fileName, String tmpFileName) {
|
||||||
@ -73,4 +77,19 @@ public class FileDataDto {
|
|||||||
this.deleted = deleted;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -107,6 +107,7 @@ public class FileService {
|
|||||||
|
|
||||||
private FileData copyFromDto(FileData fileData, FileDataDto fileDataDto) {
|
private FileData copyFromDto(FileData fileData, FileDataDto fileDataDto) {
|
||||||
fileData.setName(fileDataDto.getName());
|
fileData.setName(fileDataDto.getName());
|
||||||
|
fileData.setLatexAttach(fileDataDto.isLatexAttach());
|
||||||
return fileData;
|
return fileData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#files-list .row > div:nth-child(6) {
|
#files-list .row > div:nth-child(7) {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
@ -0,0 +1,45 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8"/>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<body>
|
||||||
|
<div th:fragment="filesList (isLatexAttach)" th:remove="tag">
|
||||||
|
<th:block th:each="file, rowStat : *{files}">
|
||||||
|
|
||||||
|
<span th:if="${file.isLatexAttach == isLatexAttach}" th:remove="tag">
|
||||||
|
|
||||||
|
<div class="row" th:id="|files${rowStat.index}|"
|
||||||
|
th:style="${file.deleted} ? 'display: none;' :''">
|
||||||
|
<input type="hidden" th:field="*{files[__${rowStat.index}__].id}"/>
|
||||||
|
<input type="hidden"
|
||||||
|
th:field="*{files[__${rowStat.index}__].deleted}"/>
|
||||||
|
<input type="hidden"
|
||||||
|
th:field="*{files[__${rowStat.index}__].name}"/>
|
||||||
|
<input type="hidden"
|
||||||
|
th:field="*{files[__${rowStat.index}__].tmpFileName}"/>
|
||||||
|
<input type="hidden"
|
||||||
|
th:field="*{files[__${rowStat.index}__].isLatexAttach}"/>
|
||||||
|
<div class="col-2">
|
||||||
|
<a class="btn btn-danger float-right"
|
||||||
|
th:onclick="|$('#files${rowStat.index}\\.deleted').val('true'); $('#files${rowStat.index}').hide(); |">
|
||||||
|
<span aria-hidden="true"><i class="fa fa-times"/></span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="col-10">
|
||||||
|
<a th:onclick="${file.id==null} ? 'downloadFile('+${file.tmpFileName}+',null,\''+${file.name}+'\')':
|
||||||
|
'downloadFile(null,'+${file.id}+',\''+${file.name}+'\')' "
|
||||||
|
href="javascript:void(0)"
|
||||||
|
th:text="*{files[__${rowStat.index}__].name}">
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</span>
|
||||||
|
</th:block>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -106,33 +106,10 @@
|
|||||||
class="alert alert-danger">Incorrect title</p>
|
class="alert alert-danger">Incorrect title</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group" id="files-list">
|
<div class="form-group files-list" id="files-list">
|
||||||
<label>Файлы:</label>
|
<label>Файлы:</label>
|
||||||
<th:block th:each="file, rowStat : *{files}">
|
|
||||||
<div class="row" th:id="|files${rowStat.index}|"
|
<div th:replace="papers/fragments/paperFilesListFragment :: filesList(isLatexAttach = ${false})"/>
|
||||||
th:style="${file.deleted} ? 'display: none;' :''">
|
|
||||||
<input type="hidden" th:field="*{files[__${rowStat.index}__].id}"/>
|
|
||||||
<input type="hidden"
|
|
||||||
th:field="*{files[__${rowStat.index}__].deleted}"/>
|
|
||||||
<input type="hidden"
|
|
||||||
th:field="*{files[__${rowStat.index}__].name}"/>
|
|
||||||
<input type="hidden"
|
|
||||||
th:field="*{files[__${rowStat.index}__].tmpFileName}"/>
|
|
||||||
<div class="col-2">
|
|
||||||
<a class="btn btn-danger float-right"
|
|
||||||
th:onclick="|$('#files${rowStat.index}\\.deleted').val('true'); $('#files${rowStat.index}').hide(); |">
|
|
||||||
<span aria-hidden="true"><i class="fa fa-times"/></span>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
<div class="col-10">
|
|
||||||
<a th:onclick="${file.id==null} ? 'downloadFile('+${file.tmpFileName}+',null,\''+${file.name}+'\')':
|
|
||||||
'downloadFile(null,'+${file.id}+',\''+${file.name}+'\')' "
|
|
||||||
href="javascript:void(0)"
|
|
||||||
th:text="*{files[__${rowStat.index}__].name}">
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</th:block>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -156,11 +133,18 @@
|
|||||||
placeholder="Latex.."
|
placeholder="Latex.."
|
||||||
th:field="*{latexText}"/>
|
th:field="*{latexText}"/>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group files-list" id="latex-files-list">
|
||||||
|
<label>Файлы:</label>
|
||||||
|
<div th:replace="papers/fragments/paperFilesListFragment :: filesList(isLatexAttach = ${true})"/>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="latex-loader">Загрузить файлы:</label>
|
||||||
|
<div id="latex-loader">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-4 offset-md-1 col-sm-12 offset-sm-0">
|
<div class="col-md-4 offset-md-1 col-sm-12 offset-sm-0">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@ -231,14 +215,26 @@
|
|||||||
showFeedbackMessage("Файл успешно загружен");
|
showFeedbackMessage("Файл успешно загружен");
|
||||||
console.debug(response);
|
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();
|
$('.selectpicker').selectpicker();
|
||||||
});
|
});
|
||||||
/*]]>*/
|
/*]]>*/
|
||||||
function addNewFile(fileDto) {
|
function addNewFile(fileDto, listElement, isLatexAttach) {
|
||||||
var fileNumber = $("#files-list div.row").length;
|
var fileNumber = $('.files-list div.row').length;
|
||||||
|
|
||||||
var newFileRow = $("<div/>")
|
var newFileRow = $("<div/>")
|
||||||
.attr("id", 'files' + fileNumber)
|
.attr("id", 'files' + fileNumber)
|
||||||
@ -272,6 +268,13 @@
|
|||||||
.attr("name", "files[" + fileNumber + "].tmpFileName");
|
.attr("name", "files[" + fileNumber + "].tmpFileName");
|
||||||
newFileRow.append(tmpFileNameInput);
|
newFileRow.append(tmpFileNameInput);
|
||||||
|
|
||||||
|
var isLatexInput = $("<input/>")
|
||||||
|
.attr("type", "hidden")
|
||||||
|
.attr("id", "files" + fileNumber + ".isLatexAttach")
|
||||||
|
.attr("value", isLatexAttach)
|
||||||
|
.attr("name", "files[" + fileNumber + "].isLatexAttach");
|
||||||
|
newFileRow.append(isLatexInput);
|
||||||
|
|
||||||
var nextDiv = $("<div/>")
|
var nextDiv = $("<div/>")
|
||||||
.addClass("col-2");
|
.addClass("col-2");
|
||||||
|
|
||||||
@ -290,7 +293,7 @@
|
|||||||
.attr("onclick", "downloadFile('" + fileDto.tmpFileName + "',null,'" + fileDto.fileName + "')"));
|
.attr("onclick", "downloadFile('" + fileDto.tmpFileName + "',null,'" + fileDto.fileName + "')"));
|
||||||
newFileRow.append(nameDiv);
|
newFileRow.append(nameDiv);
|
||||||
|
|
||||||
$("#files-list").append(newFileRow);
|
listElement.append(newFileRow);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user