2019-05-12 15:31:50 +04:00

374 lines
23 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="en"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorator="default" xmlns:th="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/html">
<head>
<link rel="stylesheet" href="../css/grant.css"/>
</head>
<body>
<div class="container" layout:fragment="content">
<section id="grant">
<div class="container">
<div class="row">
<div class="col-lg-12 text-center">
<h2 class="section-heading text-uppercase">Редактирование гранта</h2>
<div th:replace="grants/fragments/grantNavigationFragment"/>
</div>
</div>
<hr/>
<div class="row">
<div class="col-lg-12">
<form id="grant-form" method="post" th:action="@{'/grants/grant?id='+ *{id == null ? '' : id} + ''}"
th:object="${grantDto}">
<div class="row">
<div class="col-md-6 col-sm-12">
<input type="hidden" name="id" th:field="*{id}"/>
<div class="form-group">
<label for="title">Название:</label>
<input class="form-control" id="title" type="text"
placeholder="Название гранта"
th:field="*{title}"/>
<p th:if="${#fields.hasErrors('title')}" th:errors="*{title}"
class="alert alert-danger">Incorrect title</p>
<p class="help-block text-danger"></p>
</div>
<div class="form-group">
<label for="status">Статус:</label>
<select class="form-control" th:field="*{status}" id="status">
<option th:each="status : ${allStatuses}" th:value="${status}"
th:text="${status.statusName}">Status
</option>
</select>
</div>
<div class="form-group">
<label for="comment">Комментарий:</label>
<textarea class="form-control" rows="3" id="comment"
th:field="*{comment}"></textarea>
</div>
<div class="form-group">
<label>Дедлайны показателей:</label>
<input type="hidden" th:field="*{removedDeadlineIds}"/>
<div class="row" th:each="deadline, rowStat : *{deadlines}">
<input type="hidden" th:field="*{deadlines[__${rowStat.index}__].id}"/>
<div class="col-6 div-deadline-date">
<input type="date" class="form-control form-deadline-date" name="deadline"
th:field="*{deadlines[__${rowStat.index}__].date}"/>
</div>
<div class="col-4 div-deadline-description">
<input class="form-control" type="text" placeholder="Описание"
th:field="*{deadlines[__${rowStat.index}__].description}"/>
</div>
<div class="col-2">
<button type="submit"
class="btn btn-danger float-right btn-delete-deadline"
id="removeDeadline" name="removeDeadline"
th:value="${rowStat.index}">
<span aria-hidden="true">
<i class="fa fa-times"/>
</span>
</button>
</div>
</div>
<p th:if="${#fields.hasErrors('deadlines')}" th:errors="*{deadlines}"
class="alert alert-danger">Incorrect title</p>
</div>
<div class="form-group">
<input type="submit" id="addDeadline" name="addDeadline" class="btn btn-primary"
value="Добавить дедлайн"/>
</div>
<div class="form-group div-loader">
<label for="loader">Загрузить файлы:</label>
<div id="loader">
</div>
</div>
<div class="form-group" id="files-list">
<div th:replace="grants/fragments/grantFilesListFragment :: filesList(isLatexAttach = ${false})"/>
</div>
</div>
<div class="col-md-6 col-sm-12">
<label data-toggle="collapse"
href="#collapse-filter"
aria-expanded="false"
aria-controls="collapse-filter">Фильтр рабочей группы
</label>
<div th:class="${grantDto.wasLeader || grantDto.hasAge || grantDto.hasDegree
|| grantDto.hasBAKPapers || grantDto.hasScopusPapers} ?
'form-check' : 'form-check collapse'" id="collapse-filter">
<div class="row">
<div class="col">
<input class="form-check-input" type="checkbox" id="f1"
th:field="*{wasLeader}" th:onclick="|$('#filter').click();|"/>
<label class="form-check-label" for="f1">Был руководителем проекта</label>
</div>
<div class="col">
<input class="form-check-input" type="checkbox" id="f2"
th:field="*{hasAge}" th:onclick="|$('#filter').click();|"/>
<label class="form-check-label" for="f2">Младше 35 лет</label>
</div>
</div>
<div class="row">
<div class="col">
<input class="form-check-input" type="checkbox" id="f3"
th:field="*{hasDegree}" th:onclick="|$('#filter').click();|"/>
<label class="form-check-label" for="f3">епень к.т.н.</label>
</div>
<div class="col">
<input class="form-check-input" type="checkbox" id="f4"
th:field="*{hasScopusPapers}" th:onclick="|$('#filter').click();|"/>
<label class="form-check-label" for="f4">Более 3-х публикаций в
scopus</label>
</div>
</div>
<div class="row">
<div class="col">
<input class="form-check-input" type="checkbox" id="f5"
th:field="*{hasBAKPapers}" th:onclick="|$('#filter').click();|"/>
<label class="form-check-label" for="f5">Наличие ВАК статей</label> <br/>
</div>
<div class="col">
<input class="form-check-input" type="checkbox" id="f6"/>
<label class="form-check-label" for="f6">Наименьшая загруженность</label>
</div>
</div>
<input type="submit" hidden="hidden" id="filter" name="filterUsers"
value="Применить фильтр"/>
<hr/>
</div>
<div class="form-group">
<label>Руководитель проекта:</label>
<select class="form-control" th:field="*{leaderId}" id="leaderId"
onchange="updateAuthors();">
<option selected="selected" hidden="hidden" th:value="-1">-- Выберите
руководителя --
</option>
<option th:each="leader : ${allAuthors}" th:value="${leader.id}"
th:text="${leader.lastName}"> Руководитель
</option>
</select>
<p th:if="${#fields.hasErrors('leaderId')}" th:errors="*{leaderId}"
class="alert alert-danger">Choose leader</p>
<p class="help-block text-danger"></p>
</div>
<div class="form-group">
<label>Участники гранта:</label>
<select class="selectpicker form-control" multiple="true" data-live-search="true"
title="-- Выберите участников --" id="authors"
th:field="*{authorIds}" data-size="5">
<option th:each="author : ${allAuthors}" th:value="${author.id}"
th:text="${author.lastName}"> Участник
</option>
</select>
</div>
<div class="form-group">
<label>Список статей:</label>
<div class="row">
<div class="col-8">
<select class="selectpicker form-control" multiple="true"
data-live-search="true"
title="Прикрепить статью" id="allPapers"
th:field="*{paperIds}" data-size="5">
<option th:each="paper : ${allPapers}" th:value="${paper.id}"
th:text="${paper.title}">Статья для прикрепления
</option>
</select>
</div>
<div class="col-4 div-view-paper">
<a th:onclick="|$('#attachPaper').click();|">
<span aria-hidden="true">
<label>Отобразить</label>
</span>
</a>
</div>
<input type="submit" hidden="hidden" id="attachPaper" name="attachPaper"
value="Отобразить прикрепленную статью"/>
</div>
<div class="row">
<div class="form-control list-group div-selected-papers" id="selected-papers">
<div th:each="paper, rowStat : *{papers}">
<input type="hidden" th:field="*{papers[__${rowStat.index}__].id}"/>
<div class="col">
<a th:href="@{'/papers/paper?id=' + *{papers[__${rowStat.index}__].id} + ''}">
<img class="icon-paper" src="/img/conference/paper.png"/>
<span th:text="*{papers[__${rowStat.index}__].title}">
Название статьи
</span>
</a>
</div>
<div class="col">
<label>Статус: </label>
<span th:text="*{papers[__${rowStat.index}__].status.statusName}">
Статус статьи
</span>
</div>
<!--
<div class="col" th:unless="${#lists.isEmpty(paper.grants)}">
<label>Гранты: </label>
<div th:each="grant, grantRowStat : *{papers[__${rowStat.index}__].grants}"
th:remove="tag">
<div th:unless="${grant.id}==*{id}" th:remove="tag">
<li>
<a th:href="@{'/grants/grant?id=' + ${grant.id} + ''}">
<span th:text="${grant.title} "></span>
</a>
</li>
</div>
</div>
</div>
<div class="col" th:unless="${#lists.isEmpty(paper.conferences)}">
<label>Конференции: </label>
<div th:each="conference, conferenceRowStat : *{papers[__${rowStat.index}__].conferences}"
th:remove="tag">
<li>
<a th:href="@{'/conferences/conference?id=' + ${conference.id} + ''}">
<span th:text="${conference.title}"></span>
</a>
</li>
</div>
</div>
-->
</div>
</div>
</div>
</div>
<div class="form-group">
<div th:if="*{project} == null">
<input type="submit" name="createProject" class="btn btn-primary"
value="Добавить проект"/>
</div>
<input type = "hidden" th:field="*{project.id}"/>
</div>
</div>
<div class="clearfix"></div>
<div class="col-lg-12">
<div class="form-group">
<button id="sendMessageButton" name="save" class="btn btn-success text-uppercase"
type="submit">
Сохранить
</button>
<button id="cancelButton" class="btn btn-default text-uppercase" href="/grants/grants">
Отмена
</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</section>
<script type="text/javascript" src="/js/file-loader.js"></script>
<script>
/*<![CDATA[*/
$(document).ready(function () {
new FileLoader({
div: "loader",
url: urlFileUpload,
maxSize: -1,
extensions: [],
callback: function (response) {
showFeedbackMessage("Файл успешно загружен");
console.debug(response);
addNewFile(response);
}
});
$('.selectpicker').selectpicker();
});
/*]]>*/
function addNewFile(fileDto) {
var fileNumber = $("#files-list div.row").length;
var newFileRow = $("<div/>")
.attr("id", 'files' + fileNumber)
.addClass("row div-row-file");
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 + ".deleted")
.attr("value", "false")
.attr("name", "files[" + fileNumber + "].deleted");
newFileRow.append(flagInput);
var nameInput = $("<input/>")
.attr("type", "hidden")
.attr("id", "files" + fileNumber + ".name")
.attr("value", fileDto.fileName)
.attr("name", "files[" + fileNumber + "].name");
newFileRow.append(nameInput);
var tmpFileNameInput = $("<input/>")
.attr("type", "hidden")
.attr("id", "files" + fileNumber + ".tmpFileName")
.attr("value", fileDto.tmpFileName)
.attr("name", "files[" + fileNumber + "].tmpFileName");
newFileRow.append(tmpFileNameInput);
var nameDiv = $("<div/>")
.addClass("col-10 div-file-name")
.append($("<a/>").text(fileDto.fileName)
.attr("href", 'javascript:void(0)')
.attr("onclick", "downloadFile('" + fileDto.tmpFileName + "',null,'" + fileDto.fileName + "')"));
newFileRow.append(nameDiv);
var nextDiv = $("<div/>")
.addClass("col-2");
var nextA = $("<a/>")
.addClass("btn btn-danger float-right")
.attr("onclick", "$('#files" + fileNumber + "\\\\.deleted').val('true'); $('#files" + fileNumber + "').hide();")
.append(($("<span/>").attr("aria-hidden", "true")).append($("<i/>").addClass("fa fa-times")))
;
nextDiv.append(nextA)
newFileRow.append(nextDiv);
$("#files-list").append(newFileRow);
}
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 {
}
}
}
</script>
<script type="text/javascript">
function updateAuthors() {
$("#authors").val('default');
$("#authors").selectpicker("refresh");
$("#authors").children('option:disabled').prop('disabled', false);
var lid = $("#leaderId option:selected").val();
$("#authors [value='" + lid + "']").attr("disabled", "disabled");
}
</script>
</div>
</body>
</html>