Skip to content

Commit

Permalink
Hide unknown or missing values from being filter values
Browse files Browse the repository at this point in the history
  • Loading branch information
ommann committed Feb 29, 2024
1 parent 156b730 commit 8e5f134
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,12 @@ <h2>Julkaisut - {{total$ | async}}</h2>

tulosta / sivu

<a href='#'>Mitä julkaisutietoja palvelu sisältää?</a>
<a [routerLink]='["/service-info"]' fragment='service-info2'>
<ng-container i18n="@@publication2.contentInfo">
Mitä julkaisutietoja palvelu sisältää?
</ng-container>
</a>

</div>
</div>
</div>
Expand Down Expand Up @@ -783,6 +788,12 @@ <h2>Julkaisut - {{total$ | async}}</h2>
</ng-container>
</ng-container>

<!-- make "pill" for running clearFilters -->
<div style='display: inline-flex; align-items: center; background-color: white; border: 2px solid #4546b9; padding: 7px 3px; border-radius: 4px; cursor: pointer; font-weight: bold; margin: 4px' (click)='clearFilters()'>
<div style='font-size: 0.8rem; padding-left: 8px'>Tyhjennä rajaukset</div>
<i class='fa fa-times' style='padding-left: 7px; padding-right: 8px' aria-hidden='true'></i>
</div>

</div>
</ng-container>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
HighlightedPublication,
Publication2Service, SearchParams
} from '@portal/services/publication2.service';
import { map, take, tap } from 'rxjs/operators';
import { filter, map, take, tap } from 'rxjs/operators';
import { SharedModule } from '@shared/shared.module';
import { SearchBar2Component } from '@portal/search-bar2/search-bar2.component';
import { NgArrayPipesModule, NgMathPipesModule } from 'ngx-pipes';
Expand Down Expand Up @@ -127,6 +127,17 @@ export class Publications2Component implements OnDestroy {
this.filterCount$.next(count);
}

clearFilters() {
this.router.navigate([], {
relativeTo: this.route,
queryParams: {
q: this.keywords,
page: this.page.toString(),
size: this.size.toString(),
}
});
}

displayedColumns: string[] = ['icon', 'publicationName', 'authorsText', 'publisherName', 'publicationYear'];

highlights$ = this.publications2Service.getSearch(); // TODO: /*: Observable<HighlightedPublication[]>*/
Expand Down Expand Up @@ -192,6 +203,7 @@ export class Publications2Component implements OnDestroy {

publicationFormatAdditions$ = this.aggregations$.pipe(
map(aggs => getPublicationFormatAdditions(aggs).map((bucket: any) => ({ id: bucket.key, count: bucket.doc_count })) ?? []),
map(aggs => aggs.filter(publicationFormatAddition => publicationFormatAddition.id !== "-1")),
map(aggs => aggs.sort((a, b) => b.count - a.count))
);

Expand All @@ -209,6 +221,7 @@ export class Publications2Component implements OnDestroy {

publicationAudienceAdditions$ = this.aggregations$.pipe(
map(aggs => getPublicationAudienceAdditions(aggs).map((bucket: any) => ({ id: bucket.key, count: bucket.doc_count })) ?? []),
map(aggs => aggs.filter(publicationAudienceAddition => publicationAudienceAddition.id !== "-1")),
map(aggs => aggs.sort((a, b) => b.count - a.count))
);

Expand All @@ -224,7 +237,8 @@ export class Publications2Component implements OnDestroy {

peerReviewedAdditions$ = this.aggregations$.pipe(
map(aggs => getPeerReviewedAdditions(aggs).map((bucket: any) => ({ id: bucket.key, count: bucket.doc_count })) ?? []),
map(aggs => aggs.sort((a, b) => b.count - a.count))
map(aggs => aggs.filter(peerReviewedAddition => ![' ', '-1'].includes(peerReviewedAddition.id))),
map(aggs => aggs.sort((a, b) => b.count - a.count)),
);

peerReviewedNames$ = this.publications2Service.getPeerReviewedNames();
Expand All @@ -241,11 +255,13 @@ export class Publications2Component implements OnDestroy {

parentPublicationTypeAdditions$ = this.aggregations$.pipe(
map(aggs => getParentPublicationTypeAdditions(aggs).map((bucket: any) => ({ id: bucket.key, count: bucket.doc_count })) ?? []),
map(aggs => aggs.filter(parentPublicationTypeAddition => parentPublicationTypeAddition.id !== "-1")),
map(aggs => aggs.sort((a, b) => b.count - a.count))
);

publisherInternationalityAdditions$ = this.aggregations$.pipe(
map(aggs => getPublisherInternationalityAdditions(aggs).map((bucket: any) => ({ id: bucket.key.toString(), count: bucket.doc_count })) ?? []),
map(aggs => aggs.filter(internationalPublicationAddition => internationalPublicationAddition.id !== "9")),
map(aggs => aggs.sort((a, b) => b.count - a.count))
);

Expand Down
8 changes: 3 additions & 5 deletions src/app/portal/components/results/results.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,9 @@ <h1 #srHeader aria-live="polite" class="sr-only"></h1>
Mitä rahoitushakutietoja palvelu sisältää?
</ng-container>

<ng-container *ngIf="selectedTabData.singular !== 'Rahoitushaku'" i18n="@@resultInfo1">Mitä</ng-container
><span *ngIf="selectedTabData.singular !== 'Rahoitushaku'"> {{ selectedTabData?.singular.toLowerCase() }}</span>
<ng-container *ngIf="selectedTabData.singular !== 'Rahoitushaku'" i18n="@@resultInfo2"
>tietoja palvelu sisältää?</ng-container
>
<ng-container *ngIf="selectedTabData.singular !== 'Rahoitushaku'" i18n="@@resultInfo1">Mitä</ng-container>
<span *ngIf="selectedTabData.singular !== 'Rahoitushaku'"> {{ selectedTabData?.singular.toLowerCase() }}</span>
<ng-container *ngIf="selectedTabData.singular !== 'Rahoitushaku'" i18n="@@resultInfo2">tietoja palvelu sisältää?</ng-container>
</strong>
</a>
</div>
Expand Down
7 changes: 6 additions & 1 deletion src/app/portal/search-bar2/search-bar2.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@
tabindex='0'
/>

<button matRipple style='display:flex; justify-content: center; align-items: center; background-color: white; height: 55px; width: 115px; margin-right: 8px' (click)='search.emit(keywords)'>
<button matRipple style='display: flex; justify-content: center; align-items: center; background-color: white; height: 55px; width: 115px; margin-right: 8px' (click)='search.emit(keywords)'>
Hae
</button>

<div matRipple i18n='@@searchHelpButton' style='cursor: pointer; user-select: none; color: white; font-size: 14px; padding: 0 1rem; display: flex; justify-content: center; align-items: center; margin-right: 8px' (click)='instructions.emit()'>
Hakuohje
<i class='fas fa-chevron-down' style='margin-left: 0.5rem'></i>
</div>
</div>
3 changes: 3 additions & 0 deletions src/app/portal/search-bar2/search-bar2.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ export class SearchBar2Component {
// search is pressed output
@Output() search = new EventEmitter<string>();

// instruction button is pressed output
@Output() instructions = new EventEmitter<void>();

public keywords = this.route.snapshot.queryParams.q ?? "";

searchKeywords(keywords: string) {
Expand Down
8 changes: 8 additions & 0 deletions src/i18n/messages.en.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -6730,6 +6730,14 @@
<source>Haettaessa ISSN:ä: issn:"1234-1234"</source>
<target>When searching for ISSN: issn:"1234-1234"</target>
</trans-unit>



<trans-unit id="publication2.contentInfo">
<source>Mitä julkaisutietoja palvelu sisältää?</source>
<target>What publication information is included in the service?</target>
</trans-unit>

</body>
</file>
</xliff>
8 changes: 8 additions & 0 deletions src/i18n/messages.sv.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -6735,6 +6735,14 @@ uppgifter till datalagret för forskningsinformation. De gemensamma personuppgif
<source>Haettaessa ISSN:ä: issn:"1234-1234"</source>
<target>När du söker efter ISSN: issn:"1234-1234"</target>
</trans-unit>



<trans-unit id="publication2.contentInfo">
<source>Mitä julkaisutietoja palvelu sisältää?</source>
<target>Vilka publikationsuppgifter finns i tjänsten?</target>
</trans-unit>

</body>
</file>
</xliff>
7 changes: 7 additions & 0 deletions src/i18n/messages.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2726,6 +2726,13 @@
<trans-unit id="publication2.tutorial.8">
<source>Haettaessa ISSN:ä: issn:"1234-1234"</source>
</trans-unit>



<trans-unit id="publication2.contentInfo">
<source>Mitä julkaisutietoja palvelu sisältää?</source>
</trans-unit>

</body>
</file>
</xliff>

0 comments on commit 8e5f134

Please sign in to comment.