ng-tracker/src/main/resources/templates/papers/paper.html

300 lines
16 KiB
HTML
Raw Normal View History

2018-04-29 20:44:47 +04:00
<!DOCTYPE html>
<html lang="en"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
2018-12-17 13:46:08 +04:00
layout:decorator="default" xmlns:th="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/html">
2018-04-29 20:44:47 +04:00
<head>
2019-03-19 17:59:19 +04:00
<link rel="stylesheet" href="../css/paper.css"/>
2018-04-29 20:44:47 +04:00
</head>
<body>
2018-04-29 20:44:47 +04:00
<div class="container" layout:fragment="content">
2018-04-29 20:44:47 +04:00
<section id="paper">
<div class="container">
<div class="row">
<div class="col-lg-12 text-center">
<h2 class="section-heading text-uppercase">Редактирование статьи</h2>
2018-12-18 18:05:30 +04:00
<div th:replace="papers/fragments/paperNavigationFragment"/>
</div>
2018-04-29 20:48:05 +04:00
</div>
2018-12-30 19:23:11 +04:00
<hr/>
<div class="row">
<div class="col-lg-12">
2018-12-17 13:46:08 +04:00
<form id="paper-form" method="post" th:action="@{'/papers/paper?id='+ *{id == null ? '' : id} + ''}"
2018-12-05 16:51:26 +04:00
th:object="${paperDto}">
<div class="row">
2018-12-30 19:23:11 +04:00
<div class="col-md-7 col-sm-12">
2018-12-05 16:51:26 +04:00
<input type="hidden" name="id" th:field="*{id}"/>
<div class="form-group">
2018-11-26 23:07:14 +04:00
<label for="title">Название:</label>
2018-12-04 11:35:51 +04:00
<input class="form-control" id="title" type="text"
2018-11-26 23:07:14 +04:00
placeholder="Название статьи"
2018-12-04 11:35:51 +04:00
th:field="*{title}"/>
2018-12-05 16:51:26 +04:00
<p th:if="${#fields.hasErrors('title')}" th:errors="*{title}"
class="alert alert-danger">Incorrect title</p>
<p class="help-block text-danger"></p>
</div>
2018-10-10 17:05:54 +04:00
<div class="form-group">
<label for="status">Статус:</label>
2018-12-04 14:48:39 +04:00
<select class="form-control" th:field="*{status}" id="status">
2018-12-05 16:51:26 +04:00
<option th:each="status : ${allStatuses}" th:value="${status}"
th:text="${status.statusName}">Status
</option>
2018-10-10 17:05:54 +04:00
</select>
</div>
<div class="form-group">
<label for="comment">Комментарий:</label>
2018-11-26 23:07:14 +04:00
<textarea class="form-control" rows="5" id="comment"
th:field="*{comment}"></textarea>
2018-10-10 17:05:54 +04:00
</div>
2018-10-25 08:41:37 +04:00
<div class="form-group">
2018-12-17 13:46:08 +04:00
<label>Дедлайны:</label>
<div class="row" th:each="deadline, rowStat : *{deadlines}">
<input type="hidden" th:field="*{deadlines[__${rowStat.index}__].id}"/>
<div class="col-6">
<input type="date" class="form-control" name="deadline"
th:field="*{deadlines[__${rowStat.index}__].date}"/>
</div>
2018-12-18 19:40:23 +04:00
<div class="col-4">
2018-12-17 13:46:08 +04:00
<input class="form-control" type="text" placeholder="Описание"
th:field="*{deadlines[__${rowStat.index}__].description}"/>
</div>
2018-12-18 19:40:23 +04:00
<div class="col-2">
2018-12-17 13:46:08 +04:00
<a class="btn btn-danger float-right"
th:onclick="|$('#deadlines${rowStat.index}\\.description').val('');
$('#deadlines${rowStat.index}\\.date').val('');
$('#addDeadline').click();|"><span
aria-hidden="true"><i class="fa fa-times"/></span>
</a>
</div>
</div>
<p th:if="${#fields.hasErrors('deadlines')}" th:errors="*{deadlines}"
2018-12-05 16:51:26 +04:00
class="alert alert-danger">Incorrect title</p>
2018-10-25 08:41:37 +04:00
</div>
2018-12-17 13:46:08 +04:00
<div class="form-group">
2018-12-30 19:23:11 +04:00
<input type="submit" id="addDeadline" name="addDeadline" class="btn btn-primary"
value="Добавить
2018-12-17 13:46:08 +04:00
дедлайн"/>
</div>
2018-12-30 19:23:11 +04:00
<div class="form-group">
<label>Авторы:</label>
<select class="selectpicker form-control" multiple="true" data-live-search="true"
title="-- Выберите авторов --"
th:field="*{authorIds}">
<option th:each="author: ${allAuthors}" th:value="${author.id}"
th:text="${author.lastName}">Status
</option>
</select>
<p th:if="${#fields.hasErrors('authorIds')}" th:errors="*{authorIds}"
class="alert alert-danger">Incorrect title</p>
</div>
2019-03-18 16:02:55 +04:00
2019-03-18 18:39:15 +04:00
<div class="form-group" id="files-list">
2019-03-18 16:02:55 +04:00
<label>Файлы:</label>
<th:block th:each="file, rowStat : *{files}">
<div class="row" th:id="|files${rowStat.index}|"
th:style="${file.deleteFlag} ? 'display: none;' :''">
<input type="hidden" th:field="*{files[__${rowStat.index}__].id}"/>
<input type="hidden" th:field="*{files[__${rowStat.index}__].deleteFlag}"/>
<input type="hidden" th:field="*{files[__${rowStat.index}__].name}"/>
2019-03-18 18:39:15 +04:00
<input type="hidden" th:field="*{files[__${rowStat.index}__].tmpFileName}"/>
2019-03-18 16:02:55 +04:00
<div class="col-2">
<a class="btn btn-danger float-right"
th:onclick="|$('#files${rowStat.index}\\.deleteFlag').val('true'); $('#files${rowStat.index}').hide(); |">
<span aria-hidden="true"><i class="fa fa-times"/></span>
</a>
</div>
2019-03-19 17:59:19 +04:00
<div class="col-10">
<a th:onclick="${file.id==null} ? 'downloadFile('+${file.tmpFileName}+',null,\''+${file.name}+'\')':
'downloadFile(null,'+${file.id}+',\''+${file.name}+'\')' "
2019-03-18 21:02:26 +04:00
href="javascript:void(0)"
th:text="*{files[__${rowStat.index}__].name}">
</a>
2019-03-18 16:02:55 +04:00
</div>
</div>
</th:block>
2019-03-18 18:39:15 +04:00
2019-03-18 16:02:55 +04:00
</div>
2018-10-10 17:05:54 +04:00
<div class="form-check">
2018-11-26 23:07:14 +04:00
<input type="checkbox" class="form-check-input" id="locked"
th:field="*{locked}"/>
2018-10-10 17:05:54 +04:00
<label class="form-check-label" for="locked">Заблокирована</label>
</div>
<div class="form-group">
<label for="loader">Загрузить статью:</label>
<div id="loader">
</div>
</div>
2018-12-30 19:23:11 +04:00
</div>
<div class="col-md-4 offset-md-1 col-sm-12 offset-sm-0">
2018-10-18 11:21:26 +04:00
<div class="form-group">
2018-12-30 19:23:11 +04:00
<div class="row">
<div class="col">
<h6 class="my-0">Дата создания:</h6>
</div>
<div class="col">
<small class="text-muted"
th:text="${paperDto.createDate == null ? '' : #dates.format(paperDto.createDate, 'dd.MM.yyyy HH:mm')}">
text
</small>
</div>
</div>
2018-10-18 11:21:26 +04:00
</div>
2018-12-05 18:08:47 +04:00
<div class="form-group">
2018-12-30 19:23:11 +04:00
<div class="row">
<div class="col">
<h6 class="my-0">Дата изменения:</h6>
</div>
<div class="col">
<small class="text-muted"
th:text="${paperDto.updateDate == null ? '' : #dates.format(paperDto.updateDate, 'dd.MM.yyyy HH:mm')}">
text
</small>
</div>
</div>
2018-12-05 18:08:47 +04:00
</div>
2018-10-11 19:49:16 +04:00
<div class="form-group">
2018-12-30 19:23:11 +04:00
<button id="pingButton" class="btn btn-primary text-uppercase"
type="button">
2018-10-11 19:49:16 +04:00
Ping авторам
</button>
</div>
2018-10-11 15:39:57 +04:00
</div>
<div class="clearfix"></div>
2018-10-11 19:49:16 +04:00
<div class="col-lg-12">
<div class="form-group">
2018-12-30 19:23:11 +04:00
<button id="sendMessageButton" name="save"
class="btn btn-success text-uppercase"
2018-10-11 19:49:16 +04:00
type="submit">
Сохранить
</button>
2018-12-30 19:23:11 +04:00
<a id="cancelButton" class="btn btn-default text-uppercase"
href="/papers/papers">
2018-10-11 19:49:16 +04:00
Отмена
2018-12-05 16:51:26 +04:00
</a>
2018-10-11 19:49:16 +04:00
</div>
2018-11-26 23:07:14 +04:00
2018-04-29 20:44:47 +04:00
</div>
</div>
</form>
</div>
2018-04-29 20:44:47 +04:00
</div>
</div>
</section>
2018-10-10 17:05:54 +04:00
<script type="text/javascript" src="/js/file-loader.js"></script>
<script>
/*<![CDATA[*/
$(document).ready(function () {
new FileLoader({
div: "loader",
url: urlFileUpload,
2019-03-18 19:17:28 +04:00
maxSize: -1,
2019-03-18 18:39:15 +04:00
extensions: [],
2018-10-10 17:05:54 +04:00
callback: function (response) {
showFeedbackMessage("Файл успешно загружен");
console.debug(response);
2019-03-18 18:39:15 +04:00
addNewFile(response);
2018-10-10 17:05:54 +04:00
}
});
2018-12-05 18:08:47 +04:00
$('.selectpicker').selectpicker();
2018-10-10 17:05:54 +04:00
});
/*]]>*/
2019-03-21 18:26:28 +04:00
function addNewFile(fileDto) {
2019-03-18 18:39:15 +04:00
var fileNumber = $("#files-list div.row").length;
var newFileRow = $("<div/>")
.attr("id", 'files' + fileNumber)
.addClass("row");
var idInput = $("<input/>")
.attr("type", "hidden")
.attr("id", "files" + fileNumber + ".id")
.attr("value", '')
.attr("name", "files[" + fileNumber + "].id");
newFileRow.append(idInput);
var flagInput = $("<input/>")
.attr("type", "hidden")
.attr("id", "files" + fileNumber + ".deleteFlag")
.attr("value", "false")
.attr("name", "files[" + fileNumber + "].deleteFlag");
newFileRow.append(flagInput);
var nameInput = $("<input/>")
.attr("type", "hidden")
.attr("id", "files" + fileNumber + ".name")
2019-03-21 18:26:28 +04:00
.attr("value", fileDto.fileName)
2019-03-18 18:39:15 +04:00
.attr("name", "files[" + fileNumber + "].name");
newFileRow.append(nameInput);
var tmpFileNameInput = $("<input/>")
.attr("type", "hidden")
.attr("id", "files" + fileNumber + ".tmpFileName")
2019-03-21 18:26:28 +04:00
.attr("value", fileDto.tmpFileName)
2019-03-18 18:39:15 +04:00
.attr("name", "files[" + fileNumber + "].tmpFileName");
newFileRow.append(tmpFileNameInput);
var nextDiv = $("<div/>")
.addClass("col-2");
var nextA = $("<a/>")
.addClass("btn btn-danger float-right")
.attr("onclick", "$('#files" + fileNumber + "\\\\.deleteFlag').val('true'); $('#files" + fileNumber + "').hide();")
.append(($("<span/>").attr("aria-hidden", "true")).append($("<i/>").addClass("fa fa-times")))
;
nextDiv.append(nextA)
newFileRow.append(nextDiv);
var nameDiv = $("<div/>")
.addClass("col-10")
2019-03-21 18:26:28 +04:00
.append($("<a/>").text(fileDto.fileName)
2019-03-18 21:02:26 +04:00
.attr("href", 'javascript:void(0)')
2019-03-21 18:26:28 +04:00
.attr("onclick", "downloadFile('" + fileDto.tmpFileName + "',null,'" + fileDto.fileName + "')"));
2019-03-18 18:39:15 +04:00
newFileRow.append(nameDiv);
$("#files-list").append(newFileRow);
}
2019-03-18 21:02:26 +04:00
function downloadFile(tmpName, fileId, downloadName) {
let xhr = new XMLHttpRequest();
if (fileId != null) xhr.open('GET', urlFileDownload + fileId);
if (tmpName != null) xhr.open('GET', urlFileDownloadTmp + tmpName);
xhr.responseType = 'blob';
var formData = new FormData();
if (fileId != null) formData.append("file-id", fileId);
if (tmpName != null) formData.append("tmp-file-name", tmpName);
xhr.send(formData);
xhr.onload = function () {
if (this.status == 200) {
console.debug(this.response);
var blob = new Blob([this.response], {type: '*'});
let a = document.createElement("a");
a.style = "display: none";
document.body.appendChild(a);
let url = window.URL.createObjectURL(blob);
a.href = url;
a.download = downloadName;
a.click();
window.URL.revokeObjectURL(url);
} else {
}
}
}
2018-10-10 17:05:54 +04:00
</script>
</div>
2018-10-10 15:30:47 +04:00
</body>
</html>