diff --git a/src/main/resources/public/js/papers.js b/src/main/resources/public/js/papers.js index 07fa21c..9866874 100644 --- a/src/main/resources/public/js/papers.js +++ b/src/main/resources/public/js/papers.js @@ -1,6 +1,7 @@ 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) { @@ -32,6 +33,47 @@ function showPapers(papersElement, paperRowClass) { }); } +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("
" + + "
" + + " \n" + + " " + + " " + + " " + + " " + paper.title + "
" + + "
" + + "" + + "" + + "
"); + }); + + + $(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) { $("#remove-paper-modal").modal('show'); diff --git a/src/main/resources/templates/papers/papers.html b/src/main/resources/templates/papers/papers.html index 3f440cd..cb492db 100644 --- a/src/main/resources/templates/papers/papers.html +++ b/src/main/resources/templates/papers/papers.html @@ -26,7 +26,27 @@
Добавить статью +
+ + +
+
Фильтровать по:
+ + +
@@ -51,6 +71,10 @@