Add publication type filter
LocationBasedServices/smartguide/pipeline/head This commit looks good

This commit is contained in:
Steven Tischer
2026-07-16 21:18:44 +02:00
parent 53d19e5b72
commit ede9290643
3 changed files with 126 additions and 0 deletions
@@ -63,6 +63,50 @@
[showNormalizedPreview]="true"
(weightsChange)="onWeightsChange($event)"
(applyWeights)="onApplyWeights($event)">
<div class="weight-row timespan-row" style="display: block">
<mat-form-field
appearance="outline"
style="width: 100%; margin-bottom: -1.25em">
<mat-label>Art der Work</mat-label>
<mat-select
multiple
[ngModel]="selectedPubTypes()"
(ngModelChange)="onPubTypesChange($event)">
<div class="pub-type-search">
<mat-icon
class="search-icon"
style="
margin-left: 16px;
margin-right: 8px;
color: rgba(0, 0, 0, 0.54);
"
>search</mat-icon
>
<input
matInput
placeholder="Suchen..."
style="flex: 1; outline: none; border: none; padding: 12px 0"
[ngModel]="pubTypeSearchTerm()"
(ngModelChange)="pubTypeSearchTerm.set($event)"
(keydown)="onPubTypeKeydown($event)"
autocomplete="off" />
@if (pubTypeSearchTerm()) {
<button
mat-icon-button
(click)="pubTypeSearchTerm.set(''); $event.stopPropagation()"
style="margin-right: 8px; transform: scale(0.8)">
<mat-icon>close</mat-icon>
</button>
}
</div>
@for (pt of filteredPubTypes(); track pt) {
<mat-option [value]="pt">{{ pt }}</mat-option>
}
</mat-select>
</mat-form-field>
</div>
<div class="weight-row timespan-row">
<div class="weight-label">
<mat-icon class="icon-small">date_range</mat-icon>
@@ -108,3 +108,13 @@
width: 100%;
margin: 0;
}
::ng-deep .pub-type-search {
display: flex;
align-items: center;
position: sticky;
top: 0;
z-index: 10;
background: white;
border-bottom: 1px solid var(--sg-divider, rgba(0, 0, 0, 0.12));
}
@@ -9,6 +9,10 @@ import { MatCheckboxModule } from '@angular/material/checkbox';
import { MatIconModule } from '@angular/material/icon';
import { MatSliderModule } from '@angular/material/slider';
import { MatSnackBar } from '@angular/material/snack-bar';
import { FormsModule } from '@angular/forms';
import { MatSelectModule } from '@angular/material/select';
import { MatInputModule } from '@angular/material/input';
import { MatFormFieldModule } from '@angular/material/form-field';
import {
WeightMap,
@@ -37,6 +41,10 @@ import { SearchResultsStateService } from '../search-results-state.service';
MatCheckboxModule,
MatIconModule,
MatSliderModule,
FormsModule,
MatSelectModule,
MatInputModule,
MatFormFieldModule,
QueryParamPaginatorComponent,
WeightsSlidersComponent,
],
@@ -138,6 +146,66 @@ export class KeywordsToPersonsResultsComponent implements OnInit {
readonly timespanFrom = signal(this.minYear);
readonly timespanTo = signal(this.maxYear);
// publication types
readonly ALL_PUBLICATION_TYPES = [
'article',
'other',
'dataset',
'book-chapter',
'book',
'dissertation',
'preprint',
'paratext',
'libguides',
'review',
'letter',
'reference-entry',
'editorial',
'peer-review',
'report',
'standard',
'erratum',
'retraction',
'supplementary-materials',
'book-section',
'database',
'software',
'report-component',
'grant',
];
readonly pubTypeSearchTerm = signal('');
readonly selectedPubTypes = computed(() => {
const p = this.queryParams();
const val = p?.['pubType'];
if (!val) return [];
return Array.isArray(val) ? val : val.split(',');
});
readonly filteredPubTypes = computed(() => {
const term = this.pubTypeSearchTerm().toLowerCase();
if (!term) return this.ALL_PUBLICATION_TYPES;
return this.ALL_PUBLICATION_TYPES.filter((pt) =>
pt.toLowerCase().includes(term),
);
});
onPubTypesChange(selected: string[]) {
const val = selected.length > 0 ? selected.join(',') : null;
this.router.navigate([], {
relativeTo: this.route,
queryParams: { pubType: val, page: null },
queryParamsHandling: 'merge',
});
}
onPubTypeKeydown(event: KeyboardEvent) {
if (event.key === ' ') {
event.stopPropagation();
}
}
readonly authors = signal<RankedAuthor[]>([]);
readonly loading = signal(false);
@@ -246,6 +314,10 @@ export class KeywordsToPersonsResultsComponent implements OnInit {
const rawWeights = this.currentWeights().raw;
const request: KeywordToAuthorRequest = {
keywords: this.state.keywords(),
publication_types:
this.selectedPubTypes().length > 0
? this.selectedPubTypes()
: undefined,
weights: {
works: rawWeights['works'],
citation: rawWeights['citations'],