Commit e4541a19 authored by Gradl, Tobias's avatar Gradl, Tobias
Browse files

1092: Manual and banned terms for significant terms

Task-Url: https://pm.winseda.de/issues/1092
parent e1158c3c
......@@ -161,8 +161,8 @@ Basesearch.prototype.showSearchResponseItem = function(result, resultsContainer)
"<div class='panel-heading'>" +
(!this.auth ? "" : (
"<div class='pull-right'>" +
"<button onclick='elementGroups.triggerAddToGroup(\"" + result.id + "\");' class='btn btn-default btn-xs'><i class='fa fa-plus' aria-hidden='true'></i></button> " +
"<button onclick='elementGroups.triggerRemoveFromGroup(\"" + result.id + "\");' class='btn btn-default btn-xs'><i class='fa fa-minus' aria-hidden='true'></i></button> " +
"<button onclick='elementGroups.triggerAddToGroup(\"" + result.id + "\"); ' class='btn btn-default btn-xs'><i class='fa fa-plus' aria-hidden='true'></i></button> " +
"<button onclick='elementGroups.triggerRemoveFromGroup(\"" + result.id + "\", (groupView!==undefined? function() { location.reload() } : undefined )); ' class='btn btn-default btn-xs'><i class='fa fa-minus' aria-hidden='true'></i></button> " +
"</div>" )) +
"<h3 class='panel-title'><a href='" + __util.composeUrl("person/" + (result.id.replace(/\./g, "/"))) + "' target='_blank'><i class='fa fa-external-link' aria-hidden='true'></i> " + title + "</a>" +
$(symbols).html() +
......
......@@ -65,7 +65,7 @@ ElementGroups.prototype.triggerAddToGroup = function(itemId) {
modalFormHandler.show(form_identifier);
};
ElementGroups.prototype.triggerRemoveFromGroup = function(itemId) {
ElementGroups.prototype.triggerRemoveFromGroup = function(itemId, callback) {
if(!__util.isLoggedIn()) {
__util.showLoginNote();
return;
......@@ -87,6 +87,9 @@ ElementGroups.prototype.triggerRemoveFromGroup = function(itemId) {
{placeholder: "~*validationerrors.body", key: "~eu.dariah.de.minfba.common.view.forms.validationerrors.body"}],
completeCallback: function() {
_this.refreshElementGroups();
if (callback!==undefined) {
callback();
}
}
});
modalFormHandler.show(form_identifier);
......
......@@ -125,6 +125,18 @@ GroupView.prototype.loadSignificantTerms = function(callback) {
});
};
GroupView.prototype.refresh = function() {
this.loadManualTerms();
var _this = this;
this.loadSignificantTerms(function() {
$(".group-candidates-loading").show();
_this.query("queryCandidates", "#group-candidates-container", function(data) {
$(".group-candidates-loading").hide();
});
});
};
GroupView.prototype.loadManualTerms = function() {
var _this = this;
$.ajax({
......@@ -133,6 +145,7 @@ GroupView.prototype.loadManualTerms = function() {
dataType: "json",
success: function(data) {
if (data!=null && data!=undefined) {
$("#manual-terms").text("");
if (data.manual.length>0) {
$(".no-manual-terms").hide();
for (var i=0; i<data.manual.length; i++) {
......@@ -145,6 +158,7 @@ GroupView.prototype.loadManualTerms = function() {
$(".no-manual-terms").show();
}
$("#banned-terms").text("");
if (data.banned.length>0) {
$(".no-banned-terms").hide();
for (var i=0; i<data.banned.length; i++) {
......@@ -206,10 +220,11 @@ GroupView.prototype.fillSignificantTermsTable = function(data) {
$("#significant-terms-table tbody").append("<tr>" +
"<td class='significant-term'><em>" + data[i].term + "</em></td>" +
"<th>" + (Math.round(data[i].weight * 10000) / 10000) + "</th>" +
"<td>" + data[i].count + "</td>" +
"<td>" + data[i].bgCount + "</td>" +
"<td><button onclick='groupView.banTerm(this);' title='Term sperren' class='btn btn-link btn-xs'><i class='fa fa-ban' aria-hidden='true'></i></td>" +
"</tr>")
"<td>" + (data[i].count<0 ? 'N/A' : data[i].count) + "</td>" +
"<td>" + (data[i].count<0 ? 'N/A' : data[i].bgCount) + "</td>" +
"<td>" + (data[i].count<0 ? '' : "<button onclick='groupView.banTerm(this);' title='Term sperren' class='btn btn-link btn-xs'><i class='fa fa-ban' aria-hidden='true'></i>") +
"</td>" +
"</tr>")
}
}
};
......@@ -223,7 +238,7 @@ GroupView.prototype.banTerm = function(control) {
dataType:"json",
data: { term : $(control).closest("tr").find(".significant-term").text()},
success: function(data) {
console.log(data);
_this.refresh();
}
});
};
......@@ -237,7 +252,7 @@ GroupView.prototype.unbanTerm = function(control) {
dataType:"json",
data: { term : $(control).closest("li").find(".term").text()},
success: function(data) {
console.log(data);
_this.refresh();
}
});
};
......@@ -253,7 +268,7 @@ GroupView.prototype.addManualTerm = function() {
dataType:"json",
data: { term : result },
success: function(data) {
console.log(data);
_this.refresh();
}
});
}
......@@ -269,7 +284,7 @@ GroupView.prototype.removeTerm = function(control) {
dataType:"json",
data: { term : $(control).closest("li").find(".term").text()},
success: function(data) {
console.log(data);
_this.refresh();
}
});
};
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment