fix issue with filters not applied in search projects
This commit is contained in:
parent
8b11478f20
commit
5679464561
|
@ -97,13 +97,11 @@ export class OpenaireSearchProjectsComponent {
|
|||
this.keyword = decodeURIComponent(params['fv0']?params['fv0']:(params['keyword']?params['keyword']:''));
|
||||
this.selectedFields = [];
|
||||
this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, [], this.fieldIdsMap, this.customFilter, params, "project");
|
||||
this.filters = [];
|
||||
this.searchPage.prepareFiltersToShow(this.filters, 0);
|
||||
if(this.initialLoad) {
|
||||
this.initialLoad = false;
|
||||
this._getResults();
|
||||
}else{
|
||||
this.filterResults();
|
||||
this._getResults();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
@ -118,25 +116,31 @@ export class OpenaireSearchProjectsComponent {
|
|||
});
|
||||
}
|
||||
private _getResults(){
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
this.disableForms = true;
|
||||
this.enableSearchView = false;
|
||||
this.results = [];
|
||||
this.searchUtils.totalResults = 0;
|
||||
this.subscriptions.push(this._searchProjectsService.searchProjects(this.properties, this.communityId).subscribe(
|
||||
this.searchUtils.refineStatus = this.errorCodes.LOADING;
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
this.disableForms = true;
|
||||
this.disableRefineForms = true;
|
||||
this.enableSearchView = false;
|
||||
if(this.allResults) {
|
||||
this.subscriptions.push(this._searchProjectsService.searchProjects(this.properties, this.communityId).subscribe(
|
||||
data => {
|
||||
this.originalFilters = this.createFilters(data);
|
||||
this.originalFilters = this.createFilters(data).slice(); //copy array
|
||||
this.allResults = this.parseResults(data);
|
||||
this.filters = this.searchPage.prepareFiltersToShow(this.originalFilters, this.allResults.length);
|
||||
this.filterResults();
|
||||
},
|
||||
err => {
|
||||
|
||||
this.handleError("Error getting projects for community with id: "+this.communityId, err);
|
||||
this.handleError("Error getting projects for community with id: " + this.communityId, err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
|
||||
this.enableSearchView = true;
|
||||
}
|
||||
));
|
||||
));
|
||||
}else{
|
||||
this.filters = this.searchPage.prepareFiltersToShow(this.originalFilters, this.allResults.length);
|
||||
this.filterResults();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -204,11 +208,6 @@ export class OpenaireSearchProjectsComponent {
|
|||
return results;
|
||||
}
|
||||
filterResults(){
|
||||
this.searchUtils.refineStatus = this.errorCodes.LOADING;
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
this.disableForms = true;
|
||||
this.disableRefineForms = true;
|
||||
this.enableSearchView = false;
|
||||
let results = this.allResults.filter(value => { return value.title.name && value.title.name.toLowerCase().indexOf(this.keyword.toLowerCase()) !=-1 || value.acronym && value.acronym.toLowerCase().indexOf(this.keyword.toLowerCase()) !=-1});
|
||||
let funderFilterValues = [];
|
||||
for(let filter of this.filters){
|
||||
|
@ -226,17 +225,13 @@ export class OpenaireSearchProjectsComponent {
|
|||
});
|
||||
}
|
||||
this.oldTotalResults = results.length;
|
||||
this.searchUtils.totalResults = results.length;
|
||||
this.subscriptions.push(setTimeout(() => {
|
||||
this.filters = this.searchPage.prepareFiltersToShow(this.originalFilters, this.allResults.length);
|
||||
this.results = results.slice((this.searchUtils.page - 1) * this.searchUtils.size, this.searchUtils.page *this.searchUtils.size );
|
||||
this.searchUtils.status = this.results.length == 0 ? this.errorCodes.NONE: this.errorCodes.DONE;
|
||||
this.disableForms = false;
|
||||
this.disableRefineForms = false;
|
||||
this.enableSearchView = true;
|
||||
this.searchUtils.refineStatus = this.errorCodes.DONE;
|
||||
}, 300));
|
||||
|
||||
this.searchUtils.totalResults = results.length;
|
||||
this.results = results.slice((this.searchUtils.page - 1) * this.searchUtils.size, this.searchUtils.page *this.searchUtils.size );
|
||||
this.searchUtils.status = this.results.length == 0 ? this.errorCodes.NONE: this.errorCodes.DONE;
|
||||
this.disableForms = false;
|
||||
this.disableRefineForms = false;
|
||||
this.enableSearchView = true;
|
||||
this.searchUtils.refineStatus = this.errorCodes.DONE;
|
||||
}
|
||||
private handleError(message: string, error) {
|
||||
console.error("Projects simple Search Page: "+message, error);
|
||||
|
|
Loading…
Reference in New Issue