diff --git a/searchPages/searchUtils/searchPage.component.ts b/searchPages/searchUtils/searchPage.component.ts index 0254fdfe..552e1c74 100644 --- a/searchPages/searchUtils/searchPage.component.ts +++ b/searchPages/searchUtils/searchPage.component.ts @@ -155,6 +155,10 @@ export class SearchPageComponent { allFqs += fq; } } + if(this.connectCommunityId ){ + allFqs+= "&fq=communityId exact " + StringUtils.quote(StringUtils.URIEncode(this.connectCommunityId )); + } + var keyword = params['keyword']; var doiQuery = ""; var keywordQuery = ""; @@ -202,6 +206,9 @@ export class SearchPageComponent { } } + if(this.connectCommunityId ){ + allFqs+= "&fq=communityId exact " + StringUtils.quote(StringUtils.URIEncode(this.connectCommunityId )); + } var keyword = params['keyword']; var doiQuery = ""; var keywordQuery = ""; @@ -285,19 +292,20 @@ export class SearchPageComponent { if(filteredValues.length > 0){ filter.values = filteredValues; } - }else if(this.connectCommunityId && filter.filterId.indexOf("community")!=-1 ){ - var filteredValues = []; - for(let filterValue of filter.values) { - if(this.connectCommunityId != filterValue.id){ - filteredValues.push(filterValue); - }else{ - filter.countSelectedValues-- ; - } - } - if(filteredValues.length > 0){ - filter.values = filteredValues; - } - } + } + // else if(this.connectCommunityId && filter.filterId.indexOf("community")!=-1 ){ + // var filteredValues = []; + // for(let filterValue of filter.values) { + // if(this.connectCommunityId != filterValue.id){ + // filteredValues.push(filterValue); + // }else{ + // filter.countSelectedValues-- ; + // } + // } + // if(filteredValues.length > 0){ + // filter.values = filteredValues; + // } + // } } return filters; @@ -321,15 +329,15 @@ export class SearchPageComponent { for (let filter of filters){ var filterLimits=""; - if(filter.countSelectedValues > 0 || (this.connectCommunityId && filter.filterId.indexOf("community")!=-1)){ + if(filter.countSelectedValues > 0 ){//|| (this.connectCommunityId && filter.filterId.indexOf("community")!=-1)){ for (let value of filter.values){ if(value.selected == true){ filterLimits+=((filterLimits.length == 0)?'':',') +'"'+ StringUtils.URIEncode(value.id)+'"'; } } - if(this.connectCommunityId && filter.filterId.indexOf("community")!=-1 ){ - filterLimits+=((filterLimits.length == 0)?'':',') +'"'+ StringUtils.URIEncode(this.connectCommunityId)+'"'; - } + // if(this.connectCommunityId && filter.filterId.indexOf("community")!=-1 ){ + // filterLimits+=((filterLimits.length == 0)?'':',') +'"'+ StringUtils.URIEncode(this.connectCommunityId)+'"'; + // } this.queryParameters.set(filter.filterId,filterLimits); if(filterLimits.length > 0){ this.parameterNames.push(filter.filterId); @@ -355,7 +363,7 @@ export class SearchPageComponent { private createSearchQueryParameters(filters:Filter[]){ // called by goTo, result emited to and used by search find pages var allFqs = ""; for (let filter of filters){ - if(filter.countSelectedValues > 0 || (this.connectCommunityId && filter.filterId.indexOf("community")!=-1)){ + if(filter.countSelectedValues > 0 ){//|| (this.connectCommunityId && filter.filterId.indexOf("community")!=-1)){ var fq = ""; var count_selected=0; for (let value of filter.values){ @@ -364,13 +372,16 @@ export class SearchPageComponent { fq+=(fq.length > 0 ? " " + filter.filterOperator + " ":"" ) + filter.filterId + " exact " + StringUtils.quote(StringUtils.URIEncode(value.id)); } } - if(this.connectCommunityId && filter.filterId.indexOf("community")!=-1){ - count_selected++; - fq+=(fq.length > 0 ? " " + filter.filterOperator + " ":"" ) + filter.filterId + " exact " + StringUtils.quote(StringUtils.URIEncode(this.connectCommunityId)); - } + // if(this.connectCommunityId && filter.filterId.indexOf("community")!=-1){ + // count_selected++; + // fq+=(fq.length > 0 ? " " + filter.filterOperator + " ":"" ) + filter.filterId + " exact " + StringUtils.quote(StringUtils.URIEncode(this.connectCommunityId)); + // } fq="&fq="+fq; allFqs += fq; } + } + if(this.connectCommunityId ){ + allFqs+= "&fq=communityId exact " + StringUtils.quote(StringUtils.URIEncode(this.connectCommunityId )); } //TODO -- var doiQuery = ""; @@ -392,7 +403,6 @@ export class SearchPageComponent { keywordQuery += "&q="+StringUtils.URIEncode(this.searchUtils.keyword); } } - return (doiQuery.length > 0 ? doiQuery:keywordQuery) + allFqs; } diff --git a/searchPages/simple/searchDatasets.component.ts b/searchPages/simple/searchDatasets.component.ts index acd31bb2..1f9d4091 100644 --- a/searchPages/simple/searchDatasets.component.ts +++ b/searchPages/simple/searchDatasets.component.ts @@ -28,7 +28,7 @@ import{EnvProperties} from '../../utils/properties/env-properties'; searchFormClass="datasetsSearchForm" [(openaireLink)]=openaireLink [(advancedSearchParameters)]=advancedSearchParameters - [piwikSiteId]=piwikSiteId + [piwikSiteId]=piwikSiteId [(connectCommunityId)]=connectCommunityId > ` @@ -92,7 +92,7 @@ properties: EnvProperties; } firstLoad = false; this.searchUtils.page = (params['page']=== undefined)?1:+params['page']; - + this.searchPage.connectCommunityId = this.connectCommunityId; var queryParameters = this.searchPage.getQueryParametersFromUrl(params); this._getResults(queryParameters, refine, this.searchUtils.page, this.searchUtils.size); diff --git a/searchPages/simple/searchPublications.component.ts b/searchPages/simple/searchPublications.component.ts index 5b12706b..8bd399eb 100644 --- a/searchPages/simple/searchPublications.component.ts +++ b/searchPages/simple/searchPublications.component.ts @@ -31,7 +31,7 @@ import{EnvProperties} from '../../utils/properties/env-properties'; searchFormClass="publicationsSearchForm" [(openaireLink)]=openaireLink [(advancedSearchParameters)]=advancedSearchParameters - [piwikSiteId]=piwikSiteId + [piwikSiteId]=piwikSiteId [(connectCommunityId)]=connectCommunityId > @@ -104,6 +104,7 @@ properties: EnvProperties; } firstLoad = false; this.searchUtils.page = (params['page']=== undefined)?1:+params['page']; + this.searchPage.connectCommunityId = this.connectCommunityId; var queryParameters = this.searchPage.getQueryParametersFromUrl(params); this._getResults(queryParameters, refine, this.searchUtils.page, this.searchUtils.size); }); diff --git a/searchPages/simple/searchSoftware.component.ts b/searchPages/simple/searchSoftware.component.ts index 73c56eee..8989f949 100644 --- a/searchPages/simple/searchSoftware.component.ts +++ b/searchPages/simple/searchSoftware.component.ts @@ -28,7 +28,7 @@ import{EnvProperties} from '../../utils/properties/env-properties'; searchFormClass="softwareSearchForm" [(openaireLink)]=openaireLink [(advancedSearchParameters)]=advancedSearchParameters - [piwikSiteId]=piwikSiteId + [piwikSiteId]=piwikSiteId [(connectCommunityId)]=connectCommunityId > ` @@ -93,7 +93,7 @@ properties: EnvProperties; } firstLoad = false; this.searchUtils.page = (params['page']=== undefined)?1:+params['page']; - + this.searchPage.connectCommunityId = this.connectCommunityId; var queryParameters = this.searchPage.getQueryParametersFromUrl(params); this._getResults(queryParameters, refine, this.searchUtils.page, this.searchUtils.size);