Commit 62e379a0 authored by Gradl, Tobias's avatar Gradl, Tobias
Browse files

1183: Implement search result filtering

Task-Url: https://pm.winseda.de/issues/1183
parent 44b99c59
......@@ -84,6 +84,7 @@
.search-result-objects {
padding: 10px 0px;
overflow: hidden;
}
.search-result-label {
......@@ -97,8 +98,13 @@
margin-right: 5px;
}
.search-result-label-wrapper {
float: left;
padding: 5px 2px;
}
#applied-filters-container {
padding: 10px 5px;
padding: 5px 0;
}
.applied-filter {
......
......@@ -14,9 +14,7 @@ $(document).ready(function() {
$("#size").bind("slider:changed", function (event, data) {
$("#size_shown").text(data.value);
var ts = new Date();
queryHandler.lastDelayedQueryTs = ts;
setTimeout(function() { queryHandler.doSearchDelayed(ts); }, 1000);
queryHandler.doSearchDelayed();
});
// Required for page reload in FF
......@@ -287,7 +285,13 @@ QueryHandler.prototype.doSearch = function(isShowMore) {
}
};
QueryHandler.prototype.doSearchDelayed = function(timestamp) {
QueryHandler.prototype.doSearchDelayed = function() {
var ts = new Date();
queryHandler.lastDelayedQueryTs = ts;
setTimeout(function() { queryHandler.delaySearch(ts); }, 1000);
};
QueryHandler.prototype.delaySearch = function(timestamp) {
if (timestamp===this.lastDelayedQueryTs) {
this.lastDelayedQueryTs = null;
this.doSearch();
......@@ -574,7 +578,7 @@ QueryHandler.prototype.handleSubject = function(subject) {
}
$(label).append(__util.escapeHtml(strNormal));
label.data("queryFilter", subject);
label.data("queryFilter", query);
label.bind("click", function() {
var match = false;
var _this = this;
......@@ -591,7 +595,7 @@ QueryHandler.prototype.handleSubject = function(subject) {
.html($(this).html())
.append("&nbsp;<i class=\"fa fa-cross\" aria-hidden=\"true\"></i>");
var filter = $("<div class='applied-filter pull-left'>")
var filter = $("<div class='applied-filter search-result-label-wrapper'>")
.data("queryFilter", $(this).data("queryFilter"))
.html(filterLabel)
.bind("click", function() {
......@@ -599,15 +603,23 @@ QueryHandler.prototype.handleSubject = function(subject) {
if ($("#applied-filters-container .applied-filter").length==0) {
$("#applied-filters-container").addClass("hide");
}
queryHandler.doSearchDelayed();
});
$("#applied-filters-container #applied-filters").append(filter).append(" ");
$("#applied-filters-container").removeClass("hide");
queryHandler.doSearchDelayed();
});
return label;
return $("<div class='search-result-label-wrapper'>").append(label);
}
QueryHandler.prototype.removeAllFilters = function() {
$('#applied-filters-container .applied-filter').remove();
$('#applied-filters-container').addClass('hide');
this.doSearchDelayed();
};
QueryHandler.prototype.getValues = function(container) {
var values = [];
......@@ -768,12 +780,17 @@ QueryHandler.prototype.renderValue = function(value, maxlength) {
QueryHandler.prototype.buildQuery = function(isShowMore) {
var query = {};
var query = {
filters : []
};
$(".applied-filter").each(function() {
query.filters.push($(this).data("queryFilter"));
});
// Simple query view
if ($("#expression").length>0) {
query.queryString = $("#expression").val();
if (query.queryString==null || query.queryString=="") {
if ((query.queryString==null || query.queryString=="") && query.filters.length==0) {
return null;
}
} else {
......@@ -790,7 +807,7 @@ QueryHandler.prototype.buildQuery = function(isShowMore) {
doQuery = true;
}
});
if (!doQuery) {
if (!doQuery && query.filters.length==0) {
return null;
}
query.schemaId = $("#schemaId").val();
......@@ -802,6 +819,7 @@ QueryHandler.prototype.buildQuery = function(isShowMore) {
query.sourceIds = sourceSelection.getSelectedSourceIds();
query.customSearch = this.options.customSearch;
//query.providerIds = JSON.parse($("#providerIds").val());
//query.userCollectionId = parseInt($("#userCollectionId").val());
......
Supports Markdown
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