confirm delete paper
This commit is contained in:
parent
c2c420027b
commit
c88ce3ac37
@ -1,127 +1,14 @@
|
||||
var urlPapers = "/api/1.0/papers";
|
||||
var urlPaperStatuses = "/api/1.0/papers/statuses";
|
||||
var urlDeletePaper = "/api/1.0/papers/";
|
||||
var urlFilterPaper = "/api/1.0/papers/filter"
|
||||
|
||||
function showPapers(papersElement, paperRowClass) {
|
||||
getFromRest(urlPapers, function (paperList) {
|
||||
paperList.forEach(function (paper, index) {
|
||||
$(papersElement).parent().append("<div class='row text-left paper-row'>" +
|
||||
" <div class='col'>" +
|
||||
" <span class='fa-stack fa-1x'>\n" +
|
||||
" <i class='fa fa-circle fa-stack-2x " + getPaperStatusClass(paper.status) + "'></i>" +
|
||||
" <i class='fa fa-file-text-o fa-stack-1x fa-inverse'></i>" +
|
||||
" </span>" +
|
||||
" <a href='paper?id=" + paper.id + "" +
|
||||
"'><span>" + (index + 1) + ". " + paper.title + "</span></a>" +
|
||||
"<span class='remove-paper d-none pull-right' onclick=\"deletePaper(" + paper.id + ",'" + papersElement + "', '" + paperRowClass + "')\">" +
|
||||
"<i class=\"fa fa-trash\" aria-hidden=\"true\"></i></span>" +
|
||||
"</div></div>");
|
||||
});
|
||||
|
||||
$(paperRowClass).mouseenter(function (event) {
|
||||
var paperRow = $(event.target).closest(paperRowClass);
|
||||
$(paperRow).css("background-color", "#f8f9fa");
|
||||
$(paperRow).find(".remove-paper").removeClass("d-none");
|
||||
|
||||
});
|
||||
$(paperRowClass).mouseleave(function (event) {
|
||||
var paperRow = $(event.target).closest(paperRowClass);
|
||||
$(paperRow).css("background-color", "white");
|
||||
$(paperRow).closest(paperRowClass).find(".remove-paper").addClass("d-none");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function filterPapers(papersElement, paperRowClass, authorId, year) {
|
||||
var paperData = JSON.stringify({
|
||||
"authorId": authorId,
|
||||
"year": year
|
||||
});
|
||||
postToRest(urlFilterPaper, paperData, function (data) {
|
||||
$(paperRowClass).remove();
|
||||
if(data.length > 0){
|
||||
data.forEach(function (paper, index) {
|
||||
$(papersElement).parent().append("<div class='row text-left paper-row'>" +
|
||||
" <div class='col-md-11'>" +
|
||||
" <span class='fa-stack fa-1x'>\n" +
|
||||
" <i class='fa fa-circle fa-stack-2x " + getPaperStatusClass(paper.status) + "'></i>" +
|
||||
" <i class='fa fa-file-text-o fa-stack-1x fa-inverse'></i>" +
|
||||
" </span>" +
|
||||
" <a href='paper?id=" + paper.id + "" +
|
||||
"'><span>" + paper.title + "</span></a></div>" +
|
||||
"<div class='col-md-1'>" +
|
||||
"<span class='remove-paper d-none' onclick=\"deletePaper(" + paper.id + ",'" + papersElement + "', '" + paperRowClass + "')\">" +
|
||||
"<i class=\"fa fa-trash\" aria-hidden=\"true\"></i></span>" +
|
||||
" </div></div>");
|
||||
});
|
||||
|
||||
|
||||
$(paperRowClass).mouseenter(function (event) {
|
||||
var paperRow = $(event.target).closest(paperRowClass);
|
||||
$(paperRow).css("background-color", "#f8f9fa");
|
||||
$(paperRow).find(".remove-paper").removeClass("d-none");
|
||||
|
||||
});
|
||||
$(paperRowClass).mouseleave(function (event) {
|
||||
var paperRow = $(event.target).closest(paperRowClass);
|
||||
$(paperRow).css("background-color", "white");
|
||||
$(paperRow).closest(paperRowClass).find(".remove-paper").addClass("d-none");
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
function deletePaper(id, papersElement, paperRowClass) {
|
||||
var id = $(idElement).parent().find('.id-class').val();
|
||||
function deletePaper() {
|
||||
$("#remove-paper-modal").modal('show');
|
||||
|
||||
$("#modal-btn-yes").on("click", function () {
|
||||
deleteFromRest(urlDeletePaper + id, function () {
|
||||
showFeedbackMessage("Статья удалена");
|
||||
$(paperRowClass).remove();
|
||||
showPapers(papersElement, paperRowClass);
|
||||
});
|
||||
$("#remove-paper-modal").modal('hide');
|
||||
return true;
|
||||
});
|
||||
|
||||
$("#modal-btn-no").on("click", function () {
|
||||
$("#remove-paper-modal").modal('hide');
|
||||
});
|
||||
}
|
||||
|
||||
function addPaper(title, status, datePublish, dateUpdate, deadline, comment, locked, tmpFileName, authors) {
|
||||
var paperData = JSON.stringify({
|
||||
"title": title,
|
||||
"status": status,
|
||||
"deadlineDate":deadline,
|
||||
"comment": comment
|
||||
});
|
||||
postToRest(urlPapers, paperData, function (data) {
|
||||
alert(data);
|
||||
});
|
||||
}
|
||||
|
||||
function getPaperStatusClass(status) {
|
||||
switch (status) {
|
||||
case 'DRAFT':
|
||||
return "text-draft"
|
||||
case 'ON_PREPARATION':
|
||||
return "text-primary";
|
||||
case 'ON_REVIEW':
|
||||
return "text-primary";
|
||||
case 'COMPLETED':
|
||||
return "text-success";
|
||||
case 'ATTENTION':
|
||||
return "text-warning";
|
||||
case 'FAILED':
|
||||
return "text-failed";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function showPaperDashboard(dashboardElement) {
|
||||
|
@ -31,9 +31,10 @@
|
||||
</span>
|
||||
<a th:href="@{'paper?id='+${paper.id}}"><span th:text="${paper.title}"></span></a>
|
||||
<input class="id-class" type="hidden" th:value="${paper.id}"/>
|
||||
<a class="remove-paper pull-right d-none" th:href="@{'/papers/delete/'+${paper.id}}">
|
||||
<i class="fa fa-trash" aria-hidden="true"></i>
|
||||
</a>
|
||||
<a class="remove-paper pull-right d-none" th:href="@{'/papers/delete/'+${paper.id}}"
|
||||
data-confirm="Удалить статью?">
|
||||
<i class="fa fa-trash" aria-hidden="true"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -7,55 +7,43 @@
|
||||
<body>
|
||||
|
||||
<div class="container" layout:fragment="content">
|
||||
<section id="papers">
|
||||
<div class="container">
|
||||
<div class="row" id="paper-list">
|
||||
<div class="col-lg-12 text-center">
|
||||
<h2 class="section-heading text-uppercase">Статьи</h2>
|
||||
<form id="papers-form" method="get" th:action="@{'/papers/papers'}">
|
||||
<input th:type="hidden" name="paperDeleteId" id="paperDeleteId"/>
|
||||
<section id="papers">
|
||||
<div class="container">
|
||||
<div class="row" id="paper-list">
|
||||
<div class="col-lg-12 text-center">
|
||||
<h2 class="section-heading text-uppercase">Статьи</h2>
|
||||
|
||||
<div th:replace="papers/fragments/paperNavigationFragment"/>
|
||||
<div class = "filter">
|
||||
<h5>Фильтровать по:</h5>
|
||||
<select id = "author">
|
||||
<option value = "1">Алёна</option>
|
||||
<option value = "2">Маша</option>
|
||||
<option value = "3">Петя</option>
|
||||
</select>
|
||||
<select id = "index score">
|
||||
<option >РИНЦ</option>
|
||||
<option>Scopus</option>
|
||||
<option>Web of science</option>
|
||||
</select>
|
||||
<select id = "year">
|
||||
<option>2018</option>
|
||||
<option>2017</option>
|
||||
<option>2016</option>
|
||||
</select>
|
||||
<div th:replace="papers/fragments/paperNavigationFragment"/>
|
||||
<div class="filter">
|
||||
<h5>Фильтровать по:</h5>
|
||||
<select id="author">
|
||||
<option value="1">Алёна</option>
|
||||
<option value="2">Маша</option>
|
||||
<option value="3">Петя</option>
|
||||
</select>
|
||||
<select id="index score">
|
||||
<option>РИНЦ</option>
|
||||
<option>Scopus</option>
|
||||
<option>Web of science</option>
|
||||
</select>
|
||||
<select id="year">
|
||||
<option>2018</option>
|
||||
<option>2017</option>
|
||||
<option>2016</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<th:block th:each="paper : ${papers}">
|
||||
<div th:replace="papers/fragments/paperLineFragment :: titleLine(paper=${paper})"/>
|
||||
</th:block>
|
||||
</div>
|
||||
<th:block th:each="paper : ${papers}">
|
||||
<div th:replace="papers/fragments/paperLineFragment :: titleLine(paper=${paper})"/>
|
||||
</th:block>
|
||||
</div>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<div class="modal fade" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true"
|
||||
id="remove-paper-modal">
|
||||
<div class="modal-dialog modal-sm">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h8 class="modal-title" id="myModalLabel">Удалить статью?</h8>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Закрыть"><span
|
||||
aria-hidden="true">×</span></button>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" id="modal-btn-yes">Да</button>
|
||||
<button type="button" class="btn btn-primary" id="modal-btn-no">Нет</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="modalDelete"/>
|
||||
</form>
|
||||
<script src="/js/papers.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
@ -72,9 +60,32 @@
|
||||
$(paperRow).css("background-color", "white");
|
||||
$(paperRow).closest(".paper-row").find(".remove-paper").addClass("d-none");
|
||||
});
|
||||
jQuery('.filter').on('change','#year',function(){
|
||||
|
||||
filterPapers("#paper-list", ".paper-row",'1','2018');
|
||||
$('a[data-confirm]').click(function(ev) {
|
||||
var href = $(this).attr('href');
|
||||
if (!$('#dataConfirmModal').length) {
|
||||
$('#modalDelete').append('<div class="modal fade" id="dataConfirmModal" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true"\n' +
|
||||
' >\n' +
|
||||
' <div class="modal-dialog modal-sm">\n' +
|
||||
' <div class="modal-content">\n' +
|
||||
' <div class="modal-header">\n' +
|
||||
' <h8 class="modal-title" id="myModalLabel">Удалить статью?</h8>\n' +
|
||||
' <button type="button" class="close" data-dismiss="modal" aria-label="Закрыть"><span\n' +
|
||||
' aria-hidden="true">×</span></button>\n' +
|
||||
' </div>\n' +
|
||||
|
||||
' <div class="modal-footer">\n' +
|
||||
' <a class="btn btn-primary" id="dataConfirmOK">Да</a>'+
|
||||
' <button class="btn primary" data-dismiss="modal" aria-hidden="true">Нет</button>'+
|
||||
' </div>\n' +
|
||||
' </div>\n' +
|
||||
' </div>\n' +
|
||||
' </div>');
|
||||
}
|
||||
$('#dataConfirmModal').find('#myModalLabel').text($(this).attr('data-confirm'));
|
||||
$('#dataConfirmOK').attr('href', href);
|
||||
$('#dataConfirmModal').modal({show:true});
|
||||
return false;
|
||||
});
|
||||
});
|
||||
/*]]>*/
|
||||
|
Loading…
Reference in New Issue
Block a user