diff --git a/src/main/resources/public/js/papers.js b/src/main/resources/public/js/papers.js index b2b81a6..3b78d8a 100644 --- a/src/main/resources/public/js/papers.js +++ b/src/main/resources/public/js/papers.js @@ -1,19 +1,52 @@ var urlPapers = "/api/1.0/papers"; var urlPaperStatuses = "/api/1.0/papers/statuses"; +var urlDeletePaper = "/api/1.0/papers/"; -function showPapers(papersElement) { +function showPapers(papersElement, paperRowClass) { getFromRest(urlPapers, function (paperList) { paperList.forEach(function (paper, index) { - $(papersElement).parent().append("
" + - "
" + + $(papersElement).parent().append("
" + + "
" + " \n" + " " + " " + " " + " " + paper.title + "" + + "'>" + 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'); + + $("#modal-btn-yes").on("click", function () { + deleteFromRest(urlDeletePaper + id, function () { + showFeedbackMessage("Статья удалена"); + $(paperRowClass).remove(); + showPapers(papersElement, paperRowClass); + }); + $("#remove-paper-modal").modal('hide'); + }); + + $("#modal-btn-no").on("click", function () { + $("#remove-paper-modal").modal('hide'); }); } diff --git a/src/main/resources/templates/papers/papers.html b/src/main/resources/templates/papers/papers.html index 83cf15a..1c5322a 100644 --- a/src/main/resources/templates/papers/papers.html +++ b/src/main/resources/templates/papers/papers.html @@ -28,12 +28,24 @@
+