Merge develop-filters into develop branch #25

Merged
konstantina.galouni merged 7 commits from develop-filters into develop 2023-12-15 09:08:00 +01:00
20 changed files with 775 additions and 197 deletions

View File

@ -1,4 +1,4 @@
import {Component, EventEmitter, Input, Output, ViewChild} from '@angular/core'; import {ChangeDetectorRef, Component, EventEmitter, Input, Output, ViewChild} from '@angular/core';
import {ActivatedRoute} from '@angular/router'; import {ActivatedRoute} from '@angular/router';
import {AdvancedField, Filter} from './searchUtils/searchHelperClasses.class'; import {AdvancedField, Filter} from './searchUtils/searchHelperClasses.class';
import {SearchDataprovidersService} from '../services/searchDataproviders.service'; import {SearchDataprovidersService} from '../services/searchDataproviders.service';
@ -11,12 +11,13 @@ import {EnvProperties} from '../utils/properties/env-properties';
import {NewSearchPageComponent, SearchForm} from "./searchUtils/newSearchPage.component"; import {NewSearchPageComponent, SearchForm} from "./searchUtils/newSearchPage.component";
import {DatasourcesHelperClass} from "./searchUtils/datasourcesHelper.class"; import {DatasourcesHelperClass} from "./searchUtils/datasourcesHelper.class";
import {properties} from "../../../environments/environment"; import {properties} from "../../../environments/environment";
import {RefineResultsUtils} from "../services/servicesUtils/refineResults.class";
import {RefineFieldResultsService} from "../services/refineFieldResults.service";
@Component({ @Component({
selector: 'search-dataproviders', selector: 'search-dataproviders',
template: ` template: `
<new-search-page <new-search-page
pageTitle="{{(simpleView?'':'Advanced ')}} Find research {{ pageTitle }}" pageTitle="{{(simpleView?'':'Advanced ')}} Find research {{ pageTitle }}"
[entityType]=entityType [entityType]=entityType
@ -25,6 +26,8 @@ import {properties} from "../../../environments/environment";
[searchUtils]="searchUtils" [searchUtils]="searchUtils"
[sortedByChanged]="searchUtils.sortBy" [sortedByChanged]="searchUtils.sortBy"
[fieldIds]="fieldIds" [fieldIdsMap]="fieldIdsMap" [selectedFields]="selectedFields" [fieldIds]="fieldIds" [fieldIdsMap]="fieldIdsMap" [selectedFields]="selectedFields"
[staticFields]="staticFields" [staticFilters]="staticFilters"
[staticFieldValues]="staticFieldValues"
[csvParams]="csvParams" [csvPath]="csvPath" [csvParams]="csvParams" [csvPath]="csvPath"
[simpleSearchLink]="simpleSearchLink" [advancedSearchLink]="advancedSearchLink" [simpleSearchLink]="simpleSearchLink" [advancedSearchLink]="advancedSearchLink"
[disableForms]="disableForms" [disableForms]="disableForms"
@ -39,7 +42,8 @@ import {properties} from "../../../environments/environment";
[simpleView]="simpleView" formPlaceholderText="Search by name, description, subject..." [simpleView]="simpleView" formPlaceholderText="Search by name, description, subject..."
[showResultCount]="true" [showIndexInfo]="type!='deposit'" [showResultCount]="true" [showIndexInfo]="type!='deposit'"
[tableViewLink]="tableViewLink" [tableViewLink]="tableViewLink"
[sort]="false" [showBreadcrumb]="showBreadcrumb" [basicMetaDescription]="metaDescription"> [sort]="false" [showBreadcrumb]="showBreadcrumb" [basicMetaDescription]="metaDescription"
(filterRequestAll)="filterRequestedAll($event)">
</new-search-page> </new-search-page>
@ -91,7 +95,16 @@ export class SearchDataProvidersComponent {
searchFiltersSub: any; searchFiltersSub: any;
metaDescription = []; metaDescription = [];
constructor (private route: ActivatedRoute, private _searchDataProvidersService: SearchDataprovidersService ) { public staticFields: string[] = [];
public staticFieldValues = this.searchFields.DATASOURCE_STATIC_FIELD_VALUES;
public staticFilters = [];
private refineQuery: string = "";
constructor (private route: ActivatedRoute, private _searchDataProvidersService: SearchDataprovidersService,
private _refineFieldsResultsService: RefineFieldResultsService,
private cdr: ChangeDetectorRef) {
this.results =[]; this.results =[];
this.errorCodes = new ErrorCodes(); this.errorCodes = new ErrorCodes();
this.errorMessages = new ErrorMessagesComponent(); this.errorMessages = new ErrorMessagesComponent();
@ -101,6 +114,9 @@ export class SearchDataProvidersComponent {
} }
ngOnInit() { ngOnInit() {
this.refineFields = DatasourcesHelperClass.getrefineFields(this.type); this.refineFields = DatasourcesHelperClass.getrefineFields(this.type);
this.staticFields = this.entityType == "service" ? this.searchFields.DATASOURCE_STATIC_FIELDS : [];
this.staticFilters = RefineResultsUtils.parse(this.staticFieldValues, this.staticFields, this.entityType, "search", true);
this.pageTitle = DatasourcesHelperClass.getTitle(this.type); this.pageTitle = DatasourcesHelperClass.getTitle(this.type);
this.metaDescription = DatasourcesHelperClass.getDescription(this.type) this.metaDescription = DatasourcesHelperClass.getDescription(this.type)
if(this.showSwitchSearchLink == null){ if(this.showSwitchSearchLink == null){
@ -143,7 +159,7 @@ export class SearchDataProvidersComponent {
this.searchPage.keywordFields = this.searchFields.DEPOSIT_DATASOURCE_KEYWORD_FIELDS; this.searchPage.keywordFields = this.searchFields.DEPOSIT_DATASOURCE_KEYWORD_FIELDS;
this.searchPage.usedBy = "deposit"; this.searchPage.usedBy = "deposit";
} }
this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, [], this.fieldIdsMap,this.customFilter,params, this.entityType); this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, [], this.staticFields, this.fieldIdsMap,this.customFilter,params, this.entityType);
if(refine) { if(refine) {
this._getFilters(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(params), this.searchUtils.page, 0, true, this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad)); this._getFilters(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(params), this.searchUtils.page, 0, true, this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad));
} else { } else {
@ -151,6 +167,8 @@ export class SearchDataProvidersComponent {
} }
this.getResults(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(params), this.searchUtils.page, this.searchUtils.size, refine, this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad)); this.getResults(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(params), this.searchUtils.page, this.searchUtils.size, refine, this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad));
firstLoad = false; firstLoad = false;
this.refineQuery = this.searchPage.getSearchAPIQueryForRangeFields(params)+this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad);
})); }));
} }
ngOnDestroy() { ngOnDestroy() {
@ -172,7 +190,7 @@ export class SearchDataProvidersComponent {
this.searchPageUpdates.emit({disableForms: this.disableForms, disableRefineForms: this.disableRefineForms, searchUtils: this.searchUtils}); this.searchPageUpdates.emit({disableForms: this.disableForms, disableRefineForms: this.disableRefineForms, searchUtils: this.searchUtils});
let datasourceQueryPrefix = DatasourcesHelperClass.getQueryPrefix(this.type); let datasourceQueryPrefix = DatasourcesHelperClass.getQueryPrefix(this.type);
this.searchFiltersSub = this._searchDataProvidersService.advancedSearchDataproviders( datasourceQueryPrefix +(datasourceQueryPrefix.length > 0 && parameters.length > 0 ?' and (':'') + parameters +(datasourceQueryPrefix.length > 0 && parameters.length > 0 ?' ) ':''), page, size, this.properties, (refine /*&& (this.type=="all" || this.type == "deposit")*/) ? this.searchPage.getRefineFieldsQuery() : null, this.searchPage.getFields(), refineFieldsFilterQuery, (this.type == "deposit")) this.searchFiltersSub = this._searchDataProvidersService.advancedSearchDataproviders( datasourceQueryPrefix +(datasourceQueryPrefix.length > 0 && parameters.length > 0 ?' and (':'') + parameters +(datasourceQueryPrefix.length > 0 && parameters.length > 0 ?' ) ':''), page, size, this.properties, (refine /*&& (this.type=="all" || this.type == "deposit")*/) ? this.searchPage.getRefineFieldsQuery() : null, this.searchPage.getFields(), refineFieldsFilterQuery, (this.type == "deposit"), true)
//.switchMap( //.switchMap(
.subscribe( .subscribe(
data => { data => {
@ -182,6 +200,7 @@ export class SearchDataProvidersComponent {
}, },
err => { err => {
this.filters = this.searchPage.prepareFiltersToShow([], 0); this.filters = this.searchPage.prepareFiltersToShow([], 0);
this.staticFilters = this.searchPage.prepareStaticFiltersToShow();
this.handleError("Error getting refine filters for "+OpenaireEntities.DATASOURCES+": ", err); this.handleError("Error getting refine filters for "+OpenaireEntities.DATASOURCES+": ", err);
this.searchUtils.refineStatus = this.errorMessages.getErrorCode(err.status); this.searchUtils.refineStatus = this.errorMessages.getErrorCode(err.status);
@ -196,6 +215,7 @@ export class SearchDataProvidersComponent {
public filtersReturned(refine: boolean, filters: Filter[], totalResults, page: number) { public filtersReturned(refine: boolean, filters: Filter[], totalResults, page: number) {
if (refine) { if (refine) {
this.filters = this.searchPage.prepareFiltersToShow(filters, totalResults); this.filters = this.searchPage.prepareFiltersToShow(filters, totalResults);
this.staticFilters = this.searchPage.prepareStaticFiltersToShow();
} }
this.searchUtils.refineStatus = this.errorCodes.DONE; this.searchUtils.refineStatus = this.errorCodes.DONE;
if(totalResults == 0) { if(totalResults == 0) {
@ -279,7 +299,7 @@ export class SearchDataProvidersComponent {
this.searchUtils.totalResults = totalResults; this.searchUtils.totalResults = totalResults;
this.results = results; this.results = results;
if(!refine) { if(!refine) {
this.searchPage.buildPageURLParameters(this.filters, [], false); this.searchPage.buildPageURLParameters(this.filters, [], this.staticFilters, false);
} }
this.searchPage.hideFilters = false; this.searchPage.hideFilters = false;
@ -316,4 +336,41 @@ export class SearchDataProvidersComponent {
private handleError(message: string, error) { private handleError(message: string, error) {
console.error(OpenaireEntities.DATASOURCES+" advanced Search Page: "+message, error); console.error(OpenaireEntities.DATASOURCES+" advanced Search Page: "+message, error);
} }
public filterRequestedAll(oldFilter: Filter) {
let fieldsStr: string = "&fields=" + oldFilter.filterId+"&refine=true";
this.searchFiltersSub = this._searchDataProvidersService.advancedSearchDataproviders(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), 1, 0, properties, fieldsStr, [oldFilter.filterId], this.refineQuery).subscribe(
// this.searchFiltersSub = this._refineFieldsResultsService.getAllRefineFieldResultsByFieldName(oldFilter.filterId, this.entityType, this.properties, this.refineQuery).subscribe(
res => {
let filter: Filter = res[1][0];
if(filter.values.length == 0) {
filter = oldFilter;
filter.countAllValues = 0;
} else {
filter.countAllValues = filter.values.length;
// console.log(filter);
for (let value of filter.values) {
for (let oldValue of oldFilter.values) {
if (oldValue.id == value.id && oldValue.selected) {
value.selected = true;
break;
}
}
}
}
let index: number = this.filters.findIndex((fltr: Filter) => fltr.filterId == filter.filterId);
filter.isOpen = true;
this.filters[index] = filter;
this.cdr.detectChanges();
},
error => {
let index: number = this.filters.findIndex((fltr: Filter) => fltr.filterId == oldFilter.filterId);
oldFilter.countAllValues = 0;
this.filters[index] = oldFilter;
this.cdr.detectChanges();
}
)
}
} }

View File

@ -1,4 +1,4 @@
import {Component, EventEmitter, Input, Output, ViewChild} from '@angular/core'; import {ChangeDetectorRef, Component, EventEmitter, Input, Output, ViewChild} from '@angular/core';
import {ActivatedRoute} from '@angular/router'; import {ActivatedRoute} from '@angular/router';
import {AdvancedField, Filter} from './searchUtils/searchHelperClasses.class'; import {AdvancedField, Filter} from './searchUtils/searchHelperClasses.class';
import {SearchOrganizationsService} from '../services/searchOrganizations.service'; import {SearchOrganizationsService} from '../services/searchOrganizations.service';
@ -9,6 +9,7 @@ import {SearchCustomFilter, SearchUtilsClass} from './searchUtils/searchUtils.cl
import {EnvProperties} from '../utils/properties/env-properties'; import {EnvProperties} from '../utils/properties/env-properties';
import {NewSearchPageComponent, SearchForm} from "./searchUtils/newSearchPage.component"; import {NewSearchPageComponent, SearchForm} from "./searchUtils/newSearchPage.component";
import {properties} from "../../../environments/environment"; import {properties} from "../../../environments/environment";
import {RefineFieldResultsService} from "../services/refineFieldResults.service";
@Component({ @Component({
@ -36,7 +37,7 @@ import {properties} from "../../../environments/environment";
[simpleView]="simpleView" formPlaceholderText="Search by organization name..." [simpleView]="simpleView" formPlaceholderText="Search by organization name..."
[showSwitchSearchLink]="showSwitchSearchLink" [showSwitchSearchLink]="showSwitchSearchLink"
[showBreadcrumb]="showBreadcrumb" [showBreadcrumb]="showBreadcrumb"
> (filterRequestAll)="filterRequestedAll($event)">
</new-search-page> </new-search-page>
` `
}) })
@ -79,7 +80,11 @@ export class SearchOrganizationsComponent {
searchResultsSub: any; searchResultsSub: any;
searchFiltersSub: any; searchFiltersSub: any;
constructor (private route: ActivatedRoute, private _searchOrganizationsService: SearchOrganizationsService ) { private refineQuery: string = "";
constructor (private route: ActivatedRoute, private _searchOrganizationsService: SearchOrganizationsService,
private _refineFieldsResultsService: RefineFieldResultsService,
private cdr: ChangeDetectorRef) {
this.results =[]; this.results =[];
this.errorCodes = new ErrorCodes(); this.errorCodes = new ErrorCodes();
this.errorMessages = new ErrorMessagesComponent(); this.errorMessages = new ErrorMessagesComponent();
@ -127,7 +132,7 @@ export class SearchOrganizationsComponent {
// this.searchPage.fieldIdsMap = this.fieldIdsMap; // this.searchPage.fieldIdsMap = this.fieldIdsMap;
// this.searchPage.customFilter = this.customFilter; // this.searchPage.customFilter = this.customFilter;
// this.searchPage.getSelectedFiltersFromUrl(params); // this.searchPage.getSelectedFiltersFromUrl(params);
this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, [], this.fieldIdsMap,this.customFilter,params, "organization"); this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, [], [], this.fieldIdsMap,this.customFilter,params, "organization");
if(refine) { if(refine) {
this._getFilters(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, 0, true, this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad)); this._getFilters(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, 0, true, this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad));
} else { } else {
@ -135,6 +140,8 @@ export class SearchOrganizationsComponent {
} }
this.getResults(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, this.searchUtils.size, refine, this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad)); this.getResults(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, this.searchUtils.size, refine, this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad));
firstLoad = false; firstLoad = false;
this.refineQuery = this.searchPage.getSearchAPIQueryForRangeFields(params)+this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad);
})); }));
} }
ngOnDestroy() { ngOnDestroy() {
@ -154,7 +161,7 @@ export class SearchOrganizationsComponent {
this.searchUtils.refineStatus = this.errorCodes.LOADING; this.searchUtils.refineStatus = this.errorCodes.LOADING;
this.disableRefineForms = true; this.disableRefineForms = true;
this.searchPageUpdates.emit({disableForms: this.disableForms, disableRefineForms: this.disableRefineForms, searchUtils: this.searchUtils}); this.searchPageUpdates.emit({disableForms: this.disableForms, disableRefineForms: this.disableRefineForms, searchUtils: this.searchUtils});
this.searchFiltersSub = this._searchOrganizationsService.advancedSearchOrganizations(parameters, page, size, this.properties,(refine) ? this.searchPage.getRefineFieldsQuery() : null, this.searchPage.getFields(), refineFieldsFilterQuery) this.searchFiltersSub = this._searchOrganizationsService.advancedSearchOrganizations(parameters, page, size, this.properties,(refine) ? this.searchPage.getRefineFieldsQuery() : null, this.searchPage.getFields(), refineFieldsFilterQuery, true)
//.switchMap( //.switchMap(
.subscribe( .subscribe(
data => { data => {
@ -271,7 +278,7 @@ export class SearchOrganizationsComponent {
this.searchUtils.totalResults = totalResults; this.searchUtils.totalResults = totalResults;
this.results = results; this.results = results;
if(!refine) { if(!refine) {
this.searchPage.buildPageURLParameters(this.filters, [], false); this.searchPage.buildPageURLParameters(this.filters, [], [], false);
} }
this.searchPage.hideFilters = false; this.searchPage.hideFilters = false;
@ -308,4 +315,41 @@ export class SearchOrganizationsComponent {
private handleError(message: string, error) { private handleError(message: string, error) {
console.error("Organizations advanced Search Page: "+message, error); console.error("Organizations advanced Search Page: "+message, error);
} }
public filterRequestedAll(oldFilter: Filter) {
let fieldsStr: string = "&fields=" + oldFilter.filterId+"&refine=true";
this.searchFiltersSub = this._searchOrganizationsService.advancedSearchOrganizations(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), 1, 0, properties, fieldsStr, [oldFilter.filterId], this.refineQuery).subscribe(
// this.searchFiltersSub = this._refineFieldsResultsService.getAllRefineFieldResultsByFieldName(oldFilter.filterId, "organization", this.properties, this.refineQuery).subscribe(
res => {
let filter: Filter = res[1][0];
if(filter.values.length == 0) {
filter = oldFilter;
filter.countAllValues = 0;
} else {
filter.countAllValues = filter.values.length;
// console.log(filter);
for (let value of filter.values) {
for (let oldValue of oldFilter.values) {
if (oldValue.id == value.id && oldValue.selected) {
value.selected = true;
break;
}
}
}
}
let index: number = this.filters.findIndex((fltr: Filter) => fltr.filterId == filter.filterId);
filter.isOpen = true;
this.filters[index] = filter;
this.cdr.detectChanges();
},
error => {
let index: number = this.filters.findIndex((fltr: Filter) => fltr.filterId == oldFilter.filterId);
oldFilter.countAllValues = 0;
this.filters[index] = oldFilter;
this.cdr.detectChanges();
}
)
}
} }

View File

@ -1,4 +1,4 @@
import {Component, EventEmitter, Input, Output, ViewChild} from '@angular/core'; import {ChangeDetectorRef, Component, EventEmitter, Input, Output, ViewChild} from '@angular/core';
import {ActivatedRoute} from '@angular/router'; import {ActivatedRoute} from '@angular/router';
import {AdvancedField, Filter} from './searchUtils/searchHelperClasses.class'; import {AdvancedField, Filter} from './searchUtils/searchHelperClasses.class';
import {SearchProjectsService} from '../services/searchProjects.service'; import {SearchProjectsService} from '../services/searchProjects.service';
@ -10,6 +10,7 @@ import {EnvProperties} from '../utils/properties/env-properties';
import {NewSearchPageComponent, SearchForm} from "./searchUtils/newSearchPage.component"; import {NewSearchPageComponent, SearchForm} from "./searchUtils/newSearchPage.component";
import {RangeFilter} from "../utils/rangeFilter/rangeFilterHelperClasses.class"; import {RangeFilter} from "../utils/rangeFilter/rangeFilterHelperClasses.class";
import {properties} from "../../../environments/environment"; import {properties} from "../../../environments/environment";
import {RefineFieldResultsService} from "../services/refineFieldResults.service";
@Component({ @Component({
selector: 'search-projects', selector: 'search-projects',
@ -36,7 +37,7 @@ import {properties} from "../../../environments/environment";
[simpleView]="simpleView" formPlaceholderText="Search by title, acronym, project code..." [simpleView]="simpleView" formPlaceholderText="Search by title, acronym, project code..."
[showSwitchSearchLink]="showSwitchSearchLink" [showSwitchSearchLink]="showSwitchSearchLink"
[sort]="false" [showBreadcrumb]="showBreadcrumb" [sort]="false" [showBreadcrumb]="showBreadcrumb"
> (filterRequestAll)="filterRequestedAll($event)">
</new-search-page> </new-search-page>
` `
@ -83,7 +84,11 @@ export class SearchProjectsComponent {
searchResultsSub: any; searchResultsSub: any;
searchFiltersSub: any; searchFiltersSub: any;
constructor(private route: ActivatedRoute, private _searchProjectsService: SearchProjectsService) { private refineQuery: string = "";
constructor(private route: ActivatedRoute, private _searchProjectsService: SearchProjectsService,
private _refineFieldsResultsService: RefineFieldResultsService,
private cdr: ChangeDetectorRef) {
this.results = []; this.results = [];
this.errorCodes = new ErrorCodes(); this.errorCodes = new ErrorCodes();
this.errorMessages = new ErrorMessagesComponent(); this.errorMessages = new ErrorMessagesComponent();
@ -128,7 +133,7 @@ export class SearchProjectsComponent {
this.searchPage.fieldIds = this.fieldIds; this.searchPage.fieldIds = this.fieldIds;
this.selectedFields = []; this.selectedFields = [];
this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, this.rangeFields, this.fieldIdsMap, this.customFilter, params, "project"); this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, this.rangeFields, [], this.fieldIdsMap, this.customFilter, params, "project");
if (refine) { if (refine) {
this._getFilters(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, 0, "", true, this.searchPage.getSearchAPIQueryForRangeFields(params) + this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad)); this._getFilters(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, 0, "", true, this.searchPage.getSearchAPIQueryForRangeFields(params) + this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad));
} else { } else {
@ -136,6 +141,8 @@ export class SearchProjectsComponent {
} }
this.getResults(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, this.searchUtils.size, refine, this.searchPage.getSearchAPIQueryForRangeFields(params) + this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad)); this.getResults(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, this.searchUtils.size, refine, this.searchPage.getSearchAPIQueryForRangeFields(params) + this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad));
firstLoad = false; firstLoad = false;
this.refineQuery = this.searchPage.getSearchAPIQueryForRangeFields(params)+this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad);
})); }));
} }
@ -160,7 +167,7 @@ export class SearchProjectsComponent {
disableRefineForms: this.disableRefineForms, disableRefineForms: this.disableRefineForms,
searchUtils: this.searchUtils searchUtils: this.searchUtils
}); });
this.searchFiltersSub = this._searchProjectsService.advancedSearchProjects(parameters, page, size, this.properties, (refine) ? this.searchPage.getRefineFieldsQuery() : null, this.searchPage.getFields(), refineFieldsFilterQuery) this.searchFiltersSub = this._searchProjectsService.advancedSearchProjects(parameters, page, size, this.properties, (refine) ? this.searchPage.getRefineFieldsQuery() : null, this.searchPage.getFields(), refineFieldsFilterQuery, true)
//.switchMap( //.switchMap(
.subscribe( .subscribe(
data => { data => {
@ -297,7 +304,7 @@ export class SearchProjectsComponent {
this.searchUtils.totalResults = totalResults; this.searchUtils.totalResults = totalResults;
this.results = results; this.results = results;
if (!refine) { if (!refine) {
this.searchPage.buildPageURLParameters(this.filters, this.rangeFilters, false); this.searchPage.buildPageURLParameters(this.filters, this.rangeFilters, [], false);
} }
this.searchPage.hideFilters = false; this.searchPage.hideFilters = false;
@ -337,4 +344,41 @@ export class SearchProjectsComponent {
private handleError(message: string, error) { private handleError(message: string, error) {
console.error("Projects advanced Search Page: " + message, error); console.error("Projects advanced Search Page: " + message, error);
} }
public filterRequestedAll(oldFilter: Filter) {
let fieldsStr: string = "&fields=" + oldFilter.filterId+"&refine=true";
this.searchFiltersSub = this._searchProjectsService.advancedSearchProjects(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), 1, 0, properties, fieldsStr, [oldFilter.filterId], this.refineQuery).subscribe(
// this.searchFiltersSub = this._refineFieldsResultsService.getAllRefineFieldResultsByFieldName(oldFilter.filterId, "project", this.properties, this.refineQuery).subscribe(
res => {
let filter: Filter = res[1][0];
if(filter.values.length == 0) {
filter = oldFilter;
filter.countAllValues = 0;
} else {
filter.countAllValues = filter.values.length;
// console.log(filter);
for (let value of filter.values) {
for (let oldValue of oldFilter.values) {
if (oldValue.id == value.id && oldValue.selected) {
value.selected = true;
break;
}
}
}
}
let index: number = this.filters.findIndex((fltr: Filter) => fltr.filterId == filter.filterId);
filter.isOpen = true;
this.filters[index] = filter;
this.cdr.detectChanges();
},
error => {
let index: number = this.filters.findIndex((fltr: Filter) => fltr.filterId == oldFilter.filterId);
oldFilter.countAllValues = 0;
this.filters[index] = oldFilter;
this.cdr.detectChanges();
}
)
}
} }

View File

@ -1,4 +1,4 @@
import {Component, EventEmitter, Input, Output, ViewChild} from '@angular/core'; import {ChangeDetectorRef, Component, EventEmitter, Input, Output, ViewChild} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router';
import {AdvancedField, Filter} from './searchUtils/searchHelperClasses.class'; import {AdvancedField, Filter} from './searchUtils/searchHelperClasses.class';
import {SearchResearchResultsService} from '../services/searchResearchResults.service'; import {SearchResearchResultsService} from '../services/searchResearchResults.service';
@ -12,6 +12,8 @@ import {RangeFilter} from "../utils/rangeFilter/rangeFilterHelperClasses.class";
import {properties} from "../../../environments/environment"; import {properties} from "../../../environments/environment";
import {ContextsService} from "../claims/claim-utils/service/contexts.service"; import {ContextsService} from "../claims/claim-utils/service/contexts.service";
import {StringUtils} from "../utils/string-utils.class"; import {StringUtils} from "../utils/string-utils.class";
import {RefineResultsUtils} from "../services/servicesUtils/refineResults.class";
import {RefineFieldResultsService} from "../services/refineFieldResults.service";
@Component({ @Component({
selector: 'search-research-results', selector: 'search-research-results',
@ -24,6 +26,8 @@ import {StringUtils} from "../utils/string-utils.class";
[searchUtils]="searchUtils" [searchUtils]="searchUtils"
[sortedByChanged]="searchUtils.sortBy" [sortedByChanged]="searchUtils.sortBy"
[fieldIds]="fieldIds" [fieldIdsMap]="fieldIdsMap" [selectedFields]="selectedFields" [fieldIds]="fieldIds" [fieldIdsMap]="fieldIdsMap" [selectedFields]="selectedFields"
[staticFields]="staticFields" [staticFilters]="staticFilters"
[staticFieldValues]="staticFieldValues"
[csvParams]="csvParams" [csvPath]="getEntityFileName(resultType)" [csvParams]="csvParams" [csvPath]="getEntityFileName(resultType)"
[simpleSearchLink]="simpleSearchLink" [advancedSearchLink]="advancedSearchLink" [simpleSearchLink]="simpleSearchLink" [advancedSearchLink]="advancedSearchLink"
[disableForms]="disableForms" [disableForms]="disableForms"
@ -34,10 +38,12 @@ import {StringUtils} from "../utils/string-utils.class";
[searchForm]="searchForm" [searchForm]="searchForm"
[filters]="filters" [quickFilter]="quickFilter" [filters]="filters" [quickFilter]="quickFilter"
[rangeFilters]="rangeFilters" [rangeFields]="rangeFields" [rangeFilters]="rangeFilters" [rangeFields]="rangeFields"
[orderedFilters]="orderedFilters"
[simpleView]="simpleView" formPlaceholderText="Search by title, author, abstract, DOI, orcid..." [simpleView]="simpleView" formPlaceholderText="Search by title, author, abstract, DOI, orcid..."
[includeOnlyResultsAndFilter]="includeOnlyResultsAndFilter" [showBreadcrumb]="showBreadcrumb" [includeOnlyResultsAndFilter]="includeOnlyResultsAndFilter" [showBreadcrumb]="showBreadcrumb"
[showSwitchSearchLink]="showSwitchSearchLink" [showSwitchSearchLink]="showSwitchSearchLink"
[stickyForm]="stickyForm" [stickyForm]="stickyForm"
(filterRequestAll)="filterRequestedAll($event)"
> >
</new-search-page> </new-search-page>
` `
@ -64,6 +70,12 @@ export class SearchResearchResultsComponent {
public fieldIdsMap = this.searchFields.RESULT_FIELDS; public fieldIdsMap = this.searchFields.RESULT_FIELDS;
public rangeFields: string[][] = this.searchFields.RESULT_RANGE_FIELDS; public rangeFields: string[][] = this.searchFields.RESULT_RANGE_FIELDS;
public selectedFields: AdvancedField[] = []; public selectedFields: AdvancedField[] = [];
public staticFields: string[] = this.searchFields.RESULT_STATIC_FIELDS;
public staticFieldValues = this.searchFields.RESULT_STATIC_FIELD_VALUES;
public staticFilters = RefineResultsUtils.parse(this.staticFieldValues, this.staticFields, this.resultType, "search", true);
public orderedFilters;
public resourcesQuery = "((oaftype exact result) and (resulttypeid exact " + this.resultType + "))"; public resourcesQuery = "((oaftype exact result) and (resulttypeid exact " + this.resultType + "))";
public csvParams: string; public csvParams: string;
public disableForms: boolean = false; public disableForms: boolean = false;
@ -76,6 +88,7 @@ export class SearchResearchResultsComponent {
properties: EnvProperties = properties; properties: EnvProperties = properties;
public openaireEntities = OpenaireEntities; public openaireEntities = OpenaireEntities;
public refineFields: string[] = this.searchFields.RESULT_REFINE_FIELDS; public refineFields: string[] = this.searchFields.RESULT_REFINE_FIELDS;
public orderedFields = this.searchFields.RESULT_FIELDS_ORDERED;
@ViewChild(NewSearchPageComponent, { static: true }) searchPage: NewSearchPageComponent; @ViewChild(NewSearchPageComponent, { static: true }) searchPage: NewSearchPageComponent;
@Input() simpleView: boolean = true; @Input() simpleView: boolean = true;
quickFilter: { filter: Filter, selected: boolean, filterId: string, value: string } = { quickFilter: { filter: Filter, selected: boolean, filterId: string, value: string } = {
@ -101,9 +114,13 @@ export class SearchResearchResultsComponent {
@Input() orcidQuery: string = ""; @Input() orcidQuery: string = "";
@Input() identifiers: string[] = []; @Input() identifiers: string[] = [];
private refineQuery: string = "";
constructor(private route: ActivatedRoute, private _router: Router, constructor(private route: ActivatedRoute, private _router: Router,
private _searchResearchResultsService: SearchResearchResultsService, private _searchResearchResultsService: SearchResearchResultsService,
private _contextService: ContextsService) { private _refineFieldsResultsService: RefineFieldResultsService,
private _contextService: ContextsService,
private cdr: ChangeDetectorRef) {
this.results = []; this.results = [];
this.errorCodes = new ErrorCodes(); this.errorCodes = new ErrorCodes();
this.errorMessages = new ErrorMessagesComponent(); this.errorMessages = new ErrorMessagesComponent();
@ -166,8 +183,7 @@ export class SearchResearchResultsComponent {
this.searchUtils.sortBy = ""; this.searchUtils.sortBy = "";
} }
this.selectedFields = []; this.selectedFields = [];
this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, this.rangeFields, this.staticFields, this.fieldIdsMap,this.customFilter,params, this.resultType, this.quickFilter);
this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, this.rangeFields, this.fieldIdsMap,this.customFilter,params, this.resultType, this.quickFilter);
if(refine) { if(refine) {
this._getFilters(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, 0, "", true, this.searchPage.getSearchAPIQueryForRangeFields(params)+this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad)); this._getFilters(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, 0, "", true, this.searchPage.getSearchAPIQueryForRangeFields(params)+this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad));
} else { } else {
@ -175,6 +191,8 @@ export class SearchResearchResultsComponent {
} }
this._getResults(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, this.searchUtils.size, this.searchUtils.sortBy, refine, this.searchPage.getSearchAPIQueryForRangeFields(params) + this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad)); this._getResults(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, this.searchUtils.size, this.searchUtils.sortBy, refine, this.searchPage.getSearchAPIQueryForRangeFields(params) + this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad));
firstLoad = false; firstLoad = false;
this.refineQuery = this.searchPage.getSearchAPIQueryForRangeFields(params)+this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad);
})); }));
} }
@ -226,7 +244,7 @@ export class SearchResearchResultsComponent {
this.searchUtils.refineStatus = this.errorCodes.LOADING; this.searchUtils.refineStatus = this.errorCodes.LOADING;
this.disableRefineForms = true; this.disableRefineForms = true;
this.searchPageUpdates.emit({disableForms: this.disableForms, disableRefineForms: this.disableRefineForms, searchUtils: this.searchUtils}); this.searchPageUpdates.emit({disableForms: this.disableForms, disableRefineForms: this.disableRefineForms, searchUtils: this.searchUtils});
this.searchFiltersSub = this._searchResearchResultsService.advancedSearchResults(this.resultType, parameters, page, size, sortBy, this.properties, (refine) ? this.searchPage.getRefineFieldsQuery() : null, this.searchPage.getFields(), refineFieldsFilterQuery) this.searchFiltersSub = this._searchResearchResultsService.advancedSearchResults(this.resultType, parameters, page, size, sortBy, this.properties, (refine) ? this.searchPage.getRefineFieldsQuery() : null, this.searchPage.getFields(), refineFieldsFilterQuery, true)
// this.subs.push(this._searchResearchResultsService.advancedSearchResults(this.resultType, parameters, page, size, sortBy, this.properties, (refine) ? this.searchPage.getRefineFieldsQuery() : null, this.searchPage.getFields(), refineFieldsFilterQuery) // this.subs.push(this._searchResearchResultsService.advancedSearchResults(this.resultType, parameters, page, size, sortBy, this.properties, (refine) ? this.searchPage.getRefineFieldsQuery() : null, this.searchPage.getFields(), refineFieldsFilterQuery)
//.switchMap( //.switchMap(
.subscribe( .subscribe(
@ -248,6 +266,7 @@ export class SearchResearchResultsComponent {
err => { err => {
this.filters = this.searchPage.prepareFiltersToShow([], 0); this.filters = this.searchPage.prepareFiltersToShow([], 0);
this.rangeFilters = this.searchPage.prepareRangeFiltersToShow(); this.rangeFilters = this.searchPage.prepareRangeFiltersToShow();
this.staticFilters = this.searchPage.prepareStaticFiltersToShow();
this.handleError("Error getting refine filters for " + this.getEntityName(this.resultType, true, true), err); this.handleError("Error getting refine filters for " + this.getEntityName(this.resultType, true, true), err);
this.searchUtils.refineStatus = this.errorMessages.getErrorCode(err.status); this.searchUtils.refineStatus = this.errorMessages.getErrorCode(err.status);
@ -292,6 +311,45 @@ export class SearchResearchResultsComponent {
if (refine) { if (refine) {
this.filters = this.searchPage.prepareFiltersToShow(filters, totalResults); this.filters = this.searchPage.prepareFiltersToShow(filters, totalResults);
this.rangeFilters = this.searchPage.prepareRangeFiltersToShow(); this.rangeFilters = this.searchPage.prepareRangeFiltersToShow();
this.staticFilters = this.searchPage.prepareStaticFiltersToShow();
if(this.orderedFields) {
this.orderedFilters = [];
for(let group of this.orderedFields) {
if (group.type == "refine") {
let groupedFilters = {title: group.title, values: []};
for (let field of group.values) {
let index = this.filters.findIndex(filter => filter.filterId == field);
if (index > -1) {
groupedFilters.values.push(this.filters[index]);
}
}
if (groupedFilters.values.length > 0) {
this.orderedFilters.push(groupedFilters);
}
} else if (group.type == "range") {
let groupedFilters = {title: group.title, values: []};
let from = group.values[0];
let to = group.values[1];
let index = this.rangeFilters.findIndex(filter => filter.originalFilterIdFrom == from && filter.originalFilterIdTo == to);
if (index > -1) {
groupedFilters.values.push(this.rangeFilters[index]);
this.orderedFilters.push(groupedFilters);
}
} else if (group.type == "static") {
let groupedFilters = {title: group.title, values: []};
for (let field of group.values) {
let index = this.staticFilters.findIndex(filter => filter.filterId == field);
if (index > -1) {
groupedFilters.values.push(this.staticFilters[index]);
}
}
if (groupedFilters.values.length > 0) {
this.orderedFilters.push(groupedFilters);
}
}
}
}
} }
this.searchUtils.refineStatus = this.errorCodes.DONE; this.searchUtils.refineStatus = this.errorCodes.DONE;
@ -399,7 +457,7 @@ export class SearchResearchResultsComponent {
this.searchUtils.totalResults = totalResults; this.searchUtils.totalResults = totalResults;
this.results = results; this.results = results;
if(!refine) { if(!refine) {
this.searchPage.buildPageURLParameters(this.filters, this.rangeFilters, false); this.searchPage.buildPageURLParameters(this.filters, this.rangeFilters, this.staticFilters, false);
} }
this.searchPage.hideFilters = false; this.searchPage.hideFilters = false;
@ -443,4 +501,62 @@ export class SearchResearchResultsComponent {
public getEntityFileName(entityType: string) { public getEntityFileName(entityType: string) {
return StringUtils.getEntityFileName(entityType); return StringUtils.getEntityFileName(entityType);
} }
public filterRequestedAll(oldFilter: Filter) {
let fieldsStr: string = "&fields=" + oldFilter.filterId+"&refine=true";
this.searchFiltersSub = this._searchResearchResultsService.advancedSearchResults(this.resultType, this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), 1, 0, null, properties, fieldsStr, [oldFilter.filterId], this.refineQuery).subscribe(
// this.searchFiltersSub = this._refineFieldsResultsService.getAllRefineFieldResultsByFieldName(oldFilter.filterId, this.resultType, this.properties, this.refineQuery).subscribe(
res => {
// let filter: Filter = res[1][0];
let filter: Filter = res[2][0];
if(filter.values.length == 0) {
filter = oldFilter;
filter.countAllValues = 0;
} else {
filter.countAllValues = filter.values.length;
for (let value of filter.values) {
for (let oldValue of oldFilter.values) {
if (oldValue.id == value.id && oldValue.selected) {
value.selected = true;
break;
}
}
}
}
let index: number = this.filters.findIndex((fltr: Filter) => fltr.filterId == filter.filterId);
filter.isOpen = true;
filter.countSelectedValues = oldFilter.countSelectedValues;
filter.radioValue = oldFilter.radioValue;
this.filters[index] = filter;
this.updateOrderedFilter(filter);
this.cdr.detectChanges();
},
error => {
let index: number = this.filters.findIndex((fltr: Filter) => fltr.filterId == oldFilter.filterId);
oldFilter.countAllValues = 0;
this.filters[index] = oldFilter;
this.updateOrderedFilter(oldFilter);
this.cdr.detectChanges();
}
)
}
public updateOrderedFilter(filter: Filter) {
if(this.orderedFilters) {
let groupIndex = 0;
let index;
for(let group of this.orderedFilters) {
index = group.values.findIndex((fltr: Filter) => fltr.filterId == filter.filterId);
if(index != -1) {
break;
}
groupIndex++;
}
this.orderedFilters[groupIndex].values[index] = filter;
}
}
} }

View File

@ -59,8 +59,9 @@
(listUpdated)="listUpdated($event,selectedField.id)" (listUpdated)="listUpdated($event,selectedField.id)"
[id]="'autocomplete-'+i"></static-autocomplete> [id]="'autocomplete-'+i"></static-autocomplete>
</td> </td>
<td *ngIf=" selectedField.id && selectedField.type == 'refine'" class="uk-width-1-3"> <td *ngIf=" selectedField.id && (selectedField.type == 'refine' || selectedField.type == 'static')" class="uk-width-1-3">
<static-autocomplete [properties]=properties [list]=this.fieldList[selectedField.id] <static-autocomplete [properties]=properties [list]=this.fieldList[selectedField.id]
[fieldValues]="getFieldValuesForId(selectedField.id)"
[fieldId]=selectedField.id [entityName]="entityType" [fieldName]=[selectedField.id] [fieldId]=selectedField.id [entityName]="entityType" [fieldName]=[selectedField.id]
[selectedValue]=selectedField.value [showSelected]=true [selectedValue]=selectedField.value [showSelected]=true
[placeHolderMessage]="'Search for '+selectedField.name" [title]="selectedField.name" [placeHolderMessage]="'Search for '+selectedField.name" [title]="selectedField.name"

View File

@ -27,6 +27,7 @@ import {Option} from "../../sharedComponents/input/input.component";
export class AdvancedSearchFormComponent implements OnInit, OnDestroy, OnChanges { export class AdvancedSearchFormComponent implements OnInit, OnDestroy, OnChanges {
@ViewChild("container") container; @ViewChild("container") container;
@Input() entityType; @Input() entityType;
@Input() fieldValues;
@Input() fieldIds: string[]; @Input() fieldIds: string[];
@Input() fieldIdsMap; @Input() fieldIdsMap;
public fieldIdsOptions: Option[] = []; public fieldIdsOptions: Option[] = [];
@ -217,4 +218,13 @@ export class AdvancedSearchFormComponent implements OnInit, OnDestroy, OnChanges
onlyIncludesSupported(index: number) { onlyIncludesSupported(index: number) {
return (this.selectedFields[index] && this.selectedFields[index].operatorId === 'or') || (this.selectedFields[index+1] && this.selectedFields[index+1].operatorId === 'or') return (this.selectedFields[index] && this.selectedFields[index].operatorId === 'or') || (this.selectedFields[index+1] && this.selectedFields[index+1].operatorId === 'or')
} }
public getFieldValuesForId(id: string) {
if(this.fieldValues[id]) {
let obj = {};
obj[id] = this.fieldValues[id];
return obj;
}
return null;
}
} }

View File

@ -41,6 +41,28 @@
</ng-container> </ng-container>
</ng-container> </ng-container>
</ng-container> </ng-container>
<ng-container *ngFor="let filter of staticFilters">
<ng-container *ngIf="filter.countSelectedValues > 0">
<ng-container *ngFor="let value of getSelectedValues(filter); let i = index; let end = last; ">
<li *ngIf="!customFilter || (customFilter.isHiddenFilter && customFilter.valueId != value.id)"
class="">
<span class="uk-label uk-label-primary uk-flex uk-flex-middle">
<span
class="uk-margin-small-right uk-width-expand uk-text-truncate">
<span *ngIf="filter.type && filter.type == 'boolean' else noboolean">{{filter.title}}:
{{value.name=='true'?'Yes':'No'}}
</span>
<ng-template #noboolean>
{{value.name}}
</ng-template></span>
<button [class.uk-disabled]="disabled" (click)="removeFilter(value, filter)" class="uk-close uk-icon" [disabled]="disabled">
<icon name="close" flex="true" ratio="0.7"></icon>
</button>
</span>
</li>
</ng-container>
</ng-container>
</ng-container>
<ng-container *ngFor="let filter of filters "> <ng-container *ngFor="let filter of filters ">
<ng-container *ngIf="filter.countSelectedValues > 0"> <ng-container *ngIf="filter.countSelectedValues > 0">
<ng-container *ngFor="let value of getSelectedValues(filter); let i = index; let end = last; "> <ng-container *ngFor="let value of getSelectedValues(filter); let i = index; let end = last; ">
@ -72,11 +94,12 @@
</h1> </h1>
</ng-template> </ng-template>
<ng-template #search_filter let-filter="filter"> <ng-template #search_filter let-filter="filter" let-showResultCount="showResultCount">
<search-filter [filterValuesNum]="filterValuesNum" [showMoreInline]="showMoreFilterValuesInline" <search-filter [filterValuesNum]="filterValuesNum" [showMoreInline]="showMoreFilterValuesInline"
[isDisabled]="disabled" [isDisabled]="disabled"
[filter]="filter" [showResultCount]=showResultCount [filter]="filter" [showResultCount]=showResultCount
(onFilterChange)="filterChanged($event)" (onFilterChange)="filterChanged($event)"
(onFilterToggle)="filterToggled($event)"
[actionRoute]="true"></search-filter> [actionRoute]="true"></search-filter>
</ng-template> </ng-template>
@ -84,7 +107,7 @@
<div [class.filterLoading]="disabled"> <div [class.filterLoading]="disabled">
<div class="uk-flex uk-flex-middle"> <div class="uk-flex uk-flex-middle">
<h4 class="uk-margin-right uk-margin-remove-bottom">Filters</h4> <h4 class="uk-margin-right uk-margin-remove-bottom">Filters</h4>
<a *ngIf="(selectedRangeFilters + selectedFilters + selectedTypesNum)>0" <a *ngIf="(selectedRangeFilters + selectedFilters + selectedStaticFilters + selectedTypesNum)>0"
(click)="clearFilters()" class="uk-text-small" (click)="clearFilters()" class="uk-text-small"
[class.uk-disabled]="disabled" [class.uk-link-muted]="disabled"> [class.uk-disabled]="disabled" [class.uk-link-muted]="disabled">
Clear All Clear All
@ -100,43 +123,64 @@
<span *ngIf="searchUtils.refineStatus != errorCodes.NONE" class="uk-text-warning">Filters temporarily unavailable. Please try again later.</span> <span *ngIf="searchUtils.refineStatus != errorCodes.NONE" class="uk-text-warning">Filters temporarily unavailable. Please try again later.</span>
</div> </div>
<ul *ngIf="!showUnknownFilters" class="uk-list uk-list-xlarge"> <ul *ngIf="!showUnknownFilters" class="uk-list uk-list-xlarge">
<li *ngIf="filters.length > 0 && getFilterById('resultbestaccessright') && getFilterById('resultbestaccessright').values.length >0"> <ng-container *ngIf="orderedFilters && orderedFilters.length > 0">
<ng-container *ngTemplateOutlet="search_filter; context: {filter: getFilterById('resultbestaccessright')}"></ng-container> <ng-container *ngFor="let group of orderedFilters">
</li> <h5 *ngIf="group.title" class="uk-h5">{{group.title}}</h5>
<li *ngIf="resultTypes && (filters.length > 0)"> <ng-container *ngFor="let filter of group.values">
<quick-selections [resultTypes]="resultTypes" (typeChange)="queryChanged($event)" <li *ngIf="filter.originalFilterIdFrom && filter.originalFilterIdTo; else refineBlock">
[isDisabled]="disabled" [vertical]="true" <range-filter [isDisabled]="disabled" [filter]="filter"
[actionRoute]="true"> (onFilterChange)="filterChanged($event)" [actionRoute]="true"></range-filter>
</quick-selections> </li>
</li> <ng-template #refineBlock>
<li *ngIf="filters.length > 0 && getFilterById('instancetypename') && getFilterById('instancetypename').values.length >0"> <li *ngIf="filter.values && filter.values.length > 0">
<ng-container *ngTemplateOutlet="search_filter; context: {filter: getFilterById('instancetypename')}"></ng-container> <ng-container *ngTemplateOutlet="search_filter; context: {filter: filter, showResultCount: filter.type!='static'}"></ng-container>
</li> </li>
<ng-container *ngIf="entityType == 'result'"> </ng-template>
<li *ngFor="let filter of rangeFilters"> </ng-container>
<range-filter [isDisabled]="disabled" [filter]="filter" </ng-container>
(onFilterChange)="filterChanged($event)" [actionRoute]="true"></range-filter> </ng-container>
<ng-container *ngIf="!orderedFilters || orderedFilters.length == 0">
<ng-container *ngFor="let filter of staticFilters ">
<li *ngIf="filter.values && filter.values.length > 0">
<ng-container *ngTemplateOutlet="search_filter; context: {filter: filter, showResultCount: false}"></ng-container>
</li>
</ng-container>
<li *ngIf="resultTypes && (filters.length > 0)">
<quick-selections [resultTypes]="resultTypes" (typeChange)="queryChanged($event)"
[isDisabled]="disabled" [vertical]="true"
[actionRoute]="true">
</quick-selections>
</li>
<li *ngIf="filters.length > 0 && getFilterById('instancetypename') && getFilterById('instancetypename').values.length >0">
<ng-container *ngTemplateOutlet="search_filter; context: {filter: getFilterById('instancetypename'), showResultCount: showResultCount}"></ng-container>
</li>
<ng-container *ngIf="entityType == 'result'">
<li *ngFor="let filter of rangeFilters">
<range-filter [isDisabled]="disabled" [filter]="filter"
(onFilterChange)="filterChanged($event)" [actionRoute]="true"></range-filter>
</li>
</ng-container>
<ng-container *ngFor="let filter of filters ">
<li *ngIf="filter.values && filter.values.length > 0
&& filter.filterId != 'resultbestaccessright' && filter.filterId != 'instancetypename' && filter.filterId != 'projectoamandatepublications'">
<!-- <search-filter [filterValuesNum]="filterValuesNum" [showMoreInline]="showMoreFilterValuesInline"-->
<!-- [isDisabled]="disabled"-->
<!-- [filter]="filter" [showResultCount]=showResultCount-->
<!-- (onFilterChange)="filterChanged($event)" [actionRoute]="true"></search-filter>-->
<ng-container *ngTemplateOutlet="search_filter; context: {filter: filter, showResultCount: showResultCount}"></ng-container>
</li>
</ng-container>
<ng-container *ngIf="entityType == 'project'">
<li *ngFor="let filter of rangeFilters">
<range-filter [isDisabled]="disabled" [filter]="filter"
(onFilterChange)="filterChanged($event)" [actionRoute]="true"></range-filter>
</li>
</ng-container>
<li *ngIf="filters.length > 0 && getFilterById('projectoamandatepublications') && getFilterById('projectoamandatepublications').values.length >0">
<ng-container *ngTemplateOutlet="search_filter; context: {filter: getFilterById('projectoamandatepublications'), showResultCount: showResultCount}"></ng-container>
</li> </li>
</ng-container> </ng-container>
<ng-container *ngFor="let filter of filters ">
<li *ngIf="filter.values && filter.values.length > 0
&& filter.filterId != 'resultbestaccessright' && filter.filterId != 'instancetypename' && filter.filterId != 'projectoamandatepublications'">
<!-- <search-filter [filterValuesNum]="filterValuesNum" [showMoreInline]="showMoreFilterValuesInline"-->
<!-- [isDisabled]="disabled"-->
<!-- [filter]="filter" [showResultCount]=showResultCount-->
<!-- (onFilterChange)="filterChanged($event)" [actionRoute]="true"></search-filter>-->
<ng-container *ngTemplateOutlet="search_filter; context: {filter: filter}"></ng-container>
</li>
</ng-container>
<ng-container *ngIf="entityType == 'project'">
<li *ngFor="let filter of rangeFilters">
<range-filter [isDisabled]="disabled" [filter]="filter"
(onFilterChange)="filterChanged($event)" [actionRoute]="true"></range-filter>
</li>
</ng-container>
<li *ngIf="filters.length > 0 && getFilterById('projectoamandatepublications') && getFilterById('projectoamandatepublications').values.length >0">
<ng-container *ngTemplateOutlet="search_filter; context: {filter: getFilterById('projectoamandatepublications')}"></ng-container>
</li>
</ul> </ul>
</div> </div>
</ng-template> </ng-template>
@ -198,6 +242,7 @@
<div [class]="'uk-width-1-1'+(simpleView?' uk-width-auto@m' : '')"><div id="searchImage"></div></div> <div [class]="'uk-width-1-1'+(simpleView?' uk-width-auto@m' : '')"><div id="searchImage"></div></div>
<advanced-search-form class="uk-width-expand uk-padding-remove-vertical" <advanced-search-form class="uk-width-expand uk-padding-remove-vertical"
[entityType]="entityType" [entityType]="entityType"
[fieldValues]="staticFieldValues"
[fieldIds]="fieldIds" [fieldIds]="fieldIds"
[fieldIdsMap]="fieldIdsMap" [fieldIdsMap]="fieldIdsMap"
[selectedFields]="selectedFields" [selectedFields]="selectedFields"

View File

@ -1,11 +1,11 @@
import { import {
ChangeDetectorRef, ChangeDetectorRef,
Component, Component,
ElementRef, Inject, ElementRef, EventEmitter, Inject,
Input, Input,
OnChanges, OnChanges,
OnDestroy, OnDestroy,
OnInit, PLATFORM_ID, OnInit, Output, PLATFORM_ID,
SimpleChanges, SimpleChanges,
ViewChild ViewChild
} from '@angular/core'; } from '@angular/core';
@ -74,17 +74,23 @@ export class NewSearchPageComponent implements OnInit, OnDestroy, OnChanges {
@Input() sortedByChanged: string = ""; @Input() sortedByChanged: string = "";
@Input() searchForm: SearchForm = {class: 'search-form', dark: true}; @Input() searchForm: SearchForm = {class: 'search-form', dark: true};
//From simple: //From simple:
@Input() orderedFilters = [];
@Input() rangeFilters: RangeFilter[] = []; @Input() rangeFilters: RangeFilter[] = [];
@Input() rangeFields: string[][] = []; @Input() rangeFields: string[][] = [];
@Input() refineFields = []; @Input() refineFields = [];
@Input() filters: Filter[] = []; @Input() filters: Filter[] = [];
@Input() staticFields = [];
@Input() staticFilters: Filter[] = [];
@Input() staticFieldValues: { [key: string]: {"name": string, "id": string, "count": string}[] } = {};
selectedFilters: number = 0; selectedFilters: number = 0;
selectedRangeFilters: number = 0; selectedRangeFilters: number = 0;
selectedStaticFilters: number = 0;
private searchFieldsHelper: SearchFields = new SearchFields(); private searchFieldsHelper: SearchFields = new SearchFields();
@Input() newQueryButton: boolean = true; @Input() newQueryButton: boolean = true;
public showUnknownFilters: boolean = false; // when a filter exists in query but has no results, so no filters returned from the query public showUnknownFilters: boolean = false; // when a filter exists in query but has no results, so no filters returned from the query
URLCreatedFilters: Filter[] = []; URLCreatedFilters: Filter[] = [];
URLCreatedRangeFilters: RangeFilter[] = []; URLCreatedRangeFilters: RangeFilter[] = [];
URLCreatedStaticFilters: Filter[] = [];
@Input() showRefine: boolean = true; @Input() showRefine: boolean = true;
@Input() tableViewLink: string; @Input() tableViewLink: string;
@Input() usedBy: string = "search"; @Input() usedBy: string = "search";
@ -98,14 +104,14 @@ export class NewSearchPageComponent implements OnInit, OnDestroy, OnChanges {
@Input() formPlaceholderText = "Type Keywords..."; @Input() formPlaceholderText = "Type Keywords...";
@Input() resultTypes: Filter = null; @Input() resultTypes: Filter = null;
resultTypeOptions = { resultTypeOptions = {
"publications": {"id": "publication", "name": OpenaireEntities.PUBLICATIONS}, // "publications": {"id": "publication", "name": OpenaireEntities.PUBLICATIONS},
"datasets": {"id": "dataset", "name": OpenaireEntities.DATASETS}, // "datasets": {"id": "dataset", "name": OpenaireEntities.DATASETS},
"software": {"id": "software", "name": OpenaireEntities.SOFTWARE}, // "software": {"id": "software", "name": OpenaireEntities.SOFTWARE},
"other": {"id": "other", "name": OpenaireEntities.OTHER} // "other": {"id": "other", "name": OpenaireEntities.OTHER}
}; };
serviceTypeOptions = { serviceTypeOptions = {
"datasources": {"id": "datasource", "name": OpenaireEntities.DATASOURCES}, // "datasources": {"id": "datasource", "name": OpenaireEntities.DATASOURCES},
"services": {"id": "service", "name": "Other "+OpenaireEntities.SERVICES} // "services": {"id": "service", "name": "Other "+OpenaireEntities.SERVICES}
} }
selectedTypesNum = 0; selectedTypesNum = 0;
@Input() quickFilter: { filter: Filter, selected: boolean, filterId: string, value: string }; @Input() quickFilter: { filter: Filter, selected: boolean, filterId: string, value: string };
@ -152,6 +158,8 @@ export class NewSearchPageComponent implements OnInit, OnDestroy, OnChanges {
searchTerm: string = null; searchTerm: string = null;
advancedSearchTerms: number = 0; advancedSearchTerms: number = 0;
@Output() filterRequestAll = new EventEmitter();
constructor(private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private location: Location, private location: Location,
private _meta: Meta, private _meta: Meta,
@ -252,15 +260,30 @@ export class NewSearchPageComponent implements OnInit, OnDestroy, OnChanges {
let filterArray = []; let filterArray = [];
let filtervalues = []; let filtervalues = [];
let filterURL = ""; let filterURL = "";
if (this.resultTypes && this.resultTypes.countSelectedValues > 0) { // if (this.resultTypes && this.resultTypes.countSelectedValues > 0) {
filterURL += ((filterURL.length == 0) ? '?' : '&') + this.resultTypes.filterId + "="; // filterURL += ((filterURL.length == 0) ? '?' : '&') + this.resultTypes.filterId + "=";
let filterName = this.resultTypes.title + " "; // let filterName = this.resultTypes.title + " ";
for (let value of this.resultTypes.values) { // for (let value of this.resultTypes.values) {
if (value.selected) { // if (value.selected) {
filterArray.push(filterName + '"' + value.name + '"'); // filterArray.push(filterName + '"' + value.name + '"');
filtervalues.push(value.name); // filtervalues.push(value.name);
filterURL += ((filterName.length == 0) ? ',' : '') + StringUtils.URIEncode('"' + value.id + '"'); // filterURL += ((filterName.length == 0) ? ',' : '') + StringUtils.URIEncode('"' + value.id + '"');
filterName = ""; // filterName = "";
// }
// }
// }
for (let filter of this.staticFilters) {
if (filter.countSelectedValues > 0) {
filterURL += ((filterURL.length == 0) ? '?' : '&') + filter.filterId + "=";
let filterName = filter.title + " ";
for (let value of filter.values) {
if (value.selected) {
filterArray.push(filterName + '"' + value.name + '"');
filtervalues.push(value.name);
filterURL += ((filterName.length == 0) ? ',' : '') + StringUtils.URIEncode('"' + StringUtils.URIEncode(value.id) + '"');
filterName = "";
}
} }
} }
} }
@ -328,9 +351,19 @@ export class NewSearchPageComponent implements OnInit, OnDestroy, OnChanges {
// if (this.quickFilter) { // if (this.quickFilter) {
// this.removeValueFromQuickFilter(); // this.removeValueFromQuickFilter();
// } // }
if (this.resultTypes) { for (var i = 0; i < this.staticFilters.length; i++) {
this.resultTypes.values = []; for (var j = 0; j < this.staticFilters[i].countSelectedValues; j++) {
if (this.staticFilters[i].values[j].selected) {
this.staticFilters[i].values[j].selected = false;
}
this.staticFilters[i].countSelectedValues = 0;
this.staticFilters[i].radioValue = "";
}
} }
this.selectedStaticFilters = 0;
// if (this.resultTypes) {
// this.resultTypes.values = [];
// }
this.goTo(1); this.goTo(1);
// this.clearKeywords(); // this.clearKeywords();
} }
@ -341,7 +374,7 @@ export class NewSearchPageComponent implements OnInit, OnDestroy, OnChanges {
} }
this.searchUtils.page = page; this.searchUtils.page = page;
this.buildPageURLParameters(this.filters, this.rangeFilters, true); this.buildPageURLParameters(this.filters, this.rangeFilters, this.staticFilters, true);
this.router.navigate([this.searchUtils.baseUrl], {queryParams: this.routerHelper.createQueryParams(this.parameterNames, this.parameterValues)}); this.router.navigate([this.searchUtils.baseUrl], {queryParams: this.routerHelper.createQueryParams(this.parameterNames, this.parameterValues)});
if (scroll) { if (scroll) {
HelperFunctions.scrollToId("searchForm"); HelperFunctions.scrollToId("searchForm");
@ -423,11 +456,13 @@ export class NewSearchPageComponent implements OnInit, OnDestroy, OnChanges {
var fields: string[] = []; var fields: string[] = [];
for (var i = 0; i < this.refineFields.length; i++) { for (var i = 0; i < this.refineFields.length; i++) {
var dependentTo = this.searchFieldsHelper.DEPENDENT_FIELDS[this.refineFields[i]]; var dependentTo = this.searchFieldsHelper.DEPENDENT_FIELDS[this.refineFields[i]];
// TODO check again the checks
//if filter is not marked as hidden OR it is hidden but it is dependent to a field that it IS selected //if filter is not marked as hidden OR it is hidden but it is dependent to a field that it IS selected
if (this.searchFieldsHelper.HIDDEN_FIELDS.indexOf(this.refineFields[i]) == -1 if (this.searchFieldsHelper.HIDDEN_FIELDS.indexOf(this.refineFields[i]) == -1
|| (selected_filters.indexOf(dependentTo) != -1) || (selected_filters.indexOf(this.refineFields[i]) != -1) || (selected_filters.indexOf(dependentTo) != -1) || (selected_filters.indexOf(this.refineFields[i]) != -1)
|| (this.resultTypes && this.resultTypes.filterId == dependentTo && this.resultTypes.countSelectedValues > 0)) { || (this.resultTypes && this.resultTypes.filterId == dependentTo && this.resultTypes.countSelectedValues > 0)
// || (this.resultAccesses && this.resultAccesses.filterId == dependentTo && this.resultAccesses.countSelectedValues > 0)
) {
fields.push(this.refineFields[i]); fields.push(this.refineFields[i]);
} }
} }
@ -569,6 +604,35 @@ export class NewSearchPageComponent implements OnInit, OnDestroy, OnChanges {
return this.rangeFilters; return this.rangeFilters;
} }
public checkSelectedStaticFilters(filters: Filter[]) {
for (var i = 0; i < filters.length; i++) {
var filter: Filter = filters[i];
filter.countSelectedValues = 0;
if (this.parameterNames.indexOf(filter.filterId) != -1) {
let values = (decodeURIComponent(this.parameterValues[this.parameterNames.indexOf(filter.filterId)])).split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/, -1);
for (let filterValue of filter.values) {
if (values.indexOf(StringUtils.quote(filterValue.id)) > -1) {
filterValue.selected = true;
filter.countSelectedValues++;
} else {
filterValue.selected = false;
}
}
} else {
for (let filterValue of filter.values) {
filterValue.selected = false;
}
}
}
this.filterFilterValues(this.filters);
if (!this.includeOnlyResultsAndFilter) {
this.updateMeta(this.pageTitle);
}
this.staticFilters = filters;
return filters;
}
get existingFiltersWithValues() { get existingFiltersWithValues() {
if (this.filters.length == 0) { if (this.filters.length == 0) {
return 0; return 0;
@ -634,6 +698,16 @@ export class NewSearchPageComponent implements OnInit, OnDestroy, OnChanges {
return this.selectedRangeFilters; return this.selectedRangeFilters;
} }
public countSelectedStaticFilters(filters: Filter[]): number {
this.selectedStaticFilters = 0;
for (let filter of filters) {
if (filter.countSelectedValues > 0) {
this.selectedStaticFilters += filter.countSelectedValues;
}
}
return this.selectedStaticFilters;
}
private clearKeywords() { private clearKeywords() {
if (this.searchUtils.keyword.length > 0) { if (this.searchUtils.keyword.length > 0) {
this.searchUtils.keyword = ''; this.searchUtils.keyword = '';
@ -702,6 +776,10 @@ export class NewSearchPageComponent implements OnInit, OnDestroy, OnChanges {
} }
filterToggled($event) {
this.filterRequestAll.emit($event)
}
/** /**
* if there is a change in the values of the quick filter, this function has to be run, to also update the quickFilter * if there is a change in the values of the quick filter, this function has to be run, to also update the quickFilter
*/ */
@ -949,6 +1027,12 @@ export class NewSearchPageComponent implements OnInit, OnDestroy, OnChanges {
if (this.entityType == "service" && URLparams) { if (this.entityType == "service" && URLparams) {
if (URLparams["type"]) { if (URLparams["type"]) {
let types1 = URLparams["type"];
types1 = Array.isArray(types1) ? types1.join(',').split(",") : types1.split(",");
types1.map(function (t) {
return StringUtils.unquote(StringUtils.URIDecode(t));
});
let types = URLparams["type"]; let types = URLparams["type"];
types = Array.isArray(types) ? types.join(',').split(",") : types.split(","); types = Array.isArray(types) ? types.join(',').split(",") : types.split(",");
types.map(function (t) { types.map(function (t) {
@ -1112,6 +1196,27 @@ export class NewSearchPageComponent implements OnInit, OnDestroy, OnChanges {
allFqs += fq; allFqs += fq;
} }
} }
for (var i = 0; i < this.staticFields.length; i++) {
var filterId = this.staticFields[i];
if (URLparams[filterId] != undefined && filterId != "type") {
let values = (StringUtils.URIDecode(StringUtils.URIDecode(URLparams[filterId]))).split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/, -1);
var countvalues = 0;
var fq = "";
let filterOp: string = this.searchFieldsHelper.getFieldOperator(filterId);
for (let value of values) {
if (value && value.length > 0) {
countvalues++;
fq += (fq.length > 0 ? " " + filterOp + " " : "") + filterId + " exact " + (value);
}
}
if (countvalues > 0) {
fq = "&fq=" + StringUtils.URIEncode(fq);
}
allFqs += fq;
}
}
this.customFilterEnabled = URLparams["cf"] == "true"; this.customFilterEnabled = URLparams["cf"] == "true";
if (this.customFilter && (this.customFilter.isHiddenFilter || this.customFilterEnabled)) { if (this.customFilter && (this.customFilter.isHiddenFilter || this.customFilterEnabled)) {
allFqs += "&fq=" + StringUtils.URIEncode(this.customFilter.queryFieldName + " exact " + StringUtils.quote((this.customFilter.valueId))); allFqs += "&fq=" + StringUtils.URIEncode(this.customFilter.queryFieldName + " exact " + StringUtils.quote((this.customFilter.valueId)));
@ -1347,9 +1452,10 @@ export class NewSearchPageComponent implements OnInit, OnDestroy, OnChanges {
* used in paging, advanced search link, Goto() * used in paging, advanced search link, Goto()
* @param filters either query filters or filters defined by the URL parameters * @param filters either query filters or filters defined by the URL parameters
* @param rangeFilters defined by the URL parameters * @param rangeFilters defined by the URL parameters
* @param staticFilters
* @param includePage * @param includePage
*/ */
buildPageURLParameters(filters: Filter[], rangeFilters: RangeFilter[], includePage: boolean) { buildPageURLParameters(filters: Filter[], rangeFilters: RangeFilter[], staticFilters: Filter[], includePage: boolean) {
this.parameterNames.splice(0, this.parameterNames.length); this.parameterNames.splice(0, this.parameterNames.length);
this.parameterValues.splice(0, this.parameterValues.length); this.parameterValues.splice(0, this.parameterValues.length);
for (var i = 0; i < this.selectedFields.length; i++) { for (var i = 0; i < this.selectedFields.length; i++) {
@ -1392,31 +1498,47 @@ export class NewSearchPageComponent implements OnInit, OnDestroy, OnChanges {
//this.parameterValues.push(this.searchUtils.sortBy); //this.parameterValues.push(this.searchUtils.sortBy);
this.parameterValues.push(this.sortedByChanged); this.parameterValues.push(this.sortedByChanged);
} }
if (this.resultTypes &&
( for (let filter of staticFilters) {
(this.entityType == 'publication' || this.entityType == 'dataset' || this.entityType == 'software' || this.entityType == 'other' || this.entityType == "result") var filterLimits = "";
|| if (filter.countSelectedValues > 0) {
(this.entityType == "service") for (let value of filter.values) {
) if (value.selected == true) {
) { filterLimits += ((filterLimits.length == 0) ? '' : ',') + '"' + StringUtils.URIEncode(value.id) + '"';
let values = []; }
for (let value of this.resultTypes.values) { }
if (value.selected) { if (filterLimits.length > 0) {
values.push(value.id); this.parameterNames.push(filter.filterId);
this.parameterValues.push(filterLimits);
} }
} }
this.selectedTypesNum = 0;
if (values.length > 0 && values.length != 4) {
this.parameterNames.push("type");
this.parameterValues.push(values.join(","));
this.selectedTypesNum = values.length;
}
//
/* if(this.quickFilter) {
this.parameterNames.push("qf");
this.parameterValues.push("" + this.quickFilter.selected);
}*/
} }
// if (this.resultTypes &&
// (
// (this.entityType == 'publication' || this.entityType == 'dataset' || this.entityType == 'software' || this.entityType == 'other' || this.entityType == "result")
// ||
// (this.entityType == "service")
// )
// ) {
// let values = [];
// for (let value of this.resultTypes.values) {
// if (value.selected) {
// values.push(value.id);
// }
// }
// this.selectedTypesNum = 0;
// if (values.length > 0 && values.length != 4) {
// this.parameterNames.push("type");
// this.parameterValues.push(values.join(","));
// this.selectedTypesNum = values.length;
// }
// //
// /* if(this.quickFilter) {
// this.parameterNames.push("qf");
// this.parameterValues.push("" + this.quickFilter.selected);
// }*/
// }
for (let filter of filters) { for (let filter of filters) {
var filterLimits = ""; var filterLimits = "";
if (filter.countSelectedValues > 0) { if (filter.countSelectedValues > 0) {
@ -1482,6 +1604,7 @@ export class NewSearchPageComponent implements OnInit, OnDestroy, OnChanges {
getRefineFiltersFromURL(URLparams) { getRefineFiltersFromURL(URLparams) {
let fields = new SearchFields(); let fields = new SearchFields();
let filters: Filter[] = []; let filters: Filter[] = [];
let staticFilters: Filter[] = [];
for (let i = 0; i < this.refineFields.length; i++) { for (let i = 0; i < this.refineFields.length; i++) {
let filterId = this.refineFields[i]; let filterId = this.refineFields[i];
if (URLparams[filterId] != undefined) { if (URLparams[filterId] != undefined) {
@ -1523,36 +1646,59 @@ export class NewSearchPageComponent implements OnInit, OnDestroy, OnChanges {
} }
}*/ }*/
let options = null; for (let i = 0; i < this.staticFields.length; i++) {
if ((this.entityType == 'publication' || this.entityType == 'dataset' || this.entityType == 'software' || this.entityType == 'other' || this.entityType == "result")) { let filterId = this.staticFields[i];
options = this.resultTypeOptions; if (URLparams[filterId] != undefined) {
} else if (this.entityType == "service") { let filter = new Filter();
options = this.serviceTypeOptions; filter.title = fields.getFieldName(filterId, this.entityType);
} filter.filterId = filterId;
if (options) { filter.originalFilterId = filterId;
this.resultTypes = {values:[],filterId:"type", countSelectedValues: 0, filterType: 'checkbox', type:'checkBox', originalFilterId: "", valueIsExact: true, title: "Type",filterOperator:"or"}; filter.values = [];
for (let typeOption of Object.keys(options)) { let values = StringUtils.URIDecode(URLparams[filterId]).split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/, -1);
let type = typeOption; for (let value of values) {
if ( URLparams["type"] && URLparams["type"].indexOf(type)==-1 || !URLparams["type"]) { let v: Value = new Value();
this.resultTypes.values.push({ v.name = RefineResultsUtils.keepPartAfterCharacters(StringUtils.unquote(value), "||");
name: options[StringUtils.unquote(type)].name, v.name = (v.name.indexOf("::") != -1) ? v.name.substring(v.name.indexOf("::") + 2).split("::").join("|") : v.name; // for funding streams
id: StringUtils.unquote(type), v.id = StringUtils.unquote(value);
selected: false, v.selected = true;
number: 0 filter.values.push(v);
}); filter.countSelectedValues++;
}else{
this.resultTypes.values.push({
name: options[StringUtils.unquote(type)].name,
id: StringUtils.unquote(type),
selected: true,
number: 0
});
this.resultTypes.countSelectedValues++;
} }
staticFilters.push(filter)
} }
} }
// let options = null;
// if ((this.entityType == 'publication' || this.entityType == 'dataset' || this.entityType == 'software' || this.entityType == 'other' || this.entityType == "result")) {
// options = this.resultTypeOptions;
// } else if (this.entityType == "service") {
// options = this.serviceTypeOptions;
// }
// if (options) {
// this.resultTypes = {values:[],filterId:"type", countSelectedValues: 0, filterType: 'checkbox', type:'checkBox', originalFilterId: "", valueIsExact: true, title: "Type",filterOperator:"or"};
// for (let typeOption of Object.keys(options)) {
// let type = typeOption;
// if ( URLparams["type"] && URLparams["type"].indexOf(type)==-1 || !URLparams["type"]) {
// this.resultTypes.values.push({
// name: options[StringUtils.unquote(type)].name,
// id: StringUtils.unquote(type),
// selected: false,
// number: 0
// });
// }else{
// this.resultTypes.values.push({
// name: options[StringUtils.unquote(type)].name,
// id: StringUtils.unquote(type),
// selected: true,
// number: 0
// });
// this.resultTypes.countSelectedValues++;
// }
// }
// }
this.URLCreatedFilters = filters; this.URLCreatedFilters = filters;
this.URLCreatedStaticFilters = staticFilters;
} }
/** /**
@ -1641,7 +1787,7 @@ export class NewSearchPageComponent implements OnInit, OnDestroy, OnChanges {
this.filters = filters; this.filters = filters;
} }
this.buildPageURLParameters(this.URLCreatedFilters, this.URLCreatedRangeFilters, true); this.buildPageURLParameters(this.URLCreatedFilters, this.URLCreatedRangeFilters, this.URLCreatedStaticFilters, true);
//this.checkSelectedRangeFilters(this.rangeFilters); //this.checkSelectedRangeFilters(this.rangeFilters);
this.checkSelectedFilters(this.filters); this.checkSelectedFilters(this.filters);
@ -1663,6 +1809,15 @@ export class NewSearchPageComponent implements OnInit, OnDestroy, OnChanges {
return this.rangeFilters; return this.rangeFilters;
} }
public prepareStaticFiltersToShow() {
this.staticFilters = RefineResultsUtils.parse(this.staticFieldValues, this.staticFields, this.entityType, "search", true);
this.checkSelectedStaticFilters(this.staticFilters);
this.countSelectedStaticFilters(this.staticFilters);
this.cdr.detectChanges();
return this.staticFilters;
}
/** /**
* Used to set the variables and search page, and prepare it before the getResults query * Used to set the variables and search page, and prepare it before the getResults query
* @param fieldIds * @param fieldIds
@ -1675,18 +1830,20 @@ export class NewSearchPageComponent implements OnInit, OnDestroy, OnChanges {
* @param entityType * @param entityType
* @param quickFilter * @param quickFilter
*/ */
prepareSearchPage(fieldIds, selectedFields, refineFields, rangeFields, fieldIdsMap, customFilter, params, entityType, quickFilter = null) { prepareSearchPage(fieldIds, selectedFields, refineFields, rangeFields, staticFields, fieldIdsMap, customFilter, params, entityType, quickFilter = null) {
// console.log(this.refineFields); // console.log(this.refineFields);
this.entityType = entityType; this.entityType = entityType;
this.fieldIds = fieldIds; this.fieldIds = fieldIds;
this.selectedFields = selectedFields; this.selectedFields = selectedFields;
this.refineFields = refineFields; this.refineFields = refineFields;
this.rangeFields = rangeFields; this.rangeFields = rangeFields;
this.staticFields = staticFields;
this.fieldIdsMap = fieldIdsMap; this.fieldIdsMap = fieldIdsMap;
this.customFilter = customFilter; this.customFilter = customFilter;
this.quickFilter = quickFilter; this.quickFilter = quickFilter;
this.getRangeFiltersFromURL(params); this.getRangeFiltersFromURL(params);
this.getRefineFiltersFromURL(params); this.getRefineFiltersFromURL(params);
// this.cdr.detectChanges();
this.createAdvancedSearchSelectedFiltersFromURLParameters(params); this.createAdvancedSearchSelectedFiltersFromURLParameters(params);
this.searchTerm = ''; this.searchTerm = '';
if(params && params['fv0'] && params['f0'] && params['f0'] == 'q'){ if(params && params['fv0'] && params['f0'] && params['f0'] == 'q'){

View File

@ -10,33 +10,41 @@
<ng-container *ngTemplateOutlet="input_label_wrapper; context: {filter: filter, value: value}"></ng-container> <ng-container *ngTemplateOutlet="input_label_wrapper; context: {filter: filter, value: value}"></ng-container>
</div> </div>
</div> </div>
<div *ngIf="addShowMore && (filter.values.length) > filterValuesNum"> <div *ngIf="addShowMore && hasMoreValues">
<a *ngIf="filterValuesNum > 0 " class="uk-text-small view-more-less-link uk-margin-small-top" [ngClass]="((isDisabled)?'uk-disabled uk-link-muted ':'')" (click)="toggle($event)"> <a *ngIf="filterValuesNum > 0 " class="uk-text-small view-more-less-link uk-margin-small-top" [ngClass]="((isDisabled)?'uk-disabled uk-link-muted ':'')" (click)="toggle($event)">
<span *ngIf="!isOpen">View all</span> <span *ngIf="!filter.isOpen">View all</span>
<span *ngIf="isOpen">View less </span> <span *ngIf="filter.isOpen">View less </span>
</a> </a>
<div *ngIf="isOpen" class="uk-text-small uk-margin-small-top uk-margin-small-bottom"> <div *ngIf="filter.isOpen" class="uk-text-small uk-margin-small-top uk-margin-small-bottom">
<div class="uk-margin-small-left"> <div *ngIf="filter.countAllValues == -1">
<div class="uk-text-meta">Top 100 values are shown in the filters</div> <loading class="uk-height-small uk-display-block" size="medium"></loading>
<div class="uk-flex uk-flex-bottom uk-margin-top"> </div>
<div input class="uk-width-1-2@m uk-margin-right" [placeholder]="{label: 'Search', static: true}" inputClass="inner small" [(value)]="keyword" (valueChange)="initMatching()"></div> <div *ngIf="filter.countAllValues == 0">
<div *ngIf="showResultCount === true" input type="select" class="uk-width-expand" placeholder="Sort by" <span class="uk-text-warning">An error occured. </span><span><a class="uk-button-link" (click)="toggleWithoutUpdate()">Please try again</a>.</span>
inputClass="border-bottom" [(value)]="sortBy" [options]="sortByOptions" (valueChange)="sort()"></div> </div>
<ng-container *ngIf="(!filter.countAllValues && filter.countAllValues != 0) || filter.countAllValues > 0">
<div class="uk-margin-small-left">
<div class="uk-text-meta">Top 100 values are shown in the filters</div>
<div class="uk-flex uk-flex-bottom uk-margin-top">
<div input class="uk-width-1-2@m uk-margin-right" [placeholder]="{label: 'Search', static: true}" inputClass="inner small" [(value)]="keyword" (valueChange)="initMatching()"></div>
<div *ngIf="showResultCount === true" input type="select" class="uk-width-expand" placeholder="Sort by"
inputClass="border-bottom" [(value)]="sortBy" [options]="sortByOptions" (valueChange)="sort()"></div>
</div>
</div> </div>
</div> <div class="uk-overflow-auto uk-height-max-small uk-margin-small-left uk-margin-small-right uk-margin-top">
<div class="uk-overflow-auto uk-height-max-small uk-margin-small-left uk-margin-small-right uk-margin-top"> <ng-container *ngFor="let value of this.sortedValues">
<ng-container *ngFor="let value of this.sortedValues"> <div *ngIf="filterKeywords(value.name)" title="{{value.name}}"
<div *ngIf="filterKeywords(value.name)" title="{{value.name}}" class="uk-animation-fade uk-text-small">
class="uk-animation-fade uk-text-small"> <ng-container *ngTemplateOutlet="input_label_wrapper; context: {filter: filter, value: value}"></ng-container>
<ng-container *ngTemplateOutlet="input_label_wrapper; context: {filter: filter, value: value}"></ng-container> </div>
</div> </ng-container>
</ng-container> <ng-container *ngIf="!hasMatch">
<ng-container *ngIf="!hasMatch"> <div class="uk-padding-small uk-text-meta">
<div class="uk-padding-small uk-text-meta"> No filters available with that term
No filters available with that term </div>
</div> </ng-container>
</ng-container> </div>
</div> </ng-container>
</div> </div>
</div> </div>
</div> </div>

View File

@ -26,6 +26,7 @@ export class SearchFilterComponent implements OnInit, OnChanges {
@Input() addShowMore: boolean = true; @Input() addShowMore: boolean = true;
@Input() showMoreInline: boolean = true; @Input() showMoreInline: boolean = true;
@Input() filterValuesNum: number = 6; @Input() filterValuesNum: number = 6;
public hasMoreValues: boolean = false;
public showAll: boolean = false; public showAll: boolean = false;
public _maxCharacters: number = 28; public _maxCharacters: number = 28;
@ -33,6 +34,7 @@ export class SearchFilterComponent implements OnInit, OnChanges {
@Output() modalChange = new EventEmitter(); @Output() modalChange = new EventEmitter();
@Output() onFilterChange = new EventEmitter(); @Output() onFilterChange = new EventEmitter();
@Output() onFilterToggle = new EventEmitter();
keyword = ""; keyword = "";
sortBy: "name" | "num" = "name"; sortBy: "name" | "num" = "name";
sortByOptions: Option[] = [{label: 'Results number', value: 'num'}, {label: 'Name', value: 'name'}]; sortByOptions: Option[] = [{label: 'Results number', value: 'num'}, {label: 'Name', value: 'name'}];
@ -41,7 +43,7 @@ export class SearchFilterComponent implements OnInit, OnChanges {
@Input() actionRoute: boolean = false; @Input() actionRoute: boolean = false;
@Input() quickFilter: { filter: Filter, selected: boolean, filterId: string, value: string }; @Input() quickFilter: { filter: Filter, selected: boolean, filterId: string, value: string };
sub; sub;
public isOpen: boolean = false; @Input() isOpen: boolean = false;
sortedValues; sortedValues;
hasMatch: boolean = false; hasMatch: boolean = false;
@ -58,11 +60,12 @@ export class SearchFilterComponent implements OnInit, OnChanges {
ngOnInit() { ngOnInit() {
if(this.filterValuesNum == 0){ if(this.filterValuesNum == 0){
this.isOpen = true; this.filter.isOpen = true;
this.sortBy = "num"; this.sortBy = "num";
}else{
this.isOpen = false;
} }
// else{
// this.filter.isOpen = false;
// }
this.sub = this.route.queryParams.subscribe(params => { this.sub = this.route.queryParams.subscribe(params => {
this.queryParams = Object.assign({}, params); this.queryParams = Object.assign({}, params);
this.paramPosition = SearchFields.getParameterOrder(this.filter.filterId, this.getEntries(params)); this.paramPosition = SearchFields.getParameterOrder(this.filter.filterId, this.getEntries(params));
@ -81,7 +84,10 @@ export class SearchFilterComponent implements OnInit, OnChanges {
ngOnChanges(changes: SimpleChanges) { ngOnChanges(changes: SimpleChanges) {
if (changes.filter) { if (changes.filter) {
this.filter.values = this.filter.values.filter(value => !value.name.toLowerCase().includes('unknown') && !value.name.toLowerCase().includes('not available')); this.hasMoreValues = this.filter.values.length > this.filterValuesNum;
// this.filter.values = this.filter.values.filter(value => !value.name.toLowerCase().includes('unknown') && !value.name.toLowerCase().includes('not available'));
this.filter.values = this.filter.values.filter(value => value && value.name != "unidentified" && value.name != "Undetermined" && !value.name.toLowerCase().includes('unknown') && !value.name.toLowerCase().includes('not available'));
if (this.filter.filterType == "radio") { if (this.filter.filterType == "radio") {
this.filter.radioValue = ""; this.filter.radioValue = "";
this.filter.values.forEach(value => { this.filter.values.forEach(value => {
@ -95,7 +101,8 @@ export class SearchFilterComponent implements OnInit, OnChanges {
} }
public _formatTitle(title, length) { public _formatTitle(title, length) {
return (((title + " (" + length + ")").length > this._maxCharacters) ? (title.substring(0, (this._maxCharacters - (" (" + length + ")").length - ('...').length)) + "...") : title) + " (" + (length > 95 ? "100" : length) + ")"; // return (((title + " (" + length + ")").length > this._maxCharacters) ? (title.substring(0, (this._maxCharacters - (" (" + length + ")").length - ('...').length)) + "...") : title) + " (" + (length > 95 ? "100" : length) + ")";
return (((title).length > this._maxCharacters) ? (title.substring(0, (this._maxCharacters - ('...').length)) + "...") : title);
} }
public _formatName(value) { public _formatName(value) {
@ -265,8 +272,18 @@ export class SearchFilterComponent implements OnInit, OnChanges {
} }
toggle(event) { toggle(event) {
this.isOpen = !this.isOpen; this.filter.isOpen = !this.filter.isOpen;
event.stopPropagation(); event.stopPropagation();
this.toggleWithoutUpdate();
}
toggleWithoutUpdate() {
if(this.filter.countAllValues == 0) {
this.filter.countAllValues = -1; // if request failed, try again automatically if toggled again
}
if(this.filter.isOpen && this.filter.countAllValues < 0) {
this.onFilterToggle.emit(this.filter);
}
} }
disabled(value) { disabled(value) {

View File

@ -8,11 +8,12 @@ import {ModalModule} from '../../utils/modal/modal.module';
import {RouterModule} from "@angular/router"; import {RouterModule} from "@angular/router";
import {InputModule} from '../../sharedComponents/input/input.module'; import {InputModule} from '../../sharedComponents/input/input.module';
import {IconsModule} from "../../utils/icons/icons.module"; import {IconsModule} from "../../utils/icons/icons.module";
import {LoadingModule} from "../../utils/loading/loading.module";
@NgModule({ @NgModule({
imports: [ imports: [
CommonModule, FormsModule, ModalModule, RouterModule, CommonModule, FormsModule, ModalModule, RouterModule,
InputModule, IconsModule InputModule, IconsModule, LoadingModule
], ],
declarations: [ declarations: [
SearchFilterComponent, SearchFilterModalComponent SearchFilterComponent, SearchFilterModalComponent

View File

@ -11,6 +11,8 @@ export class Filter{
public type?: string = "keyword"; public type?: string = "keyword";
public radioValue?: string = ""; public radioValue?: string = "";
// public uniqueValueIdSelected: string; // public uniqueValueIdSelected: string;
public countAllValues?: number = -1; // -1: not yet requested, 0: request failed, >0 OK
public isOpen?: boolean = false;
} }
export class Value{ export class Value{

View File

@ -29,7 +29,7 @@ export class RefineFieldResultsService {
getAllRefineFieldResultsByFieldName(fieldName:string, entityName:string, properties:EnvProperties, refineQuery:string=null):any{ getAllRefineFieldResultsByFieldName(fieldName:string, entityName:string, properties:EnvProperties, refineQuery:string=null):any{
// let keys:string[]=["funder", "relfunder", "fundinglevel"]; // let keys:string[]=["funder", "relfunder", "fundinglevel"];
let url = properties.searchAPIURLLAst +this.getSearchAPIURLForEntity(entityName)+"?fields="+fieldName +('&sf='+fieldName)+ "&format=json"; let url = properties.searchAPIURLLAst +this.getSearchAPIURLForEntity(entityName)+"?fields="+fieldName +('&sf='+fieldName)+ "&format=json&size=0";
if(refineQuery!= null && refineQuery != '' ) { if(refineQuery!= null && refineQuery != '' ) {
url += refineQuery; url += refineQuery;
} }

View File

@ -31,7 +31,7 @@ export class SearchDataprovidersService {
.pipe(map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource", usedBy)])); .pipe(map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource", usedBy)]));
} }
advancedSearchDataproviders (params: string, page: number, size: number, properties: EnvProperties, refineParams:string=null, refineFields:string[] =null, refineQuery:string = null, depositQuery:boolean = false ):any { advancedSearchDataproviders (params: string, page: number, size: number, properties: EnvProperties, refineParams:string=null, refineFields:string[] =null, refineQuery:string = null, depositQuery:boolean = false, minRef: boolean = false):any {
let url = properties.searchAPIURLLAst+"resources"+(depositQuery?'':2)+"/?format=json"; let url = properties.searchAPIURLLAst+"resources"+(depositQuery?'':2)+"/?format=json";
if(params!= null && params != '' ) { if(params!= null && params != '' ) {
@ -45,6 +45,7 @@ export class SearchDataprovidersService {
url += "&" + refineQuery; url += "&" + refineQuery;
} }
url += "&page="+(page-1)+"&size="+size; url += "&page="+(page-1)+"&size="+size;
url += minRef ? "&minRef=true" : "";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.pipe(map(res => [res['meta'].total, this.parseResults(res['results']), RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")])); .pipe(map(res => [res['meta'].total, this.parseResults(res['results']), RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]));

View File

@ -55,7 +55,7 @@ export class SearchOrganizationsService {
//.map(res => <any> res.json()) //.map(res => <any> res.json())
.pipe(map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "organization")])); .pipe(map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "organization")]));
} }
advancedSearchOrganizations (params: string, page: number, size: number, properties:EnvProperties, refineParams:string=null, refineFields:string[] =null, refineQuery:string = null ):any { advancedSearchOrganizations (params: string, page: number, size: number, properties:EnvProperties, refineParams:string=null, refineFields:string[] =null, refineQuery:string = null, minRef: boolean = false):any {
// &type=organizations // &type=organizations
let url = properties.searchAPIURLLAst+"resources2/?format=json"; let url = properties.searchAPIURLLAst+"resources2/?format=json";
var basicQuery = "(reldatasourcecompatibilityid exact driver or reldatasourcecompatibilityid exact driver-openaire2.0 or " + var basicQuery = "(reldatasourcecompatibilityid exact driver or reldatasourcecompatibilityid exact driver-openaire2.0 or " +
@ -76,6 +76,7 @@ export class SearchOrganizationsService {
url += "&" + refineQuery; url += "&" + refineQuery;
} }
url += "&page="+(page-1)+"&size="+size; url += "&page="+(page-1)+"&size="+size;
url += minRef ? "&minRef=true" : "";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
//.map(res => <any> res.json()) //.map(res => <any> res.json())

View File

@ -49,7 +49,7 @@ export class SearchProjectsService {
//.map(res => <any> res.json()) //.map(res => <any> res.json())
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'])])); .pipe(map(res => [res['meta'].total, this.parseResults(res['results'])]));
} }
advancedSearchProjects (params: string, page: number, size: number, properties:EnvProperties, refineParams:string=null, refineFields:string[] =null, refineQuery:string = null ):any { advancedSearchProjects (params: string, page: number, size: number, properties:EnvProperties, refineParams:string=null, refineFields:string[] =null, refineQuery:string = null, minRef: boolean = false):any {
// &type=projects // &type=projects
let url = properties.searchAPIURLLAst+"resources2/?format=json"; let url = properties.searchAPIURLLAst+"resources2/?format=json";
// var basicQuery = "(oaftype exact project) " // var basicQuery = "(oaftype exact project) "
@ -67,6 +67,8 @@ export class SearchProjectsService {
url += "&" + refineQuery; url += "&" + refineQuery;
} }
url += "&page="+(page-1)+"&size="+size; url += "&page="+(page-1)+"&size="+size;
url += minRef ? "&minRef=true" : "";
// url += "&format=json"; // url += "&format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
//.map(res => <any> res.json()) //.map(res => <any> res.json())

View File

@ -109,7 +109,7 @@ export class SearchResearchResultsService {
.pipe(map(res => [res['meta'].total, this.parseResults(resultType, res['results'], properties), RefineResultsUtils.parse(res['refineResults'], refineFields, "publication")])); .pipe(map(res => [res['meta'].total, this.parseResults(resultType, res['results'], properties), RefineResultsUtils.parse(res['refineResults'], refineFields, "publication")]));
} }
advancedSearchResults(resultType: string, params: string, page: number, size: number, sortBy: string, properties: EnvProperties, refineParams: string = null, refineFields: string[] = null, refineQuery: string = null): any { advancedSearchResults(resultType: string, params: string, page: number, size: number, sortBy: string, properties: EnvProperties, refineParams: string = null, refineFields: string[] = null, refineQuery: string = null, minRef: boolean = false): any {
let url = properties.searchAPIURLLAst + "resources2/?format=json"; let url = properties.searchAPIURLLAst + "resources2/?format=json";
if (params != null && params != '') { if (params != null && params != '') {
url += "&query=(" + params + ")"; url += "&query=(" + params + ")";
@ -126,6 +126,7 @@ export class SearchResearchResultsService {
} }
url += "&page=" + (page - 1) + "&size=" + size; url += "&page=" + (page - 1) + "&size=" + size;
url += minRef ? "&minRef=true" : "";
// url += "&format=json"; // url += "&format=json";
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url) return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)

View File

@ -6,7 +6,7 @@ import { SearchFields} from '../../utils/properties/searchFields';
export class RefineResultsUtils { export class RefineResultsUtils {
public static parse (data, fields:string[], entityType:string, usedBy: string="search"):Filter[] { public static parse (data, fields:string[], entityType:string, usedBy: string="search", staticFilter: boolean = false):Filter[] {
// var data = this.json.refineReuslts; // var data = this.json.refineReuslts;
var searchFields:SearchFields = new SearchFields(); var searchFields:SearchFields = new SearchFields();
@ -33,12 +33,16 @@ export class RefineResultsUtils {
value.name =this.removePartAfterCharacters(value,"||"); value.name =this.removePartAfterCharacters(value,"||");
value.number = field[i].count; value.number = field[i].count;
value.id = field[i].id; value.id = field[i].id;
if(RefineResultsUtils.includeValue(value)){ //if(RefineResultsUtils.includeValue(value)){
filter.values.push(value); filter.values.push(value);
} //}
} }
if(staticFilter) {
filter.countAllValues = filter.values.length;
}
// filter.values.sort(function(a, b){return b.number - a.number})
filters.push(filter); filters.push(filter);
} }

View File

@ -7,6 +7,8 @@ export class SearchFieldsBase {
//RESULTS //RESULTS
//Used for datasets and publications and software and orp //Used for datasets and publications and software and orp
//In case Datasets or Software should display different fields, use seperate tables for fields //In case Datasets or Software should display different fields, use seperate tables for fields
public RESULT_STATIC_FIELDS = ["resultbestaccessright", "type"];
// "resultacceptanceyear", // "resultacceptanceyear",
public RESULT_RANGE_FIELDS = [ public RESULT_RANGE_FIELDS = [
["resultacceptanceyear", "resultacceptanceyear"] ["resultacceptanceyear", "resultacceptanceyear"]
@ -14,10 +16,21 @@ export class SearchFieldsBase {
// Remove Collected From Filter "collectedfrom","collectedfrom" // Remove Collected From Filter "collectedfrom","collectedfrom"
public RESULT_REFINE_FIELDS = [ public RESULT_REFINE_FIELDS = [
"resultbestaccessright", "instancetypename", properties.environment!='production'?"foslabel":'fos', "relfunder", "instancetypename", properties.environment!='production'?"foslabel":'fos', "relfunder",
"relfundinglevel0_id", "relfundinglevel1_id", "relfundinglevel2_id", "relfundinglevel0_id", "relfundinglevel1_id", "relfundinglevel2_id",
"relproject", "sdg", "country", "resultlanguagename", "resulthostingdatasource", "community"]; "relproject", "sdg", "country", "resultlanguagename", "resulthostingdatasource", "community"];
RESULT_FIELDS_ORDERED = [
{type: "static", title: "", values: ["resultbestaccessright", "type"]},
{type: "refine", title: "", values: ["instancetypename"]},
{type: "range", title: "", values: ["resultacceptanceyear", "resultacceptanceyear"]},
{type: "refine", title: "", values: [
properties.environment!='production'?"foslabel":'fos', "relfunder",
"relfundinglevel0_id", "relfundinglevel1_id", "relfundinglevel2_id",
"relproject", "sdg", "country", "resultlanguagename", "resulthostingdatasource", "community"
]}
];
public RESULT_ADVANCED_FIELDS: string[] = ["q", "resulttitle", "resultauthor", "authorid", "resultdescription", "resultsubject", "eoscifguidelines", "resultpublisher", public RESULT_ADVANCED_FIELDS: string[] = ["q", "resulttitle", "resultauthor", "authorid", "resultdescription", "resultsubject", "eoscifguidelines", "resultpublisher",
"resultbestaccessright", "community", "collectedfromdatasourceid", "resulthostingdatasourceid", "resultdateofacceptance", "resultbestaccessright", "community", "collectedfromdatasourceid", "resulthostingdatasourceid", "resultdateofacceptance",
"relfunder", "relfunder",
@ -203,11 +216,11 @@ export class SearchFieldsBase {
}, },
["resultbestaccessright"]: { ["resultbestaccessright"]: {
name: "Access", name: "Access",
type: "vocabulary", type: "static",
param: "access", param: "access",
operator: "ac", operator: "ac",
equalityOperator: " exact ", equalityOperator: " exact ",
filterType: "radio" filterType: "checkbox"
}, },
["collectedfrom"]: { ["collectedfrom"]: {
name: "Collected From", name: "Collected From",
@ -272,15 +285,46 @@ export class SearchFieldsBase {
operator: "fl", operator: "fl",
equalityOperator: " exact ", equalityOperator: " exact ",
filterType: "checkbox" filterType: "checkbox"
},
["type"]: {
name: "Type",
type: "static",
param: "type",
operator: "tp",
equalityOperator: " = ",
filterType: "checkbox"
} }
}; };
public RESULT_STATIC_FIELD_VALUES: { [key: string]: {"name": string, "id": string, "count": string}[] } = {
["resultbestaccessright"]: [
{ name: "Open Access", id: "Open Access", count: "0" },
{ name: "Closed Access", id: "Closed Access", count: "0" },
{ name: "Restricted", id: "Restricted", count: "0" },
{ name: "Open Source", id: "Open Source", count: "0" },
{ name: "Embargo", id: "Embargo", count: "0" }
],
["type"]: [
{ name: OpenaireEntities.PUBLICATIONS, id: "publications", count: "0" },
{ name: OpenaireEntities.DATASETS, id: "datasets", count: "0" },
{ name: OpenaireEntities.SOFTWARE, id: "software", count: "0" },
{ name: OpenaireEntities.OTHER, id: "other", count: "0" }
]
};
//PROJECT //PROJECT
public PROJECT_RANGE_FIELDS = [ public PROJECT_RANGE_FIELDS = [
["projectendyear", "projectstartyear"] ["projectendyear", "projectstartyear"]
]; ];
public PROJECT_REFINE_FIELDS: string[] = ["funder", "fundinglevel0_id", "fundinglevel1_id", public PROJECT_REFINE_FIELDS: string[] = ["funder", "fundinglevel0_id", "fundinglevel1_id",
"fundinglevel2_id", "projectoamandatepublications", "projectstartyear", "projectendyear"]; "fundinglevel2_id", "projectoamandatepublications", "projectstartyear", "projectendyear"];
public PROJECT_FIELDS_ORDERED = [
{type: "refine", title: "", values: ["funder", "fundinglevel0_id", "fundinglevel1_id", "fundinglevel2_id"]},
{type: "range", title: "", values: ["projectstartyear", "projectendyear"]},
{type: "refine", title: "", values: ["projectoamandatepublications"]}
];
public PROJECT_ADVANCED_FIELDS: string[] = ["q", "projectacronym", "projecttitle", "projectkeywords", public PROJECT_ADVANCED_FIELDS: string[] = ["q", "projectacronym", "projecttitle", "projectkeywords",
"funder", "fundinglevel0_id", "fundinglevel1_id", "fundinglevel2_id", "funder", "fundinglevel0_id", "fundinglevel1_id", "fundinglevel2_id",
"projectstartdate", "projectenddate", "projectstartdate", "projectenddate",
@ -436,6 +480,8 @@ export class SearchFieldsBase {
}; };
//DATAPROVIDERS //DATAPROVIDERS
public DATASOURCE_STATIC_FIELDS = ["eosctype"];
// add Collected From Filter "collectedfromname" // add Collected From Filter "collectedfromname"
public DATASOURCE_REFINE_FIELDS: string[] = ["eoscdatasourcetype", "datasourceodlanguages", "datasourceodcontenttypes", public DATASOURCE_REFINE_FIELDS: string[] = ["eoscdatasourcetype", "datasourceodlanguages", "datasourceodcontenttypes",
"datasourcecompatibilityname", "country", "collectedfromname", "datasourcethematic", "datasourcecompatibilityname", "country", "collectedfromname", "datasourcethematic",
@ -582,9 +628,24 @@ export class SearchFieldsBase {
equalityOperator: " exact ", equalityOperator: " exact ",
filterType: "checkbox" filterType: "checkbox"
}, },
["pid"]: {name: "PID", type: "keyword", param: "pid", operator: "pd", equalityOperator: " exact ", filterType: null} ["pid"]: {name: "PID", type: "keyword", param: "pid", operator: "pd", equalityOperator: " exact ", filterType: null},
["eosctype"]: {
name: "EOSC Type",
type: "static",
param: "type",
operator: "tp",
equalityOperator: " = ",
filterType: "checkbox"
}
}; };
public DATASOURCE_STATIC_FIELD_VALUES: { [key: string]: {"name": string, "id": string, "count": string}[] } = {
["eosctype"]: [
{ name: OpenaireEntities.DATASOURCES, id: "Data Source", count: "0" },
{ name: "Other "+OpenaireEntities.SERVICES, id: "Service", count: "0" },
]
}
public DEPOSIT_DATASOURCE_KEYWORD_FIELDS: { "name": string, "equalityOperator": string } [] = [ public DEPOSIT_DATASOURCE_KEYWORD_FIELDS: { "name": string, "equalityOperator": string } [] = [
{"name": "relorganizationname", "equalityOperator": "="}, {"name": "relorganizationname", "equalityOperator": "="},
{"name": "relorganizationshortname", "equalityOperator": "="}, {"name": "relorganizationshortname", "equalityOperator": "="},

View File

@ -59,6 +59,7 @@ export class StaticAutoCompleteComponent implements OnChanges{
@Input() public selectedValue:string = ''; @Input() public selectedValue:string = '';
@Input() public vocabularyId:string ; @Input() public vocabularyId:string ;
@Input() public fieldName:string ; @Input() public fieldName:string ;
@Input() public fieldValues;
@Input() public entityName:string ; @Input() public entityName:string ;
@Input() public fieldId:string ; @Input() public fieldId:string ;
@Input() properties:EnvProperties; @Input() properties:EnvProperties;
@ -115,21 +116,26 @@ export class StaticAutoCompleteComponent implements OnChanges{
} }
); );
}else if(this.fieldName && this.entityName){ }else if(this.fieldName && this.entityName){
this.sub = this._refineService.getRefineFieldResultsByFieldName(this.fieldName,this.entityName, this.properties).subscribe( if(this.fieldValues) {
data => { this.list = this._refineService.parse(this.fieldValues, this.fieldName);
this.list = data; this.afterListFetchedActions();
this.afterListFetchedActions(); } else {
this.sub = this._refineService.getRefineFieldResultsByFieldName(this.fieldName, this.entityName, this.properties).subscribe(
data => {
this.list = data;
this.afterListFetchedActions();
}, },
err => { err => {
//console.log(err); //console.log(err);
this.handleError("Error getting results for refine field: "+this.fieldName+" for "+this.entityName, err); this.handleError("Error getting results for refine field: " + this.fieldName + " for " + this.entityName, err);
this.warningMessage = "Error, couldn't fetch results..."; this.warningMessage = "Error, couldn't fetch results...";
this.showLoading = false; this.showLoading = false;
this.afterListFetchedActions(); this.afterListFetchedActions();
} }
); );
}else{ }
}else{
this.showLoading = false; this.showLoading = false;
} }