[Library|Trunk]

Stakeholder:
- add filteredApplied in indicator path.
- add IndicatorFilterUtils

Sidebar: enable search




git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59055 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2020-07-07 13:50:49 +00:00
parent 650964f962
commit 6df293c0b8
3 changed files with 56 additions and 12 deletions

View File

@ -47,8 +47,7 @@
<ng-template [ngIf]="searchLink">
<hr>
<ul>
<li title="This functionality is comming soon. Stay tuned!"><a [href]="searchLink"
class="uk-disabled">
<li ><a [href]="searchLink">
<span class="menu_icon"><i class="material-icons">search</i></span>
<span class="menu_title uk-text-muted ">Search for Research Results</span></a></li>
</ul>

View File

@ -183,6 +183,7 @@ export class IndicatorPath {
chartObject: string;
parameters: any;
filters: any;
filteredApplied: boolean = false;
constructor(type: IndicatorPathType, source: SourceType, url: string, chartObject: string, jsonPath: string[]) {
this.type = type;
@ -192,6 +193,7 @@ export class IndicatorPath {
this.chartObject = chartObject;
this.parameters = {};
this.filters = {};
this.filteredApplied = false;
}
static createParameters(funderName: string = null, title: string = null, chartType: string = null): any {
@ -201,12 +203,55 @@ export class IndicatorPath {
type: chartType
};
}
static createResultFilters(dbType: string = null): any {
return {
fundingL0: '{"groupFilters":[{"field":"' + dbType + '.project.funding level 0","type":"=","values":["' + ChartHelper.prefix + 'fundingL0' + ChartHelper.suffix + '"]}],"op":"AND"}',
start_year: '{"groupFilters":[{"field":"' + dbType + '.year","type":">=","values":["' + ChartHelper.prefix + 'start_year' + ChartHelper.suffix + '"]}],"op":"AND"}',
end_year: '{"groupFilters":[{"field":"' + dbType + '.year","type":"<=","values":["' + ChartHelper.prefix + 'end_year' + ChartHelper.suffix + '"]}],"op":"AND"}'
};
}
export type FilterType = "fundingL0"|"start_year" | "end_year";
export class IndicatorFilterUtils{
static getFilter(field: string, filterType:FilterType) {
if(["publication", "software", "dataset", "other", "result"].indexOf(field)!=-1){
return this.getResultFilter(field,filterType);
}else if (field == "project"){
return this.getProjectFilter(filterType);
}
//TODO add other options
}
static getResultFilter(dbType: string = null, filterType:FilterType) {
if (filterType == "fundingL0") {
return '{"groupFilters":[{"field":"' + dbType + '.project.funding level 0","type":"=","values":["' + ChartHelper.prefix + 'fundingL0' + ChartHelper.suffix + '"]}],"op":"AND"}';
} else if (filterType == "start_year") {
return '{"groupFilters":[{"field":"' + dbType + '.year","type":">=","values":["' + ChartHelper.prefix + 'start_year' + ChartHelper.suffix + '"]}],"op":"AND"}';
} else if (filterType == "end_year") {
return '{"groupFilters":[{"field":"' + dbType + '.year","type":"<=","values":["' + ChartHelper.prefix + 'end_year' + ChartHelper.suffix + '"]}],"op":"AND"}';
}
}
static getProjectFilter( filterType:FilterType) {
if (filterType == "fundingL0") {
return '{"groupFilters":[{"field":"project.funding level 0","type":"=","values":["' + ChartHelper.prefix + 'fundingL0' + ChartHelper.suffix + '"]}],"op":"AND"}';
} else if (filterType == "start_year") {
return '{"groupFilters":[{"field":"project.start year","type":">=","values":["' + ChartHelper.prefix + 'start_year' + ChartHelper.suffix + '"]}],"op":"AND"}';
} else if (filterType == "end_year") {
return '{"groupFilters":[{"field":"project.start year","type":"<=","values":["' + ChartHelper.prefix + 'end_year' + ChartHelper.suffix + '"]}],"op":"AND"}';
}
}
static getOrganizationFilter( filterType:FilterType) {
if (filterType == "fundingL0") {
return '';
} else if (filterType == "start_year") {
return '';
} else if (filterType == "end_year") {
return '';
}
}
static filterIndexOf(filterToAdd, currentFilters):any{
for(let fi =0; fi< currentFilters.length; fi++){
for(let gfi =0; gfi< currentFilters[fi]["groupFilters"].length; gfi++ ){
if(currentFilters[fi]["groupFilters"][gfi].field == filterToAdd['groupFilters'][0]['field'] && currentFilters[fi]["groupFilters"][gfi].type == filterToAdd['groupFilters'][0]['type']){
return {"filter":fi, "groupFilter":gfi};
}
}
}
return null;
}
}

View File

@ -4,15 +4,15 @@ export class Dates {
public static yearMin = 1800;
public static yearMax = (new Date().getFullYear()) + 10;
public static currentYear = (new Date().getFullYear());
public static isValidYear(yearString) {
public static isValidYear(yearString, yearMin=this.yearMin, yearMax=this.yearMax) {
// First check for the pattern
if (!/^\d{4}$/.test(yearString))
return false;
var year = parseInt(yearString, 10);
// Check the ranges of month and year
if (year < this.yearMin || year > this.yearMax)
if (year < yearMin || year > yearMax)
return false;
return true;
}