openaire-library/searchPages/searchUtils/searchUtils.class.ts

63 lines
1.8 KiB
TypeScript
Raw Normal View History

import {properties} from "../../../../environments/environment";
export class SearchUtilsClass{
page:number = 1;
size:number = 10;
defaultSize:number = 10;
status:number = 1;
[Trunk | Library]: 1. searchUtils.class.ts: In SearchUtilsClass added field "refineStatus:number = 1;" for refine queries. 2. searchResultsPerPage.component.ts & searchSorting.component.ts: [Bug fix] In EventEmitter (value change), emit raw value, not object with field "value". 3. searchDataProviders.component.ts & searchOrganizations.component.ts & searchProjects.component.ts & searchResearchResults.component.ts: a. Add subscriptions in array to unsubscribe in ngOnDestroy. b. Get properties from environment (no service needed). c. Separate queries for refine and results. d. Do not call refine query when page, results per page, sortBy change (there is still a bug here). e. For refine query, added field "disableRefineForms" default set to false - passed in <new-search-page>. 4. newSearchPage.component.html: a. Disable forms when "disableForms" or "disableRefineForms" is true. b. Do not show filters, until results query returns, but show results while refine is loading. c. Deleted old, unused code. 5. newSearchPage.component.ts: a. Added fields "@Input() disableRefineForms: boolean = false;", "@Input() sortedByChanged: string = "";", "@Input() resultsPerPageChanged: number;" b. When results per page or sortBy change, do not upadate immediately searchUtils values - do not query for refine when these change (there is still a bug here). git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59155 d315682c-612b-4755-9ff5-7f18f6832af3
2020-07-21 15:48:55 +02:00
refineStatus:number = 1;
keyword:string = "";
baseUrl:string = "";
totalResults = null;
totalResultsNoFilters:number; // for organization landing - tab with projects
sortBy: string = "";
validateSize(sizeFromParams){
this.size = (sizeFromParams=== undefined)?this.defaultSize:+sizeFromParams;
if(this.size != 5 && this.size != 10 && this.size != 20 && this.size != 50) {
this.size = this.defaultSize;
}
}
}
export class SearchCustomFilter{
fieldName:string; //Country
queryFieldName:string; //country
valueId:string; //gr
valueName:string; // Greece
isHiddenFilter:boolean;
selected:boolean;
showFilterMessage:boolean;
customQuery:string;
constructor( fieldName:string, queryFieldName:string, valueId:string, valueName:string, showFilterMessage:boolean = true, customQuery = null ){
if(valueId == "test" && properties.environment == "development"){
valueId = "covid-19";
}
this.showFilterMessage = showFilterMessage;
this.isHiddenFilter = true;
this.fieldName = fieldName;
this.queryFieldName = queryFieldName;
this.valueId = valueId;
this.valueName = valueName;
this.selected = null;
this.customQuery = customQuery;
}
public getParameters(params={}){
if(!this.isHiddenFilter){
params[this.queryFieldName] = this.valueId;
params['cf'] = true;
}
return params;
}
// public setFilter(filter:SearchCustomFilter){
// if(!filter){
// return;
// }
// this.fieldName = filter.fieldName;
// this.queryFieldName = filter.queryFieldName;
// this.valueId = filter.valueId;
// this.valueName = filter.valueName;
// }
}