From 85690104779f73f5d2fbe88d2c49f5c6be3897de Mon Sep 17 00:00:00 2001 From: "argiro.kokogiannaki" Date: Thu, 12 Nov 2020 09:51:34 +0000 Subject: [PATCH] [Library|Trunk] Search Filters fix: - make them work for static filters (e.g datasource pages) - make it work when new filter is substring of selected filter (e.g 'Registry' & 'Registry of repositories') - make it work with and without quotes SEO: - datasource landing add description in meta tags - result landing make h2 the title in other versions (only one H1 per page) git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59820 d315682c-612b-4755-9ff5-7f18f6832af3 --- .../dataProvider/dataProvider.component.ts | 4 ++-- .../landing-header/landing-header.component.ts | 4 ++-- .../landing-utils/showTitle.component.ts | 11 +++++++++-- landingPages/result/resultLanding.component.html | 3 ++- searchPages/searchDataProviders.component.ts | 5 ++++- .../searchUtils/searchFilter.component.ts | 16 +++++++++++++--- 6 files changed, 32 insertions(+), 11 deletions(-) diff --git a/landingPages/dataProvider/dataProvider.component.ts b/landingPages/dataProvider/dataProvider.component.ts index d9e11676..c2330f64 100644 --- a/landingPages/dataProvider/dataProvider.component.ts +++ b/landingPages/dataProvider/dataProvider.component.ts @@ -238,8 +238,8 @@ export class DataProviderComponent { this.initTabs(); } this.showTabs = true; - this.updateTitle(this.dataProviderInfo.title.name); - this.updateDescription("Content provider, " + this.dataProviderInfo.title.name); + this.updateTitle(this.dataProviderInfo.title.name?this.dataProviderInfo.title.name:this.dataProviderInfo.officialName); + this.updateDescription(this.dataProviderInfo.description?this.dataProviderInfo.description: "Content provider, " + (this.dataProviderInfo.title.name?this.dataProviderInfo.title.name:this.dataProviderInfo.officialName)); if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) { this.subscriptions.push(this._piwikService.trackView(this.properties, this.dataProviderInfo.title.name, this.piwikSiteId).subscribe()); } diff --git a/landingPages/landing-utils/landing-header/landing-header.component.ts b/landingPages/landing-utils/landing-header/landing-header.component.ts index e65c092a..02a59b36 100644 --- a/landingPages/landing-utils/landing-header/landing-header.component.ts +++ b/landingPages/landing-utils/landing-header/landing-header.component.ts @@ -49,7 +49,7 @@ import {AlertModal} from "../../../utils/modal/alert"; class="under-curation">Under curation - +
@@ -75,7 +75,7 @@ export class LandingHeaderComponent { @Input() underCuration: boolean = false; @Input() modal: AlertModal; @Input() titleClass: string = null; - + @Input() isTitleH1:boolean =true; public removeUnknown(array: string[], type: boolean = false): string[] { if (type) { return this.removeDuplicates(array).filter(value => value.toLowerCase() !== 'unknown'); diff --git a/landingPages/landing-utils/showTitle.component.ts b/landingPages/landing-utils/showTitle.component.ts index 2d068045..4941f2ef 100644 --- a/landingPages/landing-utils/showTitle.component.ts +++ b/landingPages/landing-utils/showTitle.component.ts @@ -4,7 +4,13 @@ import {ActivatedRoute} from '@angular/router'; @Component({ selector: 'showTitle', template: ` -

+

+ +

+

+ +

+
@@ -33,7 +39,7 @@ import {ActivatedRoute} from '@angular/router';
No title available
- + ` }) @@ -43,6 +49,7 @@ export class ShowTitleComponent { @Input() title: { [key: string]: string }; @Input() iconClass:string; @Input() classNames: string = ""; + @Input() isH1:boolean = true; constructor () {} diff --git a/landingPages/result/resultLanding.component.html b/landingPages/result/resultLanding.component.html index c39facaa..18bd070c 100644 --- a/landingPages/result/resultLanding.component.html +++ b/landingPages/result/resultLanding.component.html @@ -506,7 +506,8 @@ [subTitle]="resultLandingInfo.subtitle" [authorLimit]="10" [showAllAuthors]="false" titleClass="title-grey-background" [entityType]="getTypeName()" [authors]="resultLandingInfo.authors" [types]="resultLandingInfo.types" - [year]="resultLandingInfo.date" [embargoEndDate]="resultLandingInfo.embargoEndDate"> + [year]="resultLandingInfo.date" [embargoEndDate]="resultLandingInfo.embargoEndDate" + [isTitleH1]="false">
{ this.loadPaging = true; if(params['page'] && this.searchUtils.page != params['page']) { @@ -148,6 +147,7 @@ export class SearchDataProvidersComponent { 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.filters = DatasourcesHelperClass.createFilters(this.type); } else { this.searchUtils.refineStatus = this.errorCodes.DONE; } @@ -256,6 +256,9 @@ export class SearchDataProvidersComponent { data => { let totalResults = data[0]; let results = data[1]; + if(refine && !(this.type == "all" || this.type == "deposit")){ + this.filtersReturned(refine, this.filters, totalResults, page); + } this.resultsReturned(refine, results, totalResults, page); this.searchPageUpdates.emit({disableForms: this.disableForms, disableRefineForms: this.disableRefineForms, searchUtils: this.searchUtils}); }, diff --git a/searchPages/searchUtils/searchFilter.component.ts b/searchPages/searchUtils/searchFilter.component.ts index c83654d6..9510c118 100644 --- a/searchPages/searchUtils/searchFilter.component.ts +++ b/searchPages/searchUtils/searchFilter.component.ts @@ -249,14 +249,14 @@ export class SearchFilterComponent implements OnInit, OnChanges{ params['qf']="false"; qf=true; } - if(params[filter.filterId] && params[filter.filterId].indexOf(encodeURIComponent(value.id))==-1 && !qf) { + if(params[filter.filterId] && this.checkIfValueIndexOf(params[filter.filterId].split(','),value.id)==-1 && !qf) { //has other values of this filter --> add this value params[filter.filterId] = params[filter.filterId] + ',' + '"' + encodeURIComponent(value.id) + '"'; - }else if(params[filter.filterId] && params[filter.filterId].indexOf(encodeURIComponent(value.id))!=-1) { + }else if(params[filter.filterId] && this.checkIfValueIndexOf(params[filter.filterId].split(','),value.id)!=-1) { // has this filter and the value -- > remove it let values = params[filter.filterId].split(','); - values.splice(values.indexOf('"' + encodeURIComponent(value.id)+'"'), 1); + values.splice(this.checkIfValueIndexOf(values,value.id), 1); params[filter.filterId] =values.join(','); if(values.length == 0){ delete params[filter.filterId]; @@ -268,4 +268,14 @@ export class SearchFilterComponent implements OnInit, OnChanges{ delete params['page']; return params; } + checkIfValueIndexOf(array, value){ + let encodedValue = encodeURIComponent(value); + if(array.indexOf(encodedValue)!=-1){ + return array.indexOf(encodedValue); + } + if(array.indexOf('"'+encodedValue+'"')!=-1){ + return array.indexOf('"'+encodedValue+'"'); + } + return -1; + } }