Merge branch '14-filter-frontend' into 'master'
Resolve "Фильтр статей" Closes #14 See merge request romanov73/ng-tracker!18
This commit is contained in:
commit
aee396f686
@ -1,6 +1,7 @@
|
|||||||
var urlPapers = "/api/1.0/papers";
|
var urlPapers = "/api/1.0/papers";
|
||||||
var urlPaperStatuses = "/api/1.0/papers/statuses";
|
var urlPaperStatuses = "/api/1.0/papers/statuses";
|
||||||
var urlDeletePaper = "/api/1.0/papers/";
|
var urlDeletePaper = "/api/1.0/papers/";
|
||||||
|
var urlFilterPaper = "/api/1.0/papers/filter"
|
||||||
|
|
||||||
function showPapers(papersElement, paperRowClass) {
|
function showPapers(papersElement, paperRowClass) {
|
||||||
getFromRest(urlPapers, function (paperList) {
|
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("<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) {
|
function deletePaper(id, papersElement, paperRowClass) {
|
||||||
$("#remove-paper-modal").modal('show');
|
$("#remove-paper-modal").modal('show');
|
||||||
|
|
||||||
|
@ -26,7 +26,27 @@
|
|||||||
<div class="col-12 col-sm-12 col-md-12 col-lg-4 col-xl-3">
|
<div class="col-12 col-sm-12 col-md-12 col-lg-4 col-xl-3">
|
||||||
<a href="./paper" class="btn btn-light toolbar-button"><i class="fa fa-plus-circle" aria-hidden="true"></i>
|
<a href="./paper" class="btn btn-light toolbar-button"><i class="fa fa-plus-circle" aria-hidden="true"></i>
|
||||||
Добавить статью</a>
|
Добавить статью</a>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -51,6 +71,10 @@
|
|||||||
<script>
|
<script>
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
showPapers("#paper-list", ".paper-row");
|
showPapers("#paper-list", ".paper-row");
|
||||||
|
jQuery('.filter').on('change','#year',function(){
|
||||||
|
|
||||||
|
filterPapers("#paper-list", ".paper-row",'1','2018');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user