diff --git a/cache-interceptor.service.ts b/cache-interceptor.service.ts index 29b135e3..0a2c95c6 100644 --- a/cache-interceptor.service.ts +++ b/cache-interceptor.service.ts @@ -8,7 +8,10 @@ import { properties } from "../../environments/environment"; }) export class CacheInterceptorService implements HttpInterceptor { cachingRequests = [ + // Remove 2 following lines when bug with hidden refine filters is solved. "/resources2/?format=json&refine=true&fields=resultbestaccessright&fields=relfunder&fields=relfundinglevel0_id&fields=relproject&fields=instancetypename&fields=resultlanguagename&fields=community&fields=resulthostingdatasource&&fq=resultbestaccessright exact \"Open Access\"&type=results&page=0&size=0", + "/resources2/?format=json&refine=true&fields=funder&fields=fundinglevel0_id&fields=projectstartyear&fields=projectendyear&fields=projectecsc39&&type=projects&page=0&size=0", + "/resources2/?format=json&refine=true&fields=resultbestaccessright&fields=relfunder&fields=instancetypename&fields=resultlanguagename&fields=community&fields=resulthostingdatasource&&type=results&page=0&size=0", "/resources2/?format=json&refine=true&fields=resultbestaccessright&fields=relfunder&fields=relfundinglevel0_id&fields=relproject&fields=instancetypename&fields=resultlanguagename&fields=community&fields=resulthostingdatasource&&fq=resultbestaccessright%20exact%20%22Open%20Access%22&fq=relfunder%20exact%20%22ec__________%3A%3AEC%7C%7CEuropean%20Commission%7C%7CEC%22&type=results&page=0&size=0", diff --git a/searchPages/searchDataProviders.component.ts b/searchPages/searchDataProviders.component.ts index 82250cdc..a4c8bab9 100644 --- a/searchPages/searchDataProviders.component.ts +++ b/searchPages/searchDataProviders.component.ts @@ -120,46 +120,39 @@ export class SearchDataProvidersComponent { this.oldTotalResults = this.searchUtils.totalResults; } var refine = true; - if ( - (this.searchUtils.page != ((params['page'] === undefined) ? 1 : +params['page']) - && (this.searchUtils.page == 1 || params['page'])) - && this.filters && !firstLoad - ) { - refine = false; - } - if ( - ( - this.searchUtils.size != ((params['size'] === undefined) ? 10 : +params['size']) - && (this.searchUtils.size == 10 || params['size']) - ) - && this.filters && !firstLoad) { + if (params['page'] != undefined && this.filters && !firstLoad && this.searchUtils.page != +params['page']) { refine = false; - this.searchUtils.status = this.errorCodes.DONE; } - let page = (params['page']=== undefined)?0:+params['page']; - this.searchUtils.page = ( page < 1 ) ? 1 : page; + if (params['size'] != undefined && this.filters && !firstLoad && this.searchUtils.size != params['size']) { + refine = false; + } - this.searchUtils.size = (params['size']=== undefined)?10:+params['size']; - if(this.searchUtils.size != 5 && this.searchUtils.size != 10 && this.searchUtils.size != 20 && this.searchUtils.size != 50) { - this.searchUtils.size = 10; - } + let page = (params['page']=== undefined)?0:+params['page']; + this.searchUtils.page = ( page < 1 ) ? 1 : page; - this.searchPage.fieldIds = this.fieldIds; - this.selectedFields =[]; - if(this.type == "deposit"){ - this.searchPage.keywordFields = this.searchFields.DEPOSIT_DATASOURCE_KEYWORD_FIELDS; - this.searchPage.usedBy = "deposit"; - } - // console.log(this.refineFields) - this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, [], this.fieldIdsMap,this.customFilter,params, "dataprovider"); - if(refine && (this.type == "all" || this.type == "deposit")) { - this._getFilters(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, 0, true, this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad)); - } else if(refine) { // static filters - this.searchUtils.refineStatus = this.errorCodes.LOADING; - } - this.getResults(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, this.searchUtils.size, refine, this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad)); - firstLoad = false; + this.searchUtils.size = (params['size']=== undefined)?10:+params['size']; + if(this.searchUtils.size != 5 && this.searchUtils.size != 10 && this.searchUtils.size != 20 && this.searchUtils.size != 50) { + this.searchUtils.size = 10; + } + + this.searchPage.fieldIds = this.fieldIds; + this.selectedFields =[]; + if(this.type == "deposit"){ + this.searchPage.keywordFields = this.searchFields.DEPOSIT_DATASOURCE_KEYWORD_FIELDS; + this.searchPage.usedBy = "deposit"; + } + // console.log(this.refineFields) + this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, [], this.fieldIdsMap,this.customFilter,params, "dataprovider"); + if(refine && (this.type == "all" || this.type == "deposit")) { + this._getFilters(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, 0, true, this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad)); + } else if(refine) { // static filters + this.searchUtils.refineStatus = this.errorCodes.LOADING; + } else { + this.searchUtils.refineStatus = this.errorCodes.DONE; + } + this.getResults(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, this.searchUtils.size, refine, this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad)); + firstLoad = false; })); } ngOnDestroy() { @@ -244,7 +237,10 @@ export class SearchDataProvidersComponent { this.filters = this.searchPage.prepareFiltersToShow(this.filters, this.searchUtils.totalResults); this.searchUtils.refineStatus = this.errorCodes.DONE; } - // this.searchPage.updateBaseUrlWithParameters(); + + this.searchPage.hideFilters = false; + + // this.searchPage.updateBaseUrlWithParameters(); //var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ @@ -287,7 +283,7 @@ export class SearchDataProvidersComponent { //this.searchPage.closeLoading(); this.disableForms = false; this.searchPageUpdates.emit({disableForms: this.disableForms, disableRefineForms: this.disableRefineForms, searchUtils: this.searchUtils}); - + this.searchPage.hideFilters = false; } )); } diff --git a/searchPages/searchOrganizations.component.ts b/searchPages/searchOrganizations.component.ts index 7a0f4877..7b523b71 100644 --- a/searchPages/searchOrganizations.component.ts +++ b/searchPages/searchOrganizations.component.ts @@ -110,23 +110,12 @@ export class SearchOrganizationsComponent { this.oldTotalResults = this.searchUtils.totalResults; } var refine = true; - if ( - ( - this.searchUtils.page != ((params['page'] === undefined) ? 1 : +params['page']) - && (this.searchUtils.page == 1 || params['page']) - ) - && this.filters && !firstLoad) { + if (params['page'] != undefined && this.filters && !firstLoad && this.searchUtils.page != +params['page']) { refine = false; } - if ( - ( - this.searchUtils.size != ((params['size'] === undefined) ? 10 : +params['size']) - && (this.searchUtils.size == 10 || params['size']) - ) - && this.filters && !firstLoad) { + if (params['size'] != undefined && this.filters && !firstLoad && this.searchUtils.size != params['size']) { refine = false; - this.searchUtils.status = this.errorCodes.DONE; } let page = (params['page']=== undefined)?1:+params['page']; @@ -146,6 +135,8 @@ export class SearchOrganizationsComponent { this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, [], this.fieldIdsMap,this.customFilter,params, "organization"); if(refine) { this._getFilters(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, 0, true, this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad)); + } else { + this.searchUtils.refineStatus = this.errorCodes.DONE; } this.getResults(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, this.searchUtils.size, refine, this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad)); firstLoad = false; @@ -223,7 +214,10 @@ export class SearchOrganizationsComponent { if(!refine) { this.searchPage.buildPageURLParameters(this.filters, [],false); } - // this.searchPage.updateBaseUrlWithParameters(); + + this.searchPage.hideFilters = false; + + // this.searchPage.updateBaseUrlWithParameters(); //var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ @@ -267,7 +261,7 @@ export class SearchOrganizationsComponent { //this.searchPage.closeLoading(); this.disableForms = false; this.searchPageUpdates.emit({disableForms: this.disableForms, disableRefineForms: this.disableRefineForms, searchUtils: this.searchUtils}); - + this.searchPage.hideFilters = false; } )); } diff --git a/searchPages/searchProjects.component.ts b/searchPages/searchProjects.component.ts index 1756e9c4..49c2a442 100644 --- a/searchPages/searchProjects.component.ts +++ b/searchPages/searchProjects.component.ts @@ -113,38 +113,12 @@ export class SearchProjectsComponent { this.oldTotalResults = this.searchUtils.totalResults; } var refine = true; - if ( - ( - this.searchUtils.page != ((params['page'] === undefined) ? 1 : +params['page']) - && (this.searchUtils.page == 1 || params['page']) - ) - && this.filters && !firstLoad - ) { + if (params['page'] != undefined && this.filters && !firstLoad && this.searchUtils.page != +params['page']) { refine = false; - this.searchUtils.status = this.errorCodes.DONE; } - if ( - ( - this.searchUtils.sortBy != ((params['sortBy'] === undefined) ? "" : params['sortBy']) - && (this.searchUtils.sortBy == "" || params['sortBy']) - ) - && this.filters && !firstLoad - ) { + if (params['size'] != undefined && this.filters && !firstLoad && this.searchUtils.size != params['size']) { refine = false; - - this.searchUtils.status = this.errorCodes.DONE; - } - - if ( - ( - this.searchUtils.size != ((params['size'] === undefined) ? 10 : +params['size']) - && (this.searchUtils.size == 10 || params['size']) - ) - && this.filters && !firstLoad - ) { - refine = false; - this.searchUtils.status = this.errorCodes.DONE; } let page = (params['page']=== undefined)?1:+params['page']; @@ -160,6 +134,8 @@ export class SearchProjectsComponent { this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, this.rangeFields, this.fieldIdsMap,this.customFilter,params, "project"); if(refine) { this._getFilters(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, 0, "", true, this.searchPage.getSearchAPIQueryForRangeFields(params)+this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad)); + } else { + this.searchUtils.refineStatus = this.errorCodes.DONE; } this.getResults(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, this.searchUtils.size, refine, this.searchPage.getSearchAPIQueryForRangeFields(params)+this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad)); firstLoad = false; @@ -242,6 +218,8 @@ export class SearchProjectsComponent { this.searchPage.buildPageURLParameters(this.filters, this.rangeFilters, false); } + this.searchPage.hideFilters = false; + //var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status = this.errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ @@ -285,7 +263,7 @@ export class SearchProjectsComponent { //this.searchPage.closeLoading(); this.disableForms = false; this.searchPageUpdates.emit({disableForms: this.disableForms, disableRefineForms: this.disableRefineForms, searchUtils: this.searchUtils}) - + this.searchPage.hideFilters = false; } )); } diff --git a/searchPages/searchResearchResults.component.ts b/searchPages/searchResearchResults.component.ts index e2d804d2..a5449f10 100644 --- a/searchPages/searchResearchResults.component.ts +++ b/searchPages/searchResearchResults.component.ts @@ -118,37 +118,16 @@ export class SearchResearchResultsComponent { this.oldTotalResults = this.searchUtils.totalResults; } var refine = true; - if ( - ( - this.searchUtils.page != ((params['page'] === undefined) ? 1 : +params['page']) - && (this.searchUtils.page == 1 || params['page']) - ) - && this.filters && !firstLoad - ) { + if (params['page'] != undefined && this.filters && !firstLoad && this.searchUtils.page != +params['page']) { refine = false; - this.searchUtils.status = this.errorCodes.DONE; } - if ( - ( - this.searchUtils.sortBy != ((params['sortBy'] === undefined) ? "" : params['sortBy']) - && (this.searchUtils.sortBy == "" || params['sortBy']) - ) - && this.filters && !firstLoad - ) { + if (params['sortBy'] != undefined && this.filters && !firstLoad && this.searchUtils.sortBy != params['sortBy']) { refine = false; - this.searchUtils.status = this.errorCodes.DONE; } - if ( - ( - this.searchUtils.size != ((params['size'] === undefined) ? 10 : +params['size']) - && (this.searchUtils.size == 10 || params['size']) - ) - && this.filters && !firstLoad - ) { + if (params['size'] != undefined && this.filters && !firstLoad && this.searchUtils.size != params['size']) { refine = false; - this.searchUtils.status = this.errorCodes.DONE; } let page = (params['page'] === undefined) ? 1 : +params['page']; @@ -167,6 +146,8 @@ export class SearchResearchResultsComponent { this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, this.rangeFields, this.fieldIdsMap,this.customFilter,params, this.resultType, this.quickFilter); if(refine) { this._getFilters(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, 0, "", true, this.searchPage.getSearchAPIQueryForRangeFields(params)+this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad)); + } else { + this.searchUtils.refineStatus = this.errorCodes.DONE; } 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; @@ -243,6 +224,8 @@ export class SearchResearchResultsComponent { this.searchPage.buildPageURLParameters(this.filters, this.rangeFilters, false); } + this.searchPage.hideFilters = false; + this.searchUtils.status = this.errorCodes.DONE; if (this.searchUtils.totalResults == 0) { this.searchUtils.status = this.errorCodes.NONE; @@ -283,7 +266,7 @@ export class SearchResearchResultsComponent { //this.searchPage.closeLoading(); this.disableForms = false; this.searchPageUpdates.emit({disableForms: this.disableForms, disableRefineForms: this.disableRefineForms, searchUtils: this.searchUtils}) - + this.searchPage.hideFilters = false; } )); } diff --git a/searchPages/searchUtils/newSearchPage.component.html b/searchPages/searchUtils/newSearchPage.component.html index 83fd1d62..3e40e40e 100644 --- a/searchPages/searchUtils/newSearchPage.component.html +++ b/searchPages/searchUtils/newSearchPage.component.html @@ -83,8 +83,9 @@
-
+ +
Filters
- - -
+
No filters available
+ diff --git a/searchPages/searchUtils/newSearchPage.component.ts b/searchPages/searchUtils/newSearchPage.component.ts index 1e135162..90d01dc5 100644 --- a/searchPages/searchUtils/newSearchPage.component.ts +++ b/searchPages/searchUtils/newSearchPage.component.ts @@ -30,7 +30,6 @@ declare var UIkit: any; }) export class NewSearchPageComponent { @ViewChild('offcanvas_element') offcanvasElement: ElementRef; - @Input() piwikSiteId = null; @Input() hasPrefix: boolean = true; @Input() pageTitle = ""; @@ -108,6 +107,9 @@ export class NewSearchPageComponent { @Input() entitiesSelection:boolean = true; @Input() showAdvancedSearchLink:boolean = true; + // on 1st load, do not show filters until results query returns. + public hideFilters: boolean = true; + //Dashboard filterToggle = false; customFilterEnabled:boolean = false; @@ -485,6 +487,13 @@ export class NewSearchPageComponent { return this.rangeFilters; } + get existingFiltersWithValues() { + if(this.filters.length == 0) { + return 0; + } + return this.filters.some(filter => (filter.values && filter.values.length > 0)); + } + /* * For Funder filters - if funder selected */ @@ -1165,13 +1174,13 @@ public static createRangeFilterQuery(rangeField,selectedFromValue, selectedToVal this.parameterValues.push(StringUtils.URIEncode(this.selectedFields[i].value)); } } - if (includePage && this.searchUtils.page != 1) { + if (includePage) { this.parameterNames.push("page"); this.parameterValues.push("" + this.searchUtils.page); } //if (this.searchUtils.size != this.resultsPerPage) { - if (this.resultsPerPageChanged && this.resultsPerPageChanged != this.resultsPerPage) { + if (this.resultsPerPageChanged) { this.parameterNames.push("size"); //this.parameterValues.push("" + this.searchUtils.size); this.parameterValues.push("" + this.resultsPerPageChanged); diff --git a/searchPages/searchUtils/searchFilter.component.html b/searchPages/searchUtils/searchFilter.component.html index c7b251c6..bf199d1d 100644 --- a/searchPages/searchUtils/searchFilter.component.html +++ b/searchPages/searchUtils/searchFilter.component.html @@ -9,47 +9,10 @@ + + + +