Commit 45dab026 authored by Gradl, Tobias's avatar Gradl, Tobias
Browse files

438: Fix / reimplement 'show more' behavior (OPENED)

Task-Url: search#438
parent efab5dbc
......@@ -161,11 +161,12 @@ QueryHandler.prototype.removeSearchFacet = function(control) {
this.reorderFacets();
};
QueryHandler.prototype.doSearch = function(isShowMore, initSearch) {
if (isShowMore===null || isShowMore===undefined) {
isShowMore=false;
QueryHandler.prototype.doSearch = function(offset, initSearch) {
var isShowMore=false;
if (offset!=null && offset!=undefined && !isNaN(offset)) {
isShowMore=true;
}
this.query = this.buildQuery(isShowMore);
this.query = this.buildQuery(offset);
this.imageQueue = [];
var _this = this;
......@@ -173,7 +174,6 @@ QueryHandler.prototype.doSearch = function(isShowMore, initSearch) {
$(".wordcloud").text("");
this.clouds = [];
$("#search-loading-indicator").removeClass("fade");
// Leave notifications in place for first execution of search
......@@ -254,9 +254,10 @@ QueryHandler.prototype.removeAllFilters = function() {
this.doSearchDelayed();
};
QueryHandler.prototype.buildQuery = function(isShowMore) {
QueryHandler.prototype.buildQuery = function(offset) {
var query = {
entities: [],
start: (offset!=null && offset!=undefined && !isNaN(offset)) ? parseInt(offset) : null,
filters: JSON.parse($("#selected-filters").val())
};
......
......@@ -45,9 +45,7 @@ ResponseHandler.prototype.process = function(resultArray, isShowMore) {
this.elements.resultsContainer.removeClass("hide");
this.elements.placeholderWordcloud.addClass("hide");
for (var i=0; i<resultArray.length; i++) {
var data = resultArray[i];
for (let data of resultArray) {
if (data.resultType=="REGULAR") {
this.processExecutedQueries(data.executedQueries);
......@@ -55,17 +53,15 @@ ResponseHandler.prototype.process = function(resultArray, isShowMore) {
this.processResponseDatasources(data.resultDatasources);
this.processFilters(data.availableFilters);
//_this.processResponseTerms();
//_this.processResponseSubjects();
//this.processResponseTerms();
//this.processResponseSubjects();
//
} else if (data.resultType=="META") {
var sourceIds = [];
for (var j=0; j<data.resultDatasources.length; j++) {
sourceIds.push(data.resultDatasources[j].providerId);
for (let datasource of data.resultDatasources) {
sourceIds.push(datasource.providerId);
}
search.metasearch(sourceIds, false);
}
}
};
......@@ -159,9 +155,7 @@ ResponseHandler.prototype.processResources = function(isShowMore, resultElements
return;
}
let query = search.queryHandler.buildQuery(false);
this.elements.resourcesHeading.text(String.format(__translator.translate("~eu.dariah.de.minfba.search.view.result.n_of_m_results"), resultElements.length, totalHits));
var indexOffset = this.elements.resourcesContainer.find(".search-results-item").length;
for (var i=0; i<resultElements.length; i++) {
var resultItem = $("<div class='search-results-item d-md-flex flex-row' style='display: none;'>");
......@@ -171,16 +165,18 @@ ResponseHandler.prototype.processResources = function(isShowMore, resultElements
resultItem.fadeIn("slow");
}
this.elements.resourcesHeading.text(String.format(__translator.translate("~eu.dariah.de.minfba.search.view.result.n_of_m_results"), $(".search-results-resource-item").length, totalHits));
this.processImages();
/*if (hasMore) {
if (hasMore) {
this.elements.resourcesContainer.append(
"<div class='search-results-resources-show-more'>" +
"<button onclick='queryHandler.doSearch(true);' class='btn btn-default btn-lg'>" +
"<button onclick='search.queryHandler.doSearch(" + (startIndex + resultElements.length) + ");' class='btn btn-default btn-lg'>" +
__translator.translate("~eu.dariah.de.minfba.search.view.result.show_more") +
"</button>" +
"</div>");
}*/
}
};
......
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