Commit e1158c3c 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 749ae296
.result-highlight {
font-weight: bold;
color: #490200;
}
#search-result-cloud svg text {
cursor: pointer;
}
......
......@@ -111,7 +111,7 @@ Basesearch.prototype.showSearchResponseItem = function(result, resultsContainer)
// kreuz: †
var death = "";
if (result.deathDate!=null) {
death = "; gestorben <span class='search-result-death-date'>" +
death = "gestorben <span class='search-result-death-date'>" +
result.deathDate +
"</span>";
if (result.deathPlace!=null) {
......@@ -121,6 +121,9 @@ Basesearch.prototype.showSearchResponseItem = function(result, resultsContainer)
death += "&nbsp;in <span class='search-result-death-place'>" + result.deathPlace.titleEn + "</span>";
}
}
if (birth.length > 0) {
death = "; " + death;
}
}
......@@ -130,6 +133,21 @@ Basesearch.prototype.showSearchResponseItem = function(result, resultsContainer)
description = "<p class='search-result-description'>" + result.description + "</p>";
}
/* Description */
var highlights = "";
if (result.fieldHighlightsMap!=null && result.fieldHighlightsMap!=undefined) {
for (var field in result.fieldHighlightsMap) {
highlights += "<div id=\"search-result-highlights\">" +
"<h4>" + field + "</h4>" +
"<ul>";
for (var i=0; i<result.fieldHighlightsMap[field].length; i++) {
highlights += "<li>" + result.fieldHighlightsMap[field][i] + "</li>"
}
highlights += "</ul></div>";
}
}
/* Title */
var title;
if (result.titleDe!=null && result.titleDe!="") {
......@@ -158,6 +176,7 @@ Basesearch.prototype.showSearchResponseItem = function(result, resultsContainer)
birth + death +
"</div>" +
"</div>" +
(highlights.length > 0 ? "<div class='panel-group search-result-subpanel'>" + highlights + "</div>" : "") +
"</div>" +
"</div>";
......
......@@ -19,13 +19,15 @@ function GroupView() {
$(".group-members-loading").hide();
});
this.loadManualTerms();
this.loadSignificantTerms(function(data) {
$(".significant-terms-loading").hide();
if (data.length>0) {
$(".no-significant-terms").hide();
$("#significant-terms-table-container").show();
this.query("queryCandidates", "#group-candidates-container", function(data) {
_this.query("queryCandidates", "#group-candidates-container", function(data) {
$(".group-candidates-loading").hide();
});
} else {
......@@ -123,6 +125,44 @@ GroupView.prototype.loadSignificantTerms = function(callback) {
});
};
GroupView.prototype.loadManualTerms = function() {
var _this = this;
$.ajax({
url: __util.composeUrl("groups/" + _this.groupId + "/manualTerms"),
type: "GET",
dataType: "json",
success: function(data) {
if (data!=null && data!=undefined) {
if (data.manual.length>0) {
$(".no-manual-terms").hide();
for (var i=0; i<data.manual.length; i++) {
$("#manual-terms").append("<li>" +
"<span class='term'>" + data.manual[i] + "</span>" +
"<button onclick='groupView.removeTerm(this);' title='Term freigeben' class='btn btn-link btn-xs'><i class='fa fa-trash' aria-hidden='true'></i>" +
"</li>");
}
} else {
$(".no-manual-terms").show();
}
if (data.banned.length>0) {
$(".no-banned-terms").hide();
for (var i=0; i<data.banned.length; i++) {
$("#banned-terms").append("<li>" +
"<span class='term'>" + data.banned[i] + "</span>" +
"<button onclick='groupView.unbanTerm(this);' title='Term löschen' class='btn btn-link btn-xs'><i class='fa fa-trash' aria-hidden='true'></i>" +
"</li>");
}
} else {
$(".no-banned-terms").show();
}
}
},
error: __util.processServerError
});
};
GroupView.prototype.fillSignificantTermsCloud = function(data) {
var _this = this;
......@@ -156,6 +196,7 @@ GroupView.prototype.fillSignificantTermsTable = function(data) {
"<i class=\"fa fa-question-circle\" aria-hidden=\"true\"></i></th>" +
"<th class=\"td-no-wrap\">Treffer Subset</th>" +
"<th class=\"td-no-wrap\">Treffer Superset</th>" +
"<th></th>" +
"</tr>" +
"</head>" +
"<tbody></tbody>")
......@@ -163,11 +204,72 @@ GroupView.prototype.fillSignificantTermsTable = function(data) {
var tags = [];
for (var i=0; i<data.length; i++) {
$("#significant-terms-table tbody").append("<tr>" +
"<td><em>" + data[i].term + "</em></td>" +
"<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>")
}
}
};
GroupView.prototype.banTerm = function(control) {
var _this = this;
$.ajax({
url: __util.composeUrl("groups/" + _this.groupId + "/ban"),
type: "POST",
encoding:"UTF-8",
dataType:"json",
data: { term : $(control).closest("tr").find(".significant-term").text()},
success: function(data) {
console.log(data);
}
});
};
GroupView.prototype.unbanTerm = function(control) {
var _this = this;
$.ajax({
url: __util.composeUrl("groups/" + _this.groupId + "/unban"),
type: "POST",
encoding:"UTF-8",
dataType:"json",
data: { term : $(control).closest("li").find(".term").text()},
success: function(data) {
console.log(data);
}
});
};
GroupView.prototype.addManualTerm = function() {
var _this = this;
bootbox.prompt("Signifikanten Term manuell hinzufügen...", function(result) {
if (result!=null) {
$.ajax({
url: __util.composeUrl("groups/" + _this.groupId + "/addTerm"),
type: "POST",
encoding:"UTF-8",
dataType:"json",
data: { term : result },
success: function(data) {
console.log(data);
}
});
}
});
};
GroupView.prototype.removeTerm = function(control) {
var _this = this;
$.ajax({
url: __util.composeUrl("groups/" + _this.groupId + "/removeTerm"),
type: "POST",
encoding:"UTF-8",
dataType:"json",
data: { term : $(control).closest("li").find(".term").text()},
success: function(data) {
console.log(data);
}
});
};
\ 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