Merge branch 'dev' into feat/ranking
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
import { WorkPrimaryCategory } from '../../api';
|
||||
|
||||
export const workPrimaryCategoryLabels: Record<WorkPrimaryCategory, string> = {
|
||||
[WorkPrimaryCategory.AppliedResearch]: 'Anwendungsbasierte Forschung',
|
||||
[WorkPrimaryCategory.BasicResearch]: 'Grundlagenforschung',
|
||||
[WorkPrimaryCategory.ExperimentalDevelopment]: 'Experimentelle Entwicklung',
|
||||
[WorkPrimaryCategory.NonResearch]: 'Nicht-forschende Tätigkeit',
|
||||
[WorkPrimaryCategory.NotClassified]: 'Nicht klassifiziert',
|
||||
};
|
||||
|
||||
export const transformWorkPrimaryCategory = (
|
||||
value: WorkPrimaryCategory | null | undefined,
|
||||
): string => {
|
||||
if (!value) {
|
||||
return '';
|
||||
}
|
||||
return workPrimaryCategoryLabels[value] || value;
|
||||
};
|
||||
|
||||
@Pipe({
|
||||
name: 'workPrimaryCategory',
|
||||
})
|
||||
export class WorkPrimaryCategoryPipe implements PipeTransform {
|
||||
transform(
|
||||
value: WorkPrimaryCategory | null | undefined,
|
||||
...args: unknown[]
|
||||
): unknown {
|
||||
return transformWorkPrimaryCategory(value);
|
||||
}
|
||||
}
|
||||
@@ -1,24 +1,9 @@
|
||||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
import { findWorkTypeById } from '../ui/searchable-work-type-select/searchable-work-type-select.component';
|
||||
|
||||
export const translateWorkType = (value: string | null | undefined): string => {
|
||||
switch (value) {
|
||||
case 'article':
|
||||
return 'Artikel';
|
||||
case 'book':
|
||||
return 'Buch';
|
||||
case 'book-chapter':
|
||||
return 'Buchkapitel';
|
||||
case 'dataset':
|
||||
return 'Datensatz';
|
||||
case 'dissertation':
|
||||
return 'Dissertation';
|
||||
case 'report':
|
||||
return 'Bericht';
|
||||
case 'preprint':
|
||||
return 'Preprint';
|
||||
default:
|
||||
return value ?? 'Unbekannter Typ';
|
||||
}
|
||||
const workType = findWorkTypeById(value ?? '');
|
||||
return workType ? workType.name : '';
|
||||
};
|
||||
|
||||
@Pipe({
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
<div class="content">
|
||||
@if (showTitleFilter()) {
|
||||
<app-query-param-input
|
||||
[queryParamKey]="titleQueryParamKey()"
|
||||
label="Suchen nach Titel"
|
||||
placeholder="Suche"
|
||||
[debounceTime]="300" />
|
||||
}
|
||||
<div class="select-area">
|
||||
@if (showYearFilter()) {
|
||||
<app-searchable-year-select
|
||||
[label]="yearLabel()"
|
||||
[selectedYears]="selectedYears()"
|
||||
(handleYearSelectChange)="handleYearSelectChange($event)" />
|
||||
}
|
||||
@if (showWorkTypeFilter()) {
|
||||
<app-searchable-work-type-select
|
||||
[label]="workTypeLabel()"
|
||||
[selectedWorkTypes]="selectedWorkTypes()"
|
||||
(handleWorkTypeSelectChange)="handleWorkTypeSelectChange($event)" />
|
||||
}
|
||||
@if (showLanguageFilter()) {
|
||||
<app-searchable-language-select
|
||||
[label]="languageLabel()"
|
||||
[selectedLanguages]="selectedLanguages()"
|
||||
(handleLanguageSelectChange)="handleLanguageSelectChange($event)" />
|
||||
}
|
||||
@if (showAuthorFilter()) {
|
||||
<app-searchable-author-select
|
||||
[label]="authorLabel()"
|
||||
[selectedAuthors]="selectedAuthors()"
|
||||
(handleAuthorSelectChange)="handleAuthorSelectChange($event)" />
|
||||
}
|
||||
@if (showInstitutionFilter()) {
|
||||
<app-searchable-institution-select
|
||||
[label]="institutionLabel()"
|
||||
[selectedInstitutions]="selectedInstitutions()"
|
||||
(handleInstitutionSelectChange)="
|
||||
handleInstitutionSelectChange($event)
|
||||
" />
|
||||
}
|
||||
@if (showTopicFilter()) {
|
||||
<app-searchable-topic-select
|
||||
[label]="topicLabel()"
|
||||
[selectedTopics]="selectedTopics()"
|
||||
(handleTopicSelectChange)="handleTopicSelectChange($event)" />
|
||||
}
|
||||
<button mat-stroked-button color="primary" (click)="resetFilters()">
|
||||
<mat-icon>filter_alt_off</mat-icon>
|
||||
Filter zurücksetzen
|
||||
</button>
|
||||
</div>
|
||||
<app-selected-filters [observers]="observers" />
|
||||
</div>
|
||||
@@ -0,0 +1,13 @@
|
||||
.content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.select-area {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
flex-wrap: wrap;
|
||||
width: 100%;
|
||||
align-items: center;
|
||||
}
|
||||
@@ -0,0 +1,354 @@
|
||||
import { Component, computed, input } from '@angular/core';
|
||||
import { SearchableTopicSelectComponent } from '../searchable-topic-select/searchable-topic-select.component';
|
||||
import { SearchableYearSelectComponent } from '../searchable-year-select/searchable-year-select.component';
|
||||
import { Author, Institution, Topic } from '../../../api';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { workQueryParamKeys } from '../../../resolvers/work-page.resolver';
|
||||
import { toSignal } from '@angular/core/rxjs-interop';
|
||||
import { SearchableInstitutionSelectComponent } from '../searchable-institution-select/searchable-institution-select.component';
|
||||
import {
|
||||
findWorkTypeById,
|
||||
SearchableWorkTypeSelectComponent,
|
||||
WorkType,
|
||||
} from '../searchable-work-type-select/searchable-work-type-select.component';
|
||||
import {
|
||||
findLanguageById,
|
||||
Language,
|
||||
SearchableLanguageSelectComponent,
|
||||
} from '../searchable-language-select/searchable-language-select.component';
|
||||
import { SearchableAuthorSelectComponent } from '../searchable-author-select/searchable-author-select.component';
|
||||
import { QueryParamInputComponent } from '../query-param-input/query-param-input.component';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import {
|
||||
FilterObserver,
|
||||
SelectedFiltersComponent,
|
||||
} from '../selected-filters/selected-filters.component';
|
||||
import { translateWorkType } from '../../pipes/work-type.pipe';
|
||||
import { translateLanguageCode } from '../../pipes/language-code.pipe';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
|
||||
@Component({
|
||||
selector: 'app-publication-filter',
|
||||
imports: [
|
||||
MatButtonModule,
|
||||
MatIconModule,
|
||||
SearchableTopicSelectComponent,
|
||||
SearchableYearSelectComponent,
|
||||
SearchableInstitutionSelectComponent,
|
||||
SearchableWorkTypeSelectComponent,
|
||||
SearchableLanguageSelectComponent,
|
||||
SearchableAuthorSelectComponent,
|
||||
QueryParamInputComponent,
|
||||
SelectedFiltersComponent,
|
||||
],
|
||||
templateUrl: './publication-filters.component.html',
|
||||
styleUrl: './publication-filters.component.scss',
|
||||
})
|
||||
export class PublicationFilterComponent {
|
||||
constructor(private readonly router: Router) {}
|
||||
|
||||
selectedAuthors = input<Author[]>([]);
|
||||
selectedTopics = input<Topic[]>([]);
|
||||
selectedInstitutions = input<Institution[]>([]);
|
||||
|
||||
showTitleFilter = input<boolean>(true);
|
||||
showYearFilter = input<boolean>(true);
|
||||
showWorkTypeFilter = input<boolean>(true);
|
||||
showLanguageFilter = input<boolean>(true);
|
||||
showAuthorFilter = input<boolean>(true);
|
||||
showInstitutionFilter = input<boolean>(true);
|
||||
showTopicFilter = input<boolean>(true);
|
||||
|
||||
observers: FilterObserver[] = [
|
||||
{
|
||||
id: 'search',
|
||||
queryParamKey: workQueryParamKeys.title,
|
||||
icon: 'search',
|
||||
},
|
||||
{
|
||||
id: 'types',
|
||||
queryParamKey: workQueryParamKeys.types,
|
||||
icon: 'category',
|
||||
valueFormatter: (value: string) => {
|
||||
return translateWorkType(value) || value;
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'years',
|
||||
queryParamKey: workQueryParamKeys.years,
|
||||
icon: 'calendar_today',
|
||||
},
|
||||
{
|
||||
id: 'languages',
|
||||
queryParamKey: workQueryParamKeys.language,
|
||||
icon: 'translate',
|
||||
valueFormatter: (value: string) => {
|
||||
return translateLanguageCode(value) || value;
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'authors',
|
||||
queryParamKey: workQueryParamKeys.authorId,
|
||||
icon: 'person',
|
||||
valueFormatter: (value: string) => {
|
||||
const author = this.selectedAuthors().find((a) => a.id === value);
|
||||
console.log('Authors', this.selectedAuthors());
|
||||
return author ? author.display_name : value;
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'topics',
|
||||
queryParamKey: workQueryParamKeys.topicId,
|
||||
icon: 'label',
|
||||
valueFormatter: (value: string) => {
|
||||
const topic = this.selectedTopics().find((t) => t.id === value);
|
||||
return topic ? topic.display_name : value;
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
queryParamMap = toSignal(this.router.routerState.root.queryParamMap, {
|
||||
initialValue: this.router.routerState.snapshot.root.queryParamMap,
|
||||
});
|
||||
|
||||
titleQueryParamKey = computed(() => workQueryParamKeys.title);
|
||||
|
||||
selectedYears = computed(() => {
|
||||
return this.queryParamMap().getAll(workQueryParamKeys.years).map(Number);
|
||||
});
|
||||
|
||||
yearLabel = computed(() => {
|
||||
const selectedYears = this.selectedYears();
|
||||
if (selectedYears.length === 0) {
|
||||
return 'Jahr';
|
||||
} else if (selectedYears.length === 1) {
|
||||
return selectedYears[0].toString();
|
||||
} else {
|
||||
return `${selectedYears.length} Jahre`;
|
||||
}
|
||||
});
|
||||
|
||||
handleYearSelectChange = (selectedYear: number): void => {
|
||||
if (this.selectedYears().includes(selectedYear)) {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[workQueryParamKeys.years]: this.selectedYears().filter(
|
||||
(year) => year !== selectedYear,
|
||||
),
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
} else {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[workQueryParamKeys.years]: [...this.selectedYears(), selectedYear],
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
selectedWorkTypes = computed(() => {
|
||||
const workTypeIds = this.queryParamMap().getAll(workQueryParamKeys.types);
|
||||
return workTypeIds
|
||||
.map((id) => findWorkTypeById(id))
|
||||
.filter((type) => type !== undefined) as WorkType[];
|
||||
});
|
||||
|
||||
workTypeLabel = computed(() => {
|
||||
const selectedWorkTypes = this.selectedWorkTypes();
|
||||
if (selectedWorkTypes.length === 0) {
|
||||
return 'Typ';
|
||||
} else if (selectedWorkTypes.length === 1) {
|
||||
return selectedWorkTypes[0].name;
|
||||
} else {
|
||||
return `${selectedWorkTypes.length} Typen`;
|
||||
}
|
||||
});
|
||||
|
||||
handleWorkTypeSelectChange = (selectedWorkType: WorkType): void => {
|
||||
if (this.selectedWorkTypes().some((t) => t.id === selectedWorkType.id)) {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[workQueryParamKeys.types]: this.selectedWorkTypes()
|
||||
.filter((t) => t.id !== selectedWorkType.id)
|
||||
.map((t) => t.id),
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
} else {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[workQueryParamKeys.types]: [
|
||||
...this.selectedWorkTypes().map((t) => t.id),
|
||||
selectedWorkType.id,
|
||||
],
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
selectedLanguages = computed(() => {
|
||||
const languageCodes = this.queryParamMap().getAll(
|
||||
workQueryParamKeys.language,
|
||||
);
|
||||
return languageCodes
|
||||
.map((code) => findLanguageById(code))
|
||||
.filter((lang) => lang !== undefined) as Language[];
|
||||
});
|
||||
|
||||
languageLabel = computed(() => {
|
||||
const selectedLanguages = this.selectedLanguages();
|
||||
if (selectedLanguages.length === 0) {
|
||||
return 'Sprache';
|
||||
} else if (selectedLanguages.length === 1) {
|
||||
return selectedLanguages[0].name;
|
||||
} else {
|
||||
return `${selectedLanguages.length} Sprachen`;
|
||||
}
|
||||
});
|
||||
|
||||
handleLanguageSelectChange = (selectedLanguage: Language): void => {
|
||||
if (
|
||||
this.selectedLanguages().some((l) => l.code === selectedLanguage.code)
|
||||
) {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[workQueryParamKeys.language]: this.selectedLanguages()
|
||||
.filter((l) => l.code !== selectedLanguage.code)
|
||||
.map((l) => l.code),
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
} else {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[workQueryParamKeys.language]: [
|
||||
...this.selectedLanguages().map((l) => l.code),
|
||||
selectedLanguage.code,
|
||||
],
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
authorLabel = computed(() => {
|
||||
const selectedAuthors = this.selectedAuthors();
|
||||
if (selectedAuthors.length === 0) {
|
||||
return 'Autor';
|
||||
} else if (selectedAuthors.length === 1) {
|
||||
return selectedAuthors[0].display_name ?? 'Autor';
|
||||
} else {
|
||||
return `${selectedAuthors.length} Autoren`;
|
||||
}
|
||||
});
|
||||
|
||||
handleAuthorSelectChange = (selectedAuthor: Author): void => {
|
||||
if (this.selectedAuthors().includes(selectedAuthor)) {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[workQueryParamKeys.authorId]: this.selectedAuthors()
|
||||
.filter((a) => a !== selectedAuthor)
|
||||
.map((a) => a.id),
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
} else {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[workQueryParamKeys.authorId]: [
|
||||
...this.selectedAuthors().map((a) => a.id),
|
||||
selectedAuthor.id,
|
||||
],
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
institutionLabel = computed(() => {
|
||||
const selectedInstitutions = this.selectedInstitutions();
|
||||
if (selectedInstitutions.length === 0) {
|
||||
return 'Institution';
|
||||
} else if (selectedInstitutions.length === 1) {
|
||||
return selectedInstitutions[0].display_name ?? 'Institution';
|
||||
} else {
|
||||
return `${selectedInstitutions.length} Institutionen`;
|
||||
}
|
||||
});
|
||||
|
||||
handleInstitutionSelectChange = (selectedInstitution: Institution): void => {
|
||||
if (this.selectedInstitutions().includes(selectedInstitution)) {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[workQueryParamKeys.institutionId]: this.selectedInstitutions()
|
||||
.filter((inst) => inst !== selectedInstitution)
|
||||
.map((inst) => inst.id),
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
} else {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[workQueryParamKeys.institutionId]: [
|
||||
...this.selectedInstitutions().map((inst) => inst.id),
|
||||
selectedInstitution.id,
|
||||
],
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
topicLabel = computed(() => {
|
||||
const selectedTopicIds = this.selectedTopics().map((t) => t.id);
|
||||
if (selectedTopicIds.length === 0) {
|
||||
return 'Thema';
|
||||
} else if (selectedTopicIds.length === 1) {
|
||||
const topic = this.selectedTopics()[0];
|
||||
return topic.display_name || 'Thema';
|
||||
} else {
|
||||
return `${selectedTopicIds.length} Themen`;
|
||||
}
|
||||
});
|
||||
|
||||
handleTopicSelectChange = (selectedTopic: Topic): void => {
|
||||
if (this.selectedTopics().some((t) => t.id === selectedTopic.id)) {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[workQueryParamKeys.topicId]: this.selectedTopics()
|
||||
.filter((t) => t.id !== selectedTopic.id)
|
||||
.map((t) => t.id),
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
} else {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[workQueryParamKeys.topicId]: [
|
||||
...this.selectedTopics().map((t) => t.id!),
|
||||
selectedTopic.id,
|
||||
],
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
resetFilters = (): void => {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[workQueryParamKeys.title]: null,
|
||||
[workQueryParamKeys.years]: null,
|
||||
[workQueryParamKeys.types]: null,
|
||||
[workQueryParamKeys.language]: null,
|
||||
[workQueryParamKeys.authorId]: null,
|
||||
[workQueryParamKeys.institutionId]: null,
|
||||
[workQueryParamKeys.topicId]: null,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
};
|
||||
}
|
||||
@@ -58,6 +58,19 @@
|
||||
}
|
||||
</ng-template>
|
||||
|
||||
<ng-template #classificationTmp let-work>
|
||||
@let classification = getWorkClassification(work.id);
|
||||
@if (classification) {
|
||||
<button type="button" class="cell-filter-pill" matTooltipPosition="above">
|
||||
{{
|
||||
classification.classification?.primary_category | workPrimaryCategory
|
||||
}}
|
||||
</button>
|
||||
} @else {
|
||||
<span class="empty-text">-</span>
|
||||
}
|
||||
</ng-template>
|
||||
|
||||
<ng-template #authorsTmp let-work>
|
||||
@let workAuthors = getWorkAuthors(work);
|
||||
@let workAuthorsExpanded = isWorkAuthorsExpanded(work);
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import {
|
||||
Component,
|
||||
computed,
|
||||
effect,
|
||||
inject,
|
||||
input,
|
||||
OnInit,
|
||||
signal,
|
||||
TemplateRef,
|
||||
viewChild,
|
||||
} from '@angular/core';
|
||||
@@ -16,6 +18,8 @@ import {
|
||||
InseWorksV2ModelWorkPage,
|
||||
Institution,
|
||||
Work,
|
||||
WorkClassification,
|
||||
WorksV2Service,
|
||||
WorkTopic,
|
||||
} from '../../../api';
|
||||
import { TopicChipComponent } from '../topic-chip/topic-chip.component';
|
||||
@@ -29,6 +33,7 @@ import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
import { topicHierarchyColor } from '../../../resolvers/utils/topic-colors';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { workQueryParamKeys } from '../../../resolvers/work-page.resolver';
|
||||
import { WorkPrimaryCategoryPipe } from '../../pipes/work-primary-category.pipe';
|
||||
|
||||
@Component({
|
||||
selector: 'app-publication-table',
|
||||
@@ -42,6 +47,7 @@ import { workQueryParamKeys } from '../../../resolvers/work-page.resolver';
|
||||
ChipComponent,
|
||||
WorkTypePipe,
|
||||
LanguageCodePipe,
|
||||
WorkPrimaryCategoryPipe,
|
||||
],
|
||||
templateUrl: './publication-table.component.html',
|
||||
styleUrl: './publication-table.component.scss',
|
||||
@@ -58,6 +64,7 @@ export class PublicationTableComponent implements OnInit {
|
||||
typeTmp = viewChild.required<TemplateRef<any>>('typeTmp');
|
||||
yearTmp = viewChild.required<TemplateRef<any>>('yearTmp');
|
||||
languageTmp = viewChild.required<TemplateRef<any>>('languageTmp');
|
||||
classificationTmp = viewChild.required<TemplateRef<any>>('classificationTmp');
|
||||
authorsTmp = viewChild.required<TemplateRef<any>>('authorsTmp');
|
||||
institutionsTmp = viewChild.required<TemplateRef<any>>('institutionsTmp');
|
||||
topicsTmp = viewChild.required<TemplateRef<any>>('topicsTmp');
|
||||
@@ -125,12 +132,19 @@ export class PublicationTableComponent implements OnInit {
|
||||
accessorKey: 'language',
|
||||
cellTemplate: this.languageTmp(),
|
||||
},
|
||||
{
|
||||
id: 'classification',
|
||||
header: 'Klassifikation',
|
||||
type: 'display',
|
||||
cellTemplate: this.classificationTmp(),
|
||||
},
|
||||
{
|
||||
id: 'authors',
|
||||
header: 'Autoren',
|
||||
type: 'display',
|
||||
cellTemplate: this.authorsTmp(),
|
||||
},
|
||||
|
||||
{
|
||||
id: 'institutions',
|
||||
header: 'Institutionen',
|
||||
@@ -160,6 +174,36 @@ export class PublicationTableComponent implements OnInit {
|
||||
];
|
||||
}
|
||||
|
||||
workIds = computed(
|
||||
() =>
|
||||
this.elements()
|
||||
.map((work) => work.id)
|
||||
.filter(Boolean) as string[],
|
||||
);
|
||||
|
||||
workClassifications = signal<WorkClassification[]>([]);
|
||||
|
||||
getWorkClassification(workId: string): WorkClassification | undefined {
|
||||
return this.workClassifications().find(
|
||||
(classification) => classification.work_id === workId,
|
||||
);
|
||||
}
|
||||
|
||||
constructor(private readonly worksV2Service: WorksV2Service) {
|
||||
effect(() => {
|
||||
const ids = this.workIds();
|
||||
if (ids.length > 0) {
|
||||
this.worksV2Service
|
||||
.getWorkClassificationsByWorkIds(ids)
|
||||
.subscribe((classificationPage) => {
|
||||
this.workClassifications.set(classificationPage.elements ?? []);
|
||||
});
|
||||
} else {
|
||||
this.workClassifications.set([]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
isTypeActive(type: string): boolean {
|
||||
return this.selectedTypesQueryParams().includes(type);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<mat-form-field style="width: 100%">
|
||||
<mat-form-field style="width: 100%" subscriptSizing="dynamic">
|
||||
<mat-label>{{ this.label() }}</mat-label>
|
||||
<input
|
||||
matInput
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
<app-searchable-select
|
||||
inputPlaceholder="Authoren suchen..."
|
||||
icon="person"
|
||||
[label]="label()"
|
||||
selectedLabel="Ausgewählte Authoren"
|
||||
fetchedLabel="Gefundene Authoren"
|
||||
[fetchElements]="fetchAuthors"
|
||||
[selectedElements]="selectedAuthors()"
|
||||
[getSelectLabel]="getAuthorLabel"
|
||||
[getSelectValue]="getAuthorValue"
|
||||
[getSelectDescription]="getAuthorDescription"
|
||||
(handleSelectChange)="handleAuthorSelectChange.emit($event)" />
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
import { Component, inject, input, output } from '@angular/core';
|
||||
import { Author, WorksV2Service } from '../../../api';
|
||||
import { Observable } from 'rxjs';
|
||||
import { SearchableSelectComponent } from '../searchable-select/searchable-select.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-searchable-author-select',
|
||||
imports: [SearchableSelectComponent],
|
||||
templateUrl: './searchable-author-select.component.html',
|
||||
styleUrl: './searchable-author-select.component.scss',
|
||||
})
|
||||
export class SearchableAuthorSelectComponent {
|
||||
private readonly worksV2Service = inject(WorksV2Service);
|
||||
|
||||
label = input<string>('Authoren');
|
||||
selectedAuthors = input.required<Author[]>();
|
||||
|
||||
handleAuthorSelectChange = output<Author>();
|
||||
|
||||
fetchAuthors = (searchTerm: string): Observable<Author[]> => {
|
||||
return this.worksV2Service.getAuthorAutocomplete(searchTerm);
|
||||
};
|
||||
|
||||
getAuthorLabel = (author: Author): string => {
|
||||
return author.display_name!;
|
||||
};
|
||||
|
||||
getAuthorValue = (author: Author): string => {
|
||||
return author.id!;
|
||||
};
|
||||
|
||||
getAuthorDescription = (author: Author): string => {
|
||||
const worksCount = author.works_count ?? 0;
|
||||
const worksCountText = worksCount === 1 ? 'Werk' : 'Werke';
|
||||
const lastKnownInstitution = author.last_known_institutions?.[0];
|
||||
const lastKnownInstitutionDisplayName =
|
||||
lastKnownInstitution?.display_name ?? 'Unbekannt';
|
||||
const lastKnownInstitutionCountryCode =
|
||||
lastKnownInstitution?.country_code ?? '??';
|
||||
return `${worksCount} ${worksCountText} - ${lastKnownInstitutionDisplayName} (${lastKnownInstitutionCountryCode})`;
|
||||
};
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
<app-searchable-select
|
||||
inputPlaceholder="Institution suchen..."
|
||||
icon="apartment"
|
||||
[label]="label()"
|
||||
selectedLabel="Ausgewählte Institutionen"
|
||||
fetchedLabel="Gefundene Institutionen"
|
||||
[fetchElements]="fetchInstitutions"
|
||||
[selectedElements]="selectedInstitutions()"
|
||||
[getSelectLabel]="getInstitutionLabel"
|
||||
[getSelectValue]="getInstitutionValue"
|
||||
[getSelectDescription]="getInstitutionDescription"
|
||||
(handleSelectChange)="handleInstitutionSelectChange.emit($event)" />
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
import { Component, inject, input, output } from '@angular/core';
|
||||
import { Institution, WorksV2Service } from '../../../api';
|
||||
import { Observable } from 'rxjs';
|
||||
import { SearchableSelectComponent } from '../searchable-select/searchable-select.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-searchable-institution-select',
|
||||
imports: [SearchableSelectComponent],
|
||||
templateUrl: './searchable-institution-select.component.html',
|
||||
styleUrl: './searchable-institution-select.component.scss',
|
||||
})
|
||||
export class SearchableInstitutionSelectComponent {
|
||||
private readonly worksV2Service = inject(WorksV2Service);
|
||||
|
||||
label = input<string>('Institutionen');
|
||||
selectedInstitutions = input.required<Institution[]>();
|
||||
|
||||
handleInstitutionSelectChange = output<Institution>();
|
||||
|
||||
fetchInstitutions = (searchTerm: string): Observable<Institution[]> => {
|
||||
return this.worksV2Service.getInstitutionAutocomplete(searchTerm);
|
||||
};
|
||||
|
||||
getInstitutionLabel = (institution: Institution): string => {
|
||||
return institution.display_name!;
|
||||
};
|
||||
|
||||
getInstitutionValue = (institution: Institution): string => {
|
||||
return institution.id!;
|
||||
};
|
||||
|
||||
getInstitutionDescription = (institution: Institution): string => {
|
||||
return institution.country_code + ' - ' + institution.type;
|
||||
};
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
<app-searchable-select
|
||||
inputPlaceholder="Sprache suchen..."
|
||||
icon="translate"
|
||||
[label]="label()"
|
||||
selectedLabel="Ausgewählte Sprachen"
|
||||
fetchedLabel="Weitere Sprachen"
|
||||
[fetchElements]="fetchLanguages"
|
||||
[selectedElements]="selectedLanguages()"
|
||||
[getSelectLabel]="getLanguageLabel"
|
||||
[getSelectValue]="getLanguageValue"
|
||||
(handleSelectChange)="handleLanguageSelectChange.emit($event)" />
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
import { Component, input, output } from '@angular/core';
|
||||
import { SearchableSelectComponent } from '../searchable-select/searchable-select.component';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
export interface Language {
|
||||
code: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export const languages: Language[] = [
|
||||
{ code: 'en', name: 'Englisch' },
|
||||
{ code: 'de', name: 'Deutsch' },
|
||||
{ code: 'fr', name: 'Französisch' },
|
||||
{ code: 'es', name: 'Spanisch' },
|
||||
{ code: 'it', name: 'Italienisch' },
|
||||
{ code: 'pt', name: 'Portugiesisch' },
|
||||
{ code: 'ru', name: 'Russisch' },
|
||||
{ code: 'zh', name: 'Chinesisch' },
|
||||
{ code: 'ja', name: 'Japanisch' },
|
||||
{ code: 'ko', name: 'Koreanisch' },
|
||||
];
|
||||
|
||||
export const findLanguageById = (id: string): Language | undefined => {
|
||||
return languages.find((language) => language.code === id);
|
||||
};
|
||||
|
||||
@Component({
|
||||
selector: 'app-searchable-language-select',
|
||||
imports: [SearchableSelectComponent],
|
||||
templateUrl: './searchable-language-select.component.html',
|
||||
styleUrl: './searchable-language-select.component.scss',
|
||||
})
|
||||
export class SearchableLanguageSelectComponent {
|
||||
label = input<string>('Typen');
|
||||
selectedLanguages = input.required<Language[]>();
|
||||
|
||||
handleLanguageSelectChange = output<Language>();
|
||||
|
||||
fetchLanguages = (searchTerm: string): Observable<Language[]> => {
|
||||
return new Observable<Language[]>((observer) => {
|
||||
observer.next(
|
||||
languages.filter((language) =>
|
||||
language.name.toLowerCase().includes(searchTerm.toLowerCase()),
|
||||
),
|
||||
);
|
||||
observer.complete();
|
||||
});
|
||||
};
|
||||
|
||||
getLanguageLabel = (language: Language): string => {
|
||||
return language.name;
|
||||
};
|
||||
|
||||
getLanguageValue = (language: Language): string => {
|
||||
return language.code;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<mat-form-field style="width: 100%" subscriptSizing="dynamic">
|
||||
@if (icon()) {
|
||||
<mat-icon matPrefix [fontIcon]="icon()"></mat-icon>
|
||||
}
|
||||
<mat-select
|
||||
canSelectNullableOptions
|
||||
(selectionChange)="handleSelectChange.emit($event.value)"
|
||||
[placeholder]="label()">
|
||||
<mat-select-trigger>{{ label() }}</mat-select-trigger>
|
||||
<div
|
||||
class="search-panel-header"
|
||||
(click)="$event.stopPropagation()"
|
||||
(keydown)="$event.stopPropagation()">
|
||||
<mat-icon matPrefix>search</mat-icon>
|
||||
<input
|
||||
matInput
|
||||
[placeholder]="inputPlaceholder()"
|
||||
[(ngModel)]="searchValue"
|
||||
(ngModelChange)="_handleValueChange($event)"
|
||||
(click)="$event.stopPropagation()"
|
||||
(keydown)="$event.stopPropagation()" />
|
||||
|
||||
<button
|
||||
mat-icon-button
|
||||
aria-label="Clear"
|
||||
(click)="_clearSearchValue(); $event.stopPropagation()">
|
||||
<mat-icon>close</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@if (isLoading()) {
|
||||
<mat-option disabled>Laden…</mat-option>
|
||||
} @else {
|
||||
@if (selectedElements().length > 0) {
|
||||
<mat-optgroup [label]="selectedLabel()">
|
||||
@for (
|
||||
element of selectedElements();
|
||||
track getSelectValue()(element)
|
||||
) {
|
||||
<mat-option [value]="element" selected>
|
||||
<mat-icon>check</mat-icon>
|
||||
{{ getSelectLabel()(element) }}
|
||||
@if (getSelectDescription()) {
|
||||
<span class="option-description">{{
|
||||
getSelectDescription()!(element)
|
||||
}}</span>
|
||||
}
|
||||
</mat-option>
|
||||
} @empty {
|
||||
<mat-option disabled>Keine Ergebnisse</mat-option>
|
||||
}
|
||||
</mat-optgroup>
|
||||
}
|
||||
<mat-optgroup [label]="fetchedLabel()">
|
||||
@for (element of fetchedElements(); track getSelectValue()(element)) {
|
||||
<mat-option [value]="element">
|
||||
{{ getSelectLabel()(element) }}
|
||||
@if (getSelectDescription()) {
|
||||
<span class="option-description">{{
|
||||
getSelectDescription()!(element)
|
||||
}}</span>
|
||||
}
|
||||
</mat-option>
|
||||
} @empty {
|
||||
<mat-option disabled>Keine Ergebnisse</mat-option>
|
||||
}
|
||||
</mat-optgroup>
|
||||
}
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
@@ -0,0 +1,18 @@
|
||||
.search-panel-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 8px 12px;
|
||||
gap: 8px;
|
||||
|
||||
input {
|
||||
flex: 1;
|
||||
border: none;
|
||||
outline: none;
|
||||
}
|
||||
}
|
||||
|
||||
.option-description {
|
||||
display: block;
|
||||
font-size: 12px;
|
||||
opacity: 0.6;
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
import {
|
||||
Component,
|
||||
computed,
|
||||
DestroyRef,
|
||||
inject,
|
||||
input,
|
||||
output,
|
||||
signal,
|
||||
} from '@angular/core';
|
||||
import { MatSelectModule } from '@angular/material/select';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import {
|
||||
BehaviorSubject,
|
||||
catchError,
|
||||
debounceTime,
|
||||
distinctUntilChanged,
|
||||
Observable,
|
||||
of,
|
||||
switchMap,
|
||||
tap,
|
||||
} from 'rxjs';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
|
||||
@Component({
|
||||
selector: 'app-searchable-select',
|
||||
imports: [
|
||||
MatSelectModule,
|
||||
MatInputModule,
|
||||
MatIconModule,
|
||||
MatButtonModule,
|
||||
FormsModule,
|
||||
],
|
||||
templateUrl: './searchable-select.component.html',
|
||||
styleUrl: './searchable-select.component.scss',
|
||||
})
|
||||
export class SearchableSelectComponent<T> {
|
||||
searchValue: string = '';
|
||||
handleSelectChange = output<T>();
|
||||
|
||||
_elements = computed<T[]>(() => {
|
||||
const predefined = this.selectedElements();
|
||||
const fetched = this.fetchedElements();
|
||||
return [...predefined, ...fetched];
|
||||
});
|
||||
isLoading = signal<boolean>(false);
|
||||
|
||||
icon = input<string>('');
|
||||
label = input.required<string>();
|
||||
selectedLabel = input<string>('Ausgewählt');
|
||||
fetchedLabel = input<string>('Verfügbar');
|
||||
fetchElements = input<(searchTerm: string) => Observable<T[]>>();
|
||||
fetchedElements = signal<T[]>([]);
|
||||
selectedElements = input<T[]>([]);
|
||||
getSelectLabel = input.required<(element: T) => string>();
|
||||
getSelectValue = input.required<(element: T) => string>();
|
||||
getSelectDescription = input<(element: T) => string>();
|
||||
|
||||
inputPlaceholder = input<string>('Suche');
|
||||
|
||||
private readonly searchTerms = new BehaviorSubject<string>('');
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
constructor() {
|
||||
this.searchTerms
|
||||
.pipe(
|
||||
debounceTime(300),
|
||||
distinctUntilChanged(),
|
||||
tap(() => this.isLoading.set(true)),
|
||||
switchMap((term) => {
|
||||
const fetchFn = this.fetchElements();
|
||||
if (!fetchFn) {
|
||||
return of([] as T[]);
|
||||
}
|
||||
return fetchFn(term).pipe(catchError(() => of([] as T[])));
|
||||
}),
|
||||
tap(() => this.isLoading.set(false)),
|
||||
takeUntilDestroyed(this.destroyRef),
|
||||
)
|
||||
.subscribe((results) => this.fetchedElements.set(results));
|
||||
}
|
||||
|
||||
_handleValueChange(newValue: string): void {
|
||||
this.searchValue = newValue;
|
||||
this.searchTerms.next(newValue);
|
||||
}
|
||||
|
||||
_clearSearchValue(): void {
|
||||
this.searchValue = '';
|
||||
this.fetchedElements.set([]);
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
<app-searchable-select
|
||||
inputPlaceholder="Thema suchen..."
|
||||
icon="label"
|
||||
[label]="label()"
|
||||
selectedLabel="Ausgewählte Themen"
|
||||
fetchedLabel="Gefundene Themen"
|
||||
[fetchElements]="fetchTopics"
|
||||
[selectedElements]="selectedTopics()"
|
||||
[getSelectLabel]="getTopicLabel"
|
||||
[getSelectValue]="getTopicValue"
|
||||
[getSelectDescription]="getTopicDescription"
|
||||
(handleSelectChange)="handleTopicSelectChange.emit($event)" />
|
||||
@@ -0,0 +1,41 @@
|
||||
import { Component, inject, input, output } from '@angular/core';
|
||||
import { SearchableSelectComponent } from '../searchable-select/searchable-select.component';
|
||||
import { Topic, WorksV2Service } from '../../../api';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
@Component({
|
||||
selector: 'app-searchable-topic-select',
|
||||
imports: [SearchableSelectComponent],
|
||||
templateUrl: './searchable-topic-select.component.html',
|
||||
styleUrl: './searchable-topic-select.component.scss',
|
||||
})
|
||||
export class SearchableTopicSelectComponent {
|
||||
private readonly worksV2Service = inject(WorksV2Service);
|
||||
|
||||
label = input<string>('Themen');
|
||||
selectedTopics = input.required<Topic[]>();
|
||||
|
||||
handleTopicSelectChange = output<Topic>();
|
||||
|
||||
fetchTopics = (searchTerm: string): Observable<Topic[]> => {
|
||||
return this.worksV2Service.getTopicAutocomplete(searchTerm);
|
||||
};
|
||||
|
||||
getTopicLabel = (topic: Topic): string => {
|
||||
return topic.display_name!;
|
||||
};
|
||||
|
||||
getTopicValue = (topic: Topic): string => {
|
||||
return topic.id!;
|
||||
};
|
||||
|
||||
getTopicDescription = (topic: Topic): string => {
|
||||
return (
|
||||
topic.subfield?.display_name +
|
||||
' - ' +
|
||||
topic.field?.display_name +
|
||||
' - ' +
|
||||
topic.domain?.display_name || ''
|
||||
);
|
||||
};
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
<app-searchable-select
|
||||
inputPlaceholder="Typ suchen..."
|
||||
icon="category"
|
||||
[label]="label()"
|
||||
selectedLabel="Ausgewählte Typen"
|
||||
fetchedLabel="Weitere Typen"
|
||||
[fetchElements]="fetchWorkTypes"
|
||||
[selectedElements]="selectedWorkTypes()"
|
||||
[getSelectLabel]="getWorkTypeLabel"
|
||||
[getSelectValue]="getWorkTypeValue"
|
||||
(handleSelectChange)="handleWorkTypeSelectChange.emit($event)" />
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
import { Component, input, output } from '@angular/core';
|
||||
import { SearchableSelectComponent } from '../searchable-select/searchable-select.component';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
export interface WorkType {
|
||||
id: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export const workTypes: WorkType[] = [
|
||||
{ id: 'article', name: 'Artikel' },
|
||||
{ id: 'book', name: 'Buch' },
|
||||
{ id: 'book-chapter', name: 'Buchkapitel' },
|
||||
{ id: 'dataset', name: 'Datensatz' },
|
||||
{ id: 'dissertation', name: 'Dissertation' },
|
||||
{ id: 'editorial', name: 'Editorial' },
|
||||
{ id: 'erratum', name: 'Erratum' },
|
||||
{ id: 'letter', name: 'Brief' },
|
||||
{ id: 'libguides', name: 'LibGuides' },
|
||||
{ id: 'other', name: 'Andere' },
|
||||
{ id: 'paratext', name: 'Paratext' },
|
||||
{ id: 'peer-review', name: 'Peer Review' },
|
||||
{ id: 'preprint', name: 'Preprint' },
|
||||
{ id: 'reference-entry', name: 'Referenzeintrag' },
|
||||
{ id: 'report', name: 'Bericht' },
|
||||
{ id: 'retraction', name: 'Retraktion' },
|
||||
{ id: 'review', name: 'Review' },
|
||||
{ id: 'standard', name: 'Standard' },
|
||||
{ id: 'supplementary-materials', name: 'Ergänzende Materialien' },
|
||||
];
|
||||
|
||||
export const findWorkTypeById = (id: string): WorkType | undefined => {
|
||||
return workTypes.find((workType) => workType.id === id);
|
||||
};
|
||||
|
||||
@Component({
|
||||
selector: 'app-searchable-work-type-select',
|
||||
imports: [SearchableSelectComponent],
|
||||
templateUrl: './searchable-work-type-select.component.html',
|
||||
styleUrl: './searchable-work-type-select.component.scss',
|
||||
})
|
||||
export class SearchableWorkTypeSelectComponent {
|
||||
label = input<string>('Typen');
|
||||
selectedWorkTypes = input.required<WorkType[]>();
|
||||
|
||||
handleWorkTypeSelectChange = output<WorkType>();
|
||||
|
||||
fetchWorkTypes = (searchTerm: string): Observable<WorkType[]> => {
|
||||
return new Observable<WorkType[]>((observer) => {
|
||||
observer.next(
|
||||
workTypes.filter((workType) =>
|
||||
workType.name.toLowerCase().includes(searchTerm.toLowerCase()),
|
||||
),
|
||||
);
|
||||
observer.complete();
|
||||
});
|
||||
};
|
||||
|
||||
getWorkTypeLabel = (workType: WorkType): string => {
|
||||
return workType.name;
|
||||
};
|
||||
|
||||
getWorkTypeValue = (workType: WorkType): string => {
|
||||
return workType.id;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<app-searchable-select
|
||||
inputPlaceholder="Jahr suchen..."
|
||||
icon="calendar_today"
|
||||
[label]="label()"
|
||||
selectedLabel="Ausgewählte Jahre"
|
||||
fetchedLabel="Weitere Jahre"
|
||||
[fetchElements]="fetchYears"
|
||||
[selectedElements]="selectedYears()"
|
||||
[getSelectLabel]="getYearLabel"
|
||||
[getSelectValue]="getYearValue"
|
||||
(handleSelectChange)="handleYearSelectChange.emit($event)" />
|
||||
@@ -0,0 +1,40 @@
|
||||
import { Component, input, output } from '@angular/core';
|
||||
import { SearchableSelectComponent } from '../searchable-select/searchable-select.component';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
@Component({
|
||||
selector: 'app-searchable-year-select',
|
||||
imports: [SearchableSelectComponent],
|
||||
templateUrl: './searchable-year-select.component.html',
|
||||
styleUrl: './searchable-year-select.component.scss',
|
||||
})
|
||||
export class SearchableYearSelectComponent {
|
||||
label = input<string>('Jahr');
|
||||
selectedYears = input.required<number[]>();
|
||||
startYear = input<number>(1900);
|
||||
endYear = input<number>(new Date().getFullYear());
|
||||
|
||||
handleYearSelectChange = output<number>();
|
||||
|
||||
fetchYears = (searchTerm: string): Observable<number[]> => {
|
||||
const years: number[] = [];
|
||||
for (let year = this.endYear(); year >= this.startYear(); year--) {
|
||||
years.push(year);
|
||||
}
|
||||
|
||||
return new Observable<number[]>((observer) => {
|
||||
observer.next(
|
||||
years.filter((year) => year.toString().includes(searchTerm)),
|
||||
);
|
||||
observer.complete();
|
||||
});
|
||||
};
|
||||
|
||||
getYearLabel = (year: number): string => {
|
||||
return year.toString();
|
||||
};
|
||||
|
||||
getYearValue = (year: number): string => {
|
||||
return year.toString();
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user