refactor(patents): share app-card-search/source-filter across patent page. #292

Merged
khalti merged 2 commits from ts-136-patent-to-researchers-v2 into dev 2026-08-18 11:00:08 +02:00
16 changed files with 111 additions and 110 deletions
@@ -36,19 +36,9 @@
<mat-option value="both">Beides</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field
class="patents-toolbar-field"
subscriptSizing="dynamic">
<mat-icon matPrefix fontIcon="filter_alt"></mat-icon>
<mat-select
[value]="activeFilter"
(selectionChange)="setFilter($event.value)">
<mat-select-trigger>Filter nach Quelle</mat-select-trigger>
<mat-option value="all">Alle</mat-option>
<mat-option value="EPO">EPO</mat-option>
<mat-option value="USPTO">USPTO</mat-option>
</mat-select>
</mat-form-field>
<app-source-filter
[value]="activeFilter"
(valueChange)="setFilter($event)" />
<mat-form-field
class="patents-toolbar-field"
subscriptSizing="dynamic">
@@ -17,6 +17,7 @@ import { QueryParamPaginatorComponent } from '../../shared/ui/query-param-pagina
import { ComponentTooltipDirective } from '../../directives/component-tooltip.directive';
import { AppAuthorTooltipComponent } from '../../shared/ui/app-author-tooltip/app-author-tooltip.component';
import { PatentTableComponent } from '../../shared/ui/patent-table/patent-table.component';
import { SourceFilterComponent } from '../../shared/ui/source-filter/source-filter.component';
type SortColumn = 'title' | 'publication_year' | 'source' | 'match_type';
type SortDirection = 'asc' | 'desc';
@@ -35,6 +36,7 @@ type OrgPatentMatchTypeFilter = 'all' | 'institution' | 'name' | 'both';
QueryParamPaginatorComponent,
ComponentTooltipDirective,
PatentTableComponent,
SourceFilterComponent,
],
templateUrl: './institution-patents.component.html',
styleUrl: './institution-patents.component.scss',
@@ -13,19 +13,9 @@
<div class="patents-content">
<div class="patents-list">
<div class="patents-list-toolbar">
<mat-form-field
class="patents-toolbar-field"
subscriptSizing="dynamic">
<mat-icon matPrefix fontIcon="filter_alt"></mat-icon>
<mat-select
[value]="activeFilter()"
(selectionChange)="setFilter($event.value)">
<mat-select-trigger>Filter nach Quelle</mat-select-trigger>
<mat-option value="all">Alle</mat-option>
<mat-option value="EPO">EPO</mat-option>
<mat-option value="USPTO">USPTO</mat-option>
</mat-select>
</mat-form-field>
<app-source-filter
[value]="activeFilter()"
(valueChange)="setFilter($event)" />
<mat-form-field
class="patents-toolbar-field"
subscriptSizing="dynamic">
@@ -23,6 +23,7 @@ import {
} from '../../patent-detail/patent-detail.utils';
import { KeywordPatentMappingStatus } from '../../../api';
import { PatentTableComponent } from '../../../shared/ui/patent-table/patent-table.component';
import { SourceFilterComponent } from '../../../shared/ui/source-filter/source-filter.component';
type SourceFilter = 'all' | 'EPO' | 'USPTO';
type SortColumn = 'title' | 'publication_year' | 'source';
@@ -43,6 +44,7 @@ function isValidSortColumn(value: string | null): value is SortColumn {
LoadingComponent,
QueryParamPaginatorComponent,
PatentTableComponent,
SourceFilterComponent,
],
templateUrl: './keywords-patents.component.html',
styleUrl: './keywords-patents.component.scss',
@@ -3,13 +3,7 @@
<mat-divider />
@if (loading) {
<app-loading
text="Patentdaten werden geladen..."
icon="workspace_premium"
[size]="150"
[diameter]="150" />
} @else if (error) {
@if (error) {
<p class="state-message error">Fehler beim Laden der Patente.</p>
} @else if (showDetail && selectedPatent) {
<div class="detail-view">
@@ -261,6 +255,7 @@
</div>
} @else {
<app-card-search
[loading]="loading"
[page]="cardSearchPage()"
[cardTmp]="cardTmp"
[additionalFiltersTmp]="filtersTmp"
@@ -12,7 +12,6 @@ import { PatentEntry } from '../../api/model/patentEntry';
import { IpcClassification } from '../../api';
import { OpenAlexTopicTag } from '../../api/model/openAlexTopicTag';
import { TopicChipComponent } from '../../shared/ui/topic-chip/topic-chip.component';
import { LoadingComponent } from '../../shared/ui/loading/loading.component';
import { YearRangeSliderComponent } from '../../shared/ui/year-range-slider/year-range-slider.component';
import {
classificationSectionColor,
@@ -52,7 +51,6 @@ const MIN_YEAR = 1978;
MatChipsModule,
MatDividerModule,
TopicChipComponent,
LoadingComponent,
YearRangeSliderComponent,
CardSearchComponent,
FilterCardComponent,
@@ -13,19 +13,9 @@
<div class="patents-content">
<div class="patents-list">
<div class="patents-list-toolbar">
<mat-form-field
class="patents-toolbar-field"
subscriptSizing="dynamic">
<mat-icon matPrefix fontIcon="filter_alt"></mat-icon>
<mat-select
[value]="activeFilter"
(selectionChange)="setFilter($event.value)">
<mat-select-trigger>Filter nach Quelle</mat-select-trigger>
<mat-option value="all">Alle</mat-option>
<mat-option value="EPO">EPO</mat-option>
<mat-option value="USPTO">USPTO</mat-option>
</mat-select>
</mat-form-field>
<app-source-filter
[value]="activeFilter"
(valueChange)="setFilter($event)" />
<mat-form-field
class="patents-toolbar-field"
subscriptSizing="dynamic">
@@ -17,6 +17,7 @@ import { LoadingComponent } from '../../shared/ui/loading/loading.component';
import { PageEvent } from '@angular/material/paginator';
import { QueryParamPaginatorComponent } from '../../shared/ui/query-param-paginator/query-param-paginator.component';
import { PatentTableComponent } from '../../shared/ui/patent-table/patent-table.component';
import { SourceFilterComponent } from '../../shared/ui/source-filter/source-filter.component';
type SortColumn = 'title' | 'publication_year' | 'source';
type SortDirection = 'asc' | 'desc';
@@ -32,6 +33,7 @@ type SourceFilter = 'all' | 'EPO' | 'USPTO';
MatIconModule,
QueryParamPaginatorComponent,
PatentTableComponent,
SourceFilterComponent,
],
templateUrl: './person-patents.component.html',
styleUrl: './person-patents.component.scss',
@@ -44,10 +44,10 @@ export class AppAuthorChipComponent {
icon = input<string>('person');
author = input<Author | undefined>(undefined);
rawOaAuthorId = computed(() => {
return this.stripOpenAlexId(this.author()?.id);
});
authorId = input<string | undefined>(undefined);
rawOaAuthorId = computed(() => {
return this.authorId() ?? this.stripOpenAlexId(this.author()?.id);
});
_author = signal<Author | undefined>(undefined);
@@ -84,7 +84,7 @@
]"
matButton="outlined"
(click)="$event.stopPropagation()">
<mat-icon>verified</mat-icon>
<mat-icon>workspace_premium</mat-icon>
Patente
</a>
}
@@ -39,23 +39,25 @@
@let visibleInventors =
expanded ? patent.inventors : (patent.inventors ?? []).slice(0, 3);
<div class="person-chips">
@for (inventor of visibleInventors; track inventor) {
<span class="person-chip">
<mat-icon>person</mat-icon>
{{ inventor }}
@for (inventor of visibleInventors; track inventor; let last = $last) {
<span class="person-chip-row">
<span class="person-chip">
<mat-icon>person</mat-icon>
{{ inventor }}
</span>
@if (last && (patent.inventors ?? []).length > 3) {
<button
type="button"
class="patent-chip-more"
[attr.aria-expanded]="expanded"
(click)="toggleInventorsExpansion(patent)">
{{ expanded ? 'weniger' : '+' + (patent.inventors!.length - 3) }}
</button>
}
</span>
} @empty {
<span class="empty-text">-</span>
}
@if ((patent.inventors ?? []).length > 3) {
<button
type="button"
class="patent-chip-more"
[attr.aria-expanded]="expanded"
(click)="toggleInventorsExpansion(patent)">
{{ expanded ? 'weniger' : '+' + (patent.inventors!.length - 3) }}
</button>
}
</div>
</ng-template>
@@ -64,25 +66,27 @@
@let visibleAssignees =
expanded ? patent.assignees : (patent.assignees ?? []).slice(0, 3);
<div class="person-chips">
@for (assignee of visibleAssignees; track assignee) {
<span class="person-chip">
<mat-icon>{{
isAssigneeLikelyPerson(assignee, patent) ? 'person' : 'apartment'
}}</mat-icon>
{{ assignee }}
@for (assignee of visibleAssignees; track assignee; let last = $last) {
<span class="person-chip-row">
<span class="person-chip">
<mat-icon>{{
isAssigneeLikelyPerson(assignee, patent) ? 'person' : 'apartment'
}}</mat-icon>
{{ assignee }}
</span>
@if (last && (patent.assignees ?? []).length > 3) {
<button
type="button"
class="patent-chip-more"
[attr.aria-expanded]="expanded"
(click)="toggleAssigneesExpansion(patent)">
{{ expanded ? 'weniger' : '+' + (patent.assignees!.length - 3) }}
</button>
}
</span>
} @empty {
<span class="empty-text">-</span>
}
@if ((patent.assignees ?? []).length > 3) {
<button
type="button"
class="patent-chip-more"
[attr.aria-expanded]="expanded"
(click)="toggleAssigneesExpansion(patent)">
{{ expanded ? 'weniger' : '+' + (patent.assignees!.length - 3) }}
</button>
}
</div>
</ng-template>
@@ -99,15 +103,12 @@
author of patent.matched_authors.slice(0, 3);
track author.openalex_author_id
) {
<a
class="author-link"
[routerLink]="['/person', author.openalex_author_id]"
[appComponentTooltip]="AuthorTooltipComponent"
[tooltipInputs]="{ authorId: author.openalex_author_id }"
[tooltipMaxWidth]="'500px'"
(click)="$event.stopPropagation()">
{{ author.author_name }}
</a>
<app-author-chip
size="mini"
[showIcon]="true"
[isClickable]="true"
[authorId]="author.openalex_author_id"
(handleChipClick)="navigateToPerson(author.openalex_author_id)" />
}
} @else {
<span class="empty-text">-</span>
@@ -58,15 +58,18 @@
max-width: 240px;
}
.person-chip-row {
display: inline-flex;
align-items: center;
gap: 4px;
max-width: 100%;
}
.person-chip {
display: inline-flex;
align-items: center;
gap: 4px;
max-width: 100%;
padding: 2px 8px;
border: 1px solid var(--sg-border);
border-radius: var(--sg-radius-sm);
background: var(--sg-surface-soft);
color: var(--sg-text);
font-size: 0.75rem;
line-height: 1.4;
@@ -133,17 +136,9 @@
.cell-authors {
display: flex;
flex-direction: column;
gap: 4px;
flex-wrap: wrap;
gap: 0.25rem;
align-items: flex-start;
min-width: 120px;
}
.author-link {
color: var(--sg-blue-highlight);
text-decoration: none;
font-size: 0.82rem;
&:hover {
text-decoration: underline;
}
max-width: 260px;
}
@@ -1,12 +1,13 @@
import {
Component,
TemplateRef,
inject,
input,
output,
signal,
viewChild,
} from '@angular/core';
import { RouterModule } from '@angular/router';
import { Router, RouterModule } from '@angular/router';
import { MatIconModule } from '@angular/material/icon';
import { MatButtonModule } from '@angular/material/button';
import { MatTooltipModule } from '@angular/material/tooltip';
@@ -18,8 +19,7 @@ import {
GenericColumn,
} from '../data-table/data-table.component';
import { ChipComponent } from '../chip/chip.component';
import { ComponentTooltipDirective } from '../../../directives/component-tooltip.directive';
import { AppAuthorTooltipComponent } from '../app-author-tooltip/app-author-tooltip.component';
import { AppAuthorChipComponent } from '../app-author-chip/app-author-chip.component';
import { isAssigneeLikelyPerson } from '../../../modules/patent-detail/patent-detail.utils';
export interface PatentTableEntry extends PatentEntry {
@@ -36,7 +36,7 @@ export interface PatentTableEntry extends PatentEntry {
MatTooltipModule,
DataTableComponent,
ChipComponent,
ComponentTooltipDirective,
AppAuthorChipComponent,
],
templateUrl: './patent-table.component.html',
styleUrl: './patent-table.component.scss',
@@ -44,7 +44,7 @@ export interface PatentTableEntry extends PatentEntry {
export class PatentTableComponent<
T extends PatentTableEntry = PatentTableEntry,
> {
readonly AuthorTooltipComponent = AppAuthorTooltipComponent;
private readonly router = inject(Router);
patents = input.required<T[]>();
selectedPatent = input<T | null>(null);
@@ -156,6 +156,10 @@ export class PatentTableComponent<
return isAssigneeLikelyPerson(assignee, patent.inventors);
}
navigateToPerson(authorId: string): void {
this.router.navigate(['/person', authorId]);
}
getMatchTypeLabel(matchType: string | undefined): string {
switch (matchType) {
case 'institution':
@@ -0,0 +1,11 @@
<mat-form-field class="source-filter-field" subscriptSizing="dynamic">
<mat-icon matPrefix fontIcon="filter_alt"></mat-icon>
<mat-select
[value]="value()"
(selectionChange)="valueChange.emit($event.value)">
<mat-select-trigger>Filter nach Quelle</mat-select-trigger>
<mat-option value="all">Alle</mat-option>
<mat-option value="EPO">EPO</mat-option>
<mat-option value="USPTO">USPTO</mat-option>
</mat-select>
</mat-form-field>
@@ -0,0 +1,4 @@
.source-filter-field {
width: fit-content;
min-width: 180px;
}
@@ -0,0 +1,17 @@
import { Component, input, output } from '@angular/core';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatSelectModule } from '@angular/material/select';
import { MatIconModule } from '@angular/material/icon';
export type SourceFilterValue = 'all' | 'EPO' | 'USPTO';
@Component({
selector: 'app-source-filter',
imports: [MatFormFieldModule, MatSelectModule, MatIconModule],
templateUrl: './source-filter.component.html',
styleUrl: './source-filter.component.scss',
})
export class SourceFilterComponent {
value = input.required<SourceFilterValue>();
valueChange = output<SourceFilterValue>();
}