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