feat(person-funding, person-patents, institution-patents, keywords-patents): add sortable column headers and refine inventor/assignee chip styling #264

Merged
khalti merged 1 commits from ts-136-patent-to-researchers-v2 into dev 2026-08-04 20:40:34 +02:00
12 changed files with 942 additions and 196 deletions
@@ -54,11 +54,13 @@
subscriptSizing="dynamic">
<mat-icon matPrefix fontIcon="sort"></mat-icon>
<mat-select
[value]="sortMode"
(selectionChange)="setSortMode($event.value)">
[value]="sortColumn"
(selectionChange)="setSort($event.value)">
<mat-select-trigger>Sortieren nach</mat-select-trigger>
<mat-option value="date">Datum</mat-option>
<mat-option value="year">Jahr</mat-option>
<mat-option value="title">Titel</mat-option>
<mat-option value="source">Quelle</mat-option>
<mat-option value="matchType">Match-Typ</mat-option>
</mat-select>
</mat-form-field>
</div>
@@ -67,11 +69,41 @@
<thead>
<tr>
<th>Patent</th>
<th>Quelle</th>
<th>Jahr</th>
<th
class="sortable"
[class.sort-active]="sortColumn === 'source'"
(click)="setSort('source')">
Quelle
@if (sortColumn === 'source') {
<mat-icon class="sort-icon">{{
sortDirection === 'asc' ? 'arrow_upward' : 'arrow_downward'
}}</mat-icon>
}
</th>
<th
class="sortable"
[class.sort-active]="sortColumn === 'year'"
(click)="setSort('year')">
Jahr
@if (sortColumn === 'year') {
<mat-icon class="sort-icon">{{
sortDirection === 'asc' ? 'arrow_upward' : 'arrow_downward'
}}</mat-icon>
}
</th>
<th>Erfinder</th>
<th>Applicant/Assignee</th>
<th>Match-Typ</th>
<th
class="sortable"
[class.sort-active]="sortColumn === 'matchType'"
(click)="setSort('matchType')">
Match-Typ
@if (sortColumn === 'matchType') {
<mat-icon class="sort-icon">{{
sortDirection === 'asc' ? 'arrow_upward' : 'arrow_downward'
}}</mat-icon>
}
</th>
<th>Personen</th>
</tr>
</thead>
@@ -94,9 +126,86 @@
{{ patent.source }}
</span>
</td>
<td>{{ patent.publication_year ?? '-' }}</td>
<td class="cell-preview">{{ getInventorsPreview(patent) }}</td>
<td class="cell-preview">{{ getAssigneesPreview(patent) }}</td>
<td>
@if (patent.publication_year) {
<span class="year-badge">{{
patent.publication_year
}}</span>
} @else {
<span>-</span>
}
</td>
<td class="patent-people">
@if (patent.inventors && patent.inventors.length) {
<div class="person-chips">
@for (
inventor of patent.inventors.slice(0, 2);
track inventor
) {
<span class="person-chip">
<mat-icon>person</mat-icon>
{{ inventor }}
</span>
}
@if (patent.inventors.length > 2) {
<span class="person-chip-row">
<span class="person-chip">
<mat-icon>person</mat-icon>
{{ patent.inventors[2] }}
</span>
@if (patent.inventors.length > 3) {
<span class="person-chip person-chip--more"
>+{{ patent.inventors.length - 3 }}</span
>
}
</span>
}
</div>
} @else {
<span>-</span>
}
</td>
<td class="patent-people">
@if (patent.assignees && patent.assignees.length) {
<div class="person-chips">
@for (
assignee of patent.assignees.slice(0, 2);
track assignee
) {
<span class="person-chip">
<mat-icon>{{
isAssigneeLikelyPerson(assignee, patent)
? 'person'
: 'apartment'
}}</mat-icon>
{{ assignee }}
</span>
}
@if (patent.assignees.length > 2) {
<span class="person-chip-row">
<span class="person-chip">
<mat-icon>{{
isAssigneeLikelyPerson(
patent.assignees[2],
patent
)
? 'person'
: 'apartment'
}}</mat-icon>
{{ patent.assignees[2] }}
</span>
@if (patent.assignees.length > 3) {
<span class="person-chip person-chip--more"
>+{{ patent.assignees.length - 3 }}</span
>
}
</span>
}
</div>
} @else {
<span>-</span>
}
</td>
<td>
<span
class="match-badge match-badge--{{ patent.match_type }}">
@@ -118,6 +227,10 @@
'/person',
author.openalex_author_id,
]"
[appComponentTooltip]="AuthorTooltipComponent"
[tooltipInputs]="{
authorId: author.openalex_author_id,
}"
(click)="$event.stopPropagation()">
{{ author.author_name }}
</a>
@@ -197,7 +310,11 @@
<li>
<a
class="tag author-link"
[routerLink]="['/person', author.openalex_author_id]">
[routerLink]="['/person', author.openalex_author_id]"
[appComponentTooltip]="AuthorTooltipComponent"
[tooltipInputs]="{
authorId: author.openalex_author_id,
}">
{{ author.author_name }}
</a>
</li>
@@ -66,9 +66,24 @@ app-query-param-paginator {
text-align: left;
padding: 12px 16px;
border-bottom: 1px solid var(--sg-border);
font-size: 13px;
font-weight: 600;
font-size: 12px;
font-weight: 700;
color: var(--sg-text-muted);
&.sortable {
display: table-cell;
cursor: pointer;
-webkit-user-select: none;
user-select: none;
}
.sort-icon {
vertical-align: middle;
margin-left: 2px;
width: 14px;
height: 14px;
font-size: 14px;
}
}
tr {
@@ -101,13 +116,8 @@ app-query-param-paginator {
word-break: break-word;
}
.cell-preview {
max-width: 160px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
color: var(--sg-text-muted);
font-size: 13px;
.patent-people {
max-width: 220px;
}
.cell-authors {
@@ -119,6 +129,64 @@ app-query-param-paginator {
}
}
.year-badge {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 26px;
padding: 2px 10px;
border-radius: 999px;
border: 1px solid var(--sg-border);
color: var(--sg-text);
font-size: 0.8rem;
font-weight: 600;
}
.person-chips {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 4px;
}
.person-chip-row {
display: flex;
flex-direction: row;
align-items: center;
flex-wrap: wrap;
gap: 4px;
}
.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;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
mat-icon {
flex-shrink: 0;
width: 14px;
height: 14px;
font-size: 14px;
color: var(--sg-text-soft);
}
&--more {
color: var(--sg-text-muted);
font-weight: 600;
}
}
.match-badge {
display: inline-flex;
align-items: center;
@@ -13,8 +13,11 @@ import {
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 { ComponentTooltipDirective } from '../../directives/component-tooltip.directive';
import { AppAuthorTooltipComponent } from '../../shared/ui/app-author-tooltip/app-author-tooltip.component';
type SortMode = 'date' | 'title';
type SortColumn = 'title' | 'year' | 'source' | 'matchType';
type SortDirection = 'asc' | 'desc';
type SourceFilter = 'all' | 'EPO' | 'USPTO';
type OrgPatentMatchTypeFilter = 'all' | 'institution' | 'name' | 'both';
@@ -28,11 +31,13 @@ type OrgPatentMatchTypeFilter = 'all' | 'institution' | 'name' | 'both';
MatSelectModule,
MatIconModule,
QueryParamPaginatorComponent,
ComponentTooltipDirective,
],
templateUrl: './institution-patents.component.html',
styleUrl: './institution-patents.component.scss',
})
export class InstitutionPatentsComponent implements OnInit {
readonly AuthorTooltipComponent = AppAuthorTooltipComponent;
private route = inject(ActivatedRoute);
private router = inject(Router);
private patentsApi = inject(PatentsService);
@@ -48,7 +53,8 @@ export class InstitutionPatentsComponent implements OnInit {
activeFilter: SourceFilter = 'all';
activeMatchType: OrgPatentMatchTypeFilter = 'all';
sortMode: SortMode = 'date';
sortColumn: SortColumn = 'year';
sortDirection: SortDirection = 'desc';
pageIndex = 0;
pageSize = 20;
@@ -59,7 +65,8 @@ export class InstitutionPatentsComponent implements OnInit {
const institutionId = params.get('institutionId') ?? '';
const filterFromUrl = this.route.snapshot.queryParamMap.get('filter');
const sortFromUrl = this.route.snapshot.queryParamMap.get('sortBy');
const sortByFromUrl = this.route.snapshot.queryParamMap.get('sortBy');
const sortDirFromUrl = this.route.snapshot.queryParamMap.get('sortDir');
const matchTypeFromUrl =
this.route.snapshot.queryParamMap.get('matchType');
this.pageIndex = this.parsePageIndexParam(
@@ -72,8 +79,11 @@ export class InstitutionPatentsComponent implements OnInit {
if (this.isValidFilter(filterFromUrl)) {
this.activeFilter = filterFromUrl;
}
if (this.isValidSortMode(sortFromUrl)) {
this.sortMode = sortFromUrl;
if (this.isValidSortColumn(sortByFromUrl)) {
this.sortColumn = sortByFromUrl;
}
if (this.isValidSortDirection(sortDirFromUrl)) {
this.sortDirection = sortDirFromUrl;
}
if (this.isValidMatchType(matchTypeFromUrl)) {
this.activeMatchType = matchTypeFromUrl;
@@ -101,8 +111,13 @@ export class InstitutionPatentsComponent implements OnInit {
this.reloadPatents();
}
setSortMode(sortMode: SortMode): void {
this.sortMode = sortMode;
setSort(column: SortColumn): void {
if (this.sortColumn === column) {
this.sortDirection = this.sortDirection === 'asc' ? 'desc' : 'asc';
} else {
this.sortColumn = column;
this.sortDirection = column === 'year' ? 'desc' : 'asc';
}
this.filteredPatents = this.sortPatents(this.patents);
this.updateQueryParams();
}
@@ -168,14 +183,27 @@ export class InstitutionPatentsComponent implements OnInit {
}
private sortPatents(patents: OrgPatentEntry[]): OrgPatentEntry[] {
if (this.sortMode === 'title') {
return [...patents].sort((a, b) =>
(a.title ?? '').localeCompare(b.title ?? '', 'de', {
sensitivity: 'base',
}),
);
}
return [...patents];
const direction = this.sortDirection === 'asc' ? 1 : -1;
return [...patents].sort((a, b) => {
switch (this.sortColumn) {
case 'year': {
const yearA = a.publication_date ?? String(a.publication_year ?? '');
const yearB = b.publication_date ?? String(b.publication_year ?? '');
return direction * yearA.localeCompare(yearB);
}
case 'source':
return direction * a.source.localeCompare(b.source);
case 'matchType':
return direction * a.match_type.localeCompare(b.match_type);
default:
return (
direction *
(a.title ?? '').localeCompare(b.title ?? '', 'de', {
sensitivity: 'base',
})
);
}
});
}
private updateQueryParams(): void {
@@ -183,7 +211,8 @@ export class InstitutionPatentsComponent implements OnInit {
relativeTo: this.route,
queryParams: {
filter: this.activeFilter,
sortBy: this.sortMode,
sortBy: this.sortColumn,
sortDir: this.sortDirection,
matchType: this.activeMatchType,
page: this.pageIndex,
size: this.pageSize,
@@ -207,8 +236,17 @@ export class InstitutionPatentsComponent implements OnInit {
return value === 'all' || value === 'EPO' || value === 'USPTO';
}
private isValidSortMode(value: string | null): value is SortMode {
return value === 'date' || value === 'title';
private isValidSortColumn(value: string | null): value is SortColumn {
return (
value === 'title' ||
value === 'year' ||
value === 'source' ||
value === 'matchType'
);
}
private isValidSortDirection(value: string | null): value is SortDirection {
return value === 'asc' || value === 'desc';
}
private isValidMatchType(
@@ -287,18 +325,40 @@ export class InstitutionPatentsComponent implements OnInit {
}
}
getInventorsPreview(patent: OrgPatentEntry): string {
if (!patent.inventors?.length) {
return '-';
}
return patent.inventors.slice(0, 2).join(', ');
private static readonly ORG_SUFFIX_PATTERN =
/\b(Inc|Ltd|LLC|LLP|GmbH|Corp(oration)?|Co|KG|AG|SE|S\.?A\.?|N\.?V\.?|B\.?V\.?|PLC|Universit(y|ät|é)|Institut(e)?|Foundation|Laborator(y|ies)|Labs?|Group|Holdings?|Company|Gesellschaft)\b\.?/i;
private static readonly PERSON_SUFFIX_PATTERN =
/\b(Dr|Prof|PhD|Ph\.D|M\.D|Jr|Sr)\b\.?/i;
private normalizeNameForComparison(name: string): string {
return name
.normalize('NFD')
.replace(/[̀-ͯ]/g, '')
.replace(/[.,]/g, '')
.toUpperCase()
.split(/\s+/)
.filter(Boolean)
.sort()
.join(' ');
}
getAssigneesPreview(patent: OrgPatentEntry): string {
if (!patent.assignees?.length) {
return '-';
isAssigneeLikelyPerson(assignee: string, patent: OrgPatentEntry): boolean {
if (InstitutionPatentsComponent.ORG_SUFFIX_PATTERN.test(assignee)) {
return false;
}
return patent.assignees.slice(0, 2).join(', ');
const normalizedAssignee = this.normalizeNameForComparison(
assignee.replace(InstitutionPatentsComponent.PERSON_SUFFIX_PATTERN, ''),
);
const matchesInventor = (patent.inventors ?? []).some(
(inventor) =>
this.normalizeNameForComparison(inventor) === normalizedAssignee,
);
if (matchesInventor) {
return true;
}
return InstitutionPatentsComponent.PERSON_SUFFIX_PATTERN.test(assignee);
}
getMatchedAuthorsPreview(patent: OrgPatentEntry): string {
@@ -31,11 +31,12 @@
subscriptSizing="dynamic">
<mat-icon matPrefix fontIcon="sort"></mat-icon>
<mat-select
[value]="sortMode()"
(selectionChange)="setSortMode($event.value)">
[value]="sortColumn()"
(selectionChange)="setSort($event.value)">
<mat-select-trigger>Sortieren nach</mat-select-trigger>
<mat-option value="date">Datum</mat-option>
<mat-option value="year">Jahr</mat-option>
<mat-option value="title">Titel</mat-option>
<mat-option value="source">Quelle</mat-option>
</mat-select>
</mat-form-field>
</div>
@@ -44,8 +45,32 @@
<thead>
<tr>
<th>Patent</th>
<th>Quelle</th>
<th>Jahr</th>
<th
class="sortable"
[class.sort-active]="sortColumn() === 'source'"
(click)="setSort('source')">
Quelle
@if (sortColumn() === 'source') {
<mat-icon class="sort-icon">{{
sortDirection() === 'asc'
? 'arrow_upward'
: 'arrow_downward'
}}</mat-icon>
}
</th>
<th
class="sortable"
[class.sort-active]="sortColumn() === 'year'"
(click)="setSort('year')">
Jahr
@if (sortColumn() === 'year') {
<mat-icon class="sort-icon">{{
sortDirection() === 'asc'
? 'arrow_upward'
: 'arrow_downward'
}}</mat-icon>
}
</th>
<th>Erfinder</th>
<th>Anmelder</th>
</tr>
@@ -66,16 +91,85 @@
{{ item.patent.source }}
</span>
</td>
<td>{{ item.patent.publication_year ?? '-' }}</td>
<td
class="patent-people"
[title]="getInventorsLabel(item.patent)">
{{ getInventorsLabel(item.patent) }}
<td>
@if (item.patent.publication_year) {
<span class="year-badge">{{
item.patent.publication_year
}}</span>
} @else {
<span>-</span>
}
</td>
<td
class="patent-people"
[title]="getAssigneesLabel(item.patent)">
{{ getAssigneesLabel(item.patent) }}
<td class="patent-people">
@if (item.patent.inventors && item.patent.inventors.length) {
<div class="person-chips">
@for (
inventor of item.patent.inventors.slice(0, 2);
track inventor
) {
<span class="person-chip">
<mat-icon>person</mat-icon>
{{ inventor }}
</span>
}
@if (item.patent.inventors.length > 2) {
<span class="person-chip-row">
<span class="person-chip">
<mat-icon>person</mat-icon>
{{ item.patent.inventors[2] }}
</span>
@if (item.patent.inventors.length > 3) {
<span class="person-chip person-chip--more"
>+{{ item.patent.inventors.length - 3 }}</span
>
}
</span>
}
</div>
} @else {
<span>-</span>
}
</td>
<td class="patent-people">
@if (item.patent.assignees && item.patent.assignees.length) {
<div class="person-chips">
@for (
assignee of item.patent.assignees.slice(0, 2);
track assignee
) {
<span class="person-chip">
<mat-icon>{{
isAssigneeLikelyPerson(assignee, item.patent)
? 'person'
: 'apartment'
}}</mat-icon>
{{ assignee }}
</span>
}
@if (item.patent.assignees.length > 2) {
<span class="person-chip-row">
<span class="person-chip">
<mat-icon>{{
isAssigneeLikelyPerson(
item.patent.assignees[2],
item.patent
)
? 'person'
: 'apartment'
}}</mat-icon>
{{ item.patent.assignees[2] }}
</span>
@if (item.patent.assignees.length > 3) {
<span class="person-chip person-chip--more"
>+{{ item.patent.assignees.length - 3 }}</span
>
}
</span>
}
</div>
} @else {
<span>-</span>
}
</td>
</tr>
}
@@ -97,9 +97,24 @@ app-query-param-paginator {
text-align: left;
padding: 12px 16px;
border-bottom: 1px solid var(--sg-border);
font-size: 13px;
font-weight: 600;
font-size: 12px;
font-weight: 700;
color: var(--sg-text-muted);
&.sortable {
display: table-cell;
cursor: pointer;
-webkit-user-select: none;
user-select: none;
}
.sort-icon {
vertical-align: middle;
margin-left: 2px;
width: 14px;
height: 14px;
font-size: 14px;
}
}
tr {
@@ -133,41 +148,66 @@ app-query-param-paginator {
.patent-people {
max-width: 220px;
color: var(--sg-text-muted);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
th {
text-align: left;
padding: 10px 12px;
border-bottom: 2px solid var(--sg-border);
color: var(--sg-text);
}
tr {
cursor: pointer;
color: var(--sg-text);
&:hover {
background: var(--sg-surface-soft);
}
&.selected {
background: var(--sg-surface-muted);
}
}
td {
padding: 10px 12px;
border-bottom: 1px solid var(--sg-border);
}
}
.patent-title {
font-weight: 500;
.year-badge {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 26px;
padding: 2px 10px;
border-radius: 999px;
border: 1px solid var(--sg-border);
color: var(--sg-text);
font-size: 0.8rem;
font-weight: 600;
}
.person-chips {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 4px;
}
.person-chip-row {
display: flex;
flex-direction: row;
align-items: center;
flex-wrap: wrap;
gap: 4px;
}
.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;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
mat-icon {
flex-shrink: 0;
width: 14px;
height: 14px;
font-size: 14px;
color: var(--sg-text-soft);
}
&--more {
color: var(--sg-text-muted);
font-weight: 600;
}
}
.source-badge {
@@ -16,7 +16,8 @@ import {
import { KeywordPatentMappingStatus } from '../../../api';
type SourceFilter = 'all' | 'EPO' | 'USPTO';
type SortMode = 'date' | 'title';
type SortColumn = 'title' | 'year' | 'source';
type SortDirection = 'asc' | 'desc';
@Component({
selector: 'app-keywords-patents',
@@ -44,7 +45,8 @@ export class KeywordsPatentsComponent {
readonly reload = output<void>();
activeFilter = signal<SourceFilter>('all');
sortMode = signal<SortMode>('date');
sortColumn = signal<SortColumn>('year');
sortDirection = signal<SortDirection>('desc');
selectedMatch = signal<KeywordPatentMatch | null>(null);
readonly pageIndex = computed(() => {
@@ -86,12 +88,53 @@ export class KeywordsPatentsComponent {
this.resetPage();
}
setSortMode(sortMode: SortMode): void {
this.sortMode.set(sortMode);
setSort(column: SortColumn): void {
if (this.sortColumn() === column) {
this.sortDirection.set(this.sortDirection() === 'asc' ? 'desc' : 'asc');
} else {
this.sortColumn.set(column);
this.sortDirection.set(column === 'year' ? 'desc' : 'asc');
}
this.selectedMatch.set(null);
this.resetPage();
}
isAssigneeLikelyPerson(assignee: string, patent: PatentEntry): boolean {
if (KeywordsPatentsComponent.ORG_SUFFIX_PATTERN.test(assignee)) {
return false;
}
const normalizedAssignee = this.normalizeNameForComparison(
assignee.replace(KeywordsPatentsComponent.PERSON_SUFFIX_PATTERN, ''),
);
const matchesInventor = (patent.inventors ?? []).some(
(inventor) =>
this.normalizeNameForComparison(inventor) === normalizedAssignee,
);
if (matchesInventor) {
return true;
}
return KeywordsPatentsComponent.PERSON_SUFFIX_PATTERN.test(assignee);
}
private static readonly ORG_SUFFIX_PATTERN =
/\b(Inc|Ltd|LLC|LLP|GmbH|Corp(oration)?|Co|KG|AG|SE|S\.?A\.?|N\.?V\.?|B\.?V\.?|PLC|Universit(y|ät|é)|Institut(e)?|Foundation|Laborator(y|ies)|Labs?|Group|Holdings?|Company|Gesellschaft)\b\.?/i;
private static readonly PERSON_SUFFIX_PATTERN =
/\b(Dr|Prof|PhD|Ph\.D|M\.D|Jr|Sr)\b\.?/i;
private normalizeNameForComparison(name: string): string {
return name
.normalize('NFD')
.replace(/[̀-ͯ]/g, '')
.replace(/[.,]/g, '')
.toUpperCase()
.split(/\s+/)
.filter(Boolean)
.sort()
.join(' ');
}
onPatentPageChange(_event: PageEvent): void {
this.selectedMatch.set(null);
}
@@ -124,14 +167,6 @@ export class KeywordsPatentsComponent {
.length;
}
getInventorsLabel(patent: PatentEntry): string {
return patent.inventors?.length ? patent.inventors.join(', ') : '-';
}
getAssigneesLabel(patent: PatentEntry): string {
return patent.assignees?.length ? patent.assignees.join(', ') : '-';
}
formatDate(date: string | null | undefined): string {
return formatPatentDate(date);
}
@@ -163,16 +198,29 @@ export class KeywordsPatentsComponent {
}
private sortMatches(items: KeywordPatentMatch[]): KeywordPatentMatch[] {
const mode = this.sortMode();
const column = this.sortColumn();
const direction = this.sortDirection() === 'asc' ? 1 : -1;
return [...items].sort((a, b) => {
if (mode === 'date') {
return (b.patent.publication_date ?? '').localeCompare(
a.patent.publication_date ?? '',
);
switch (column) {
case 'year': {
const yearA =
a.patent.publication_date ??
String(a.patent.publication_year ?? '');
const yearB =
b.patent.publication_date ??
String(b.patent.publication_year ?? '');
return direction * yearA.localeCompare(yearB);
}
case 'source':
return direction * a.patent.source.localeCompare(b.patent.source);
default:
return (
direction *
(a.patent.title ?? '').localeCompare(b.patent.title ?? '', 'de', {
sensitivity: 'base',
})
);
}
return (a.patent.title ?? '').localeCompare(b.patent.title ?? '', 'de', {
sensitivity: 'base',
});
});
}
}
@@ -33,22 +33,75 @@
subscriptSizing="dynamic">
<mat-icon matPrefix fontIcon="sort"></mat-icon>
<mat-select
[value]="sortMode"
(selectionChange)="setSortMode($event.value)">
[value]="sortColumn"
(selectionChange)="setSort($event.value)">
<mat-select-trigger>Sortieren nach</mat-select-trigger>
<mat-option value="name">Name</mat-option>
<mat-option value="top">Top Förderer</mat-option>
<mat-option value="name">Förderer</mat-option>
<mat-option value="publications">Publikationen</mat-option>
<mat-option value="first">Erstautor</mat-option>
<mat-option value="middle">Mitautor</mat-option>
<mat-option value="last">Letztautor</mat-option>
</mat-select>
</mat-form-field>
</div>
<table>
<thead>
<tr>
<th>Förderer</th>
<th class="text-center">Publikationen</th>
<th class="text-center">Erstautor</th>
<th class="text-center">Mitautor</th>
<th class="text-center">Letztautor</th>
<th
class="sortable"
[class.sort-active]="sortColumn === 'name'"
(click)="setSort('name')">
Förderer
@if (sortColumn === 'name') {
<mat-icon class="sort-icon">{{
sortDirection === 'asc' ? 'arrow_upward' : 'arrow_downward'
}}</mat-icon>
}
</th>
<th
class="text-center sortable"
[class.sort-active]="sortColumn === 'publications'"
(click)="setSort('publications')">
Publikationen
@if (sortColumn === 'publications') {
<mat-icon class="sort-icon">{{
sortDirection === 'asc' ? 'arrow_upward' : 'arrow_downward'
}}</mat-icon>
}
</th>
<th
class="text-center sortable"
[class.sort-active]="sortColumn === 'first'"
(click)="setSort('first')">
Erstautor
@if (sortColumn === 'first') {
<mat-icon class="sort-icon">{{
sortDirection === 'asc' ? 'arrow_upward' : 'arrow_downward'
}}</mat-icon>
}
</th>
<th
class="text-center sortable"
[class.sort-active]="sortColumn === 'middle'"
(click)="setSort('middle')">
Mitautor
@if (sortColumn === 'middle') {
<mat-icon class="sort-icon">{{
sortDirection === 'asc' ? 'arrow_upward' : 'arrow_downward'
}}</mat-icon>
}
</th>
<th
class="text-center sortable"
[class.sort-active]="sortColumn === 'last'"
(click)="setSort('last')">
Letztautor
@if (sortColumn === 'last') {
<mat-icon class="sort-icon">{{
sortDirection === 'asc' ? 'arrow_upward' : 'arrow_downward'
}}</mat-icon>
}
</th>
</tr>
</thead>
<tbody>
@@ -45,9 +45,24 @@ app-query-param-paginator {
text-align: left;
padding: 12px 16px;
border-bottom: 1px solid var(--sg-border);
font-size: 13px;
font-weight: 600;
font-size: 12px;
font-weight: 700;
color: var(--sg-text-muted);
&.sortable {
display: table-cell;
cursor: pointer;
-webkit-user-select: none;
user-select: none;
}
.sort-icon {
vertical-align: middle;
margin-left: 2px;
width: 14px;
height: 14px;
font-size: 14px;
}
}
tr {
@@ -86,8 +101,11 @@ app-query-param-paginator {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 20px;
font-size: 13px;
min-width: 26px;
padding: 2px 10px;
border-radius: 999px;
border: 1px solid var(--sg-border);
font-size: 0.8rem;
font-weight: 700;
&--first {
@@ -157,9 +175,6 @@ app-query-param-paginator {
}
&.stat-first {
background: var(--sg-success-soft);
border-color: var(--sg-success);
.stat-label,
.stat-value {
color: var(--sg-success);
@@ -167,9 +182,6 @@ app-query-param-paginator {
}
&.stat-middle {
background: var(--sg-warning-soft);
border-color: var(--sg-warning);
.stat-label,
.stat-value {
color: var(--sg-warning);
@@ -177,9 +189,6 @@ app-query-param-paginator {
}
&.stat-last {
background: var(--sg-error-soft);
border-color: var(--sg-error);
.stat-label,
.stat-value {
color: var(--sg-error);
@@ -10,7 +10,8 @@ import { FundingService } from '../../api';
import { LoadingComponent } from '../../shared/ui/loading/loading.component';
import { QueryParamPaginatorComponent } from '../../shared/ui/query-param-paginator/query-param-paginator.component';
type SortMode = 'name' | 'top';
type SortColumn = 'name' | 'publications' | 'first' | 'middle' | 'last';
type SortDirection = 'asc' | 'desc';
type AuthorPosition = 'first' | 'middle' | 'last' | 'unknown';
type FundingPublicationDetail = {
@@ -53,7 +54,8 @@ export class PersonFundingComponent implements OnInit {
publicationPageIndex = 0;
publicationPageSize = 10;
activeFilter: 'all' | 'first' | 'middle' | 'last' = 'all';
sortMode: SortMode = 'name';
sortColumn: SortColumn = 'name';
sortDirection: SortDirection = 'asc';
loading = true;
error = false;
@@ -61,7 +63,8 @@ export class PersonFundingComponent implements OnInit {
this.route.parent?.paramMap.subscribe((params) => {
const authorId = params.get('id') ?? '';
const filterFromUrl = this.route.snapshot.queryParamMap.get('filter');
const sortFromUrl = this.route.snapshot.queryParamMap.get('sortBy');
const sortByFromUrl = this.route.snapshot.queryParamMap.get('sortBy');
const sortDirFromUrl = this.route.snapshot.queryParamMap.get('sortDir');
this.initialSelectedFunderKey =
this.route.snapshot.queryParamMap.get('funder');
this.initialFunderPageIndex = this.parsePageIndexParam(
@@ -79,8 +82,11 @@ export class PersonFundingComponent implements OnInit {
if (this.isValidFilter(filterFromUrl)) {
this.activeFilter = filterFromUrl;
}
if (this.isValidSortMode(sortFromUrl)) {
this.sortMode = sortFromUrl;
if (this.isValidSortColumn(sortByFromUrl)) {
this.sortColumn = sortByFromUrl;
}
if (this.isValidSortDirection(sortDirFromUrl)) {
this.sortDirection = sortDirFromUrl;
}
if (authorId) {
@@ -118,8 +124,13 @@ export class PersonFundingComponent implements OnInit {
this.updateQueryParams();
}
setSortMode(sortMode: SortMode): void {
this.sortMode = sortMode;
setSort(column: SortColumn): void {
if (this.sortColumn === column) {
this.sortDirection = this.sortDirection === 'asc' ? 'desc' : 'asc';
} else {
this.sortColumn = column;
this.sortDirection = column === 'name' ? 'asc' : 'desc';
}
this.applyFilter();
this.updateQueryParams();
}
@@ -185,7 +196,8 @@ export class PersonFundingComponent implements OnInit {
relativeTo: this.route,
queryParams: {
filter: this.activeFilter,
sortBy: this.sortMode,
sortBy: this.sortColumn,
sortDir: this.sortDirection,
funder: this.selectedFunder
? this.getFunderKey(this.selectedFunder)
: null,
@@ -214,8 +226,18 @@ export class PersonFundingComponent implements OnInit {
);
}
private isValidSortMode(value: string | null): value is SortMode {
return value === 'name' || value === 'top';
private isValidSortColumn(value: string | null): value is SortColumn {
return (
value === 'name' ||
value === 'publications' ||
value === 'first' ||
value === 'middle' ||
value === 'last'
);
}
private isValidSortDirection(value: string | null): value is SortDirection {
return value === 'asc' || value === 'desc';
}
getPublicationCount(funder: any): number {
@@ -294,24 +316,44 @@ export class PersonFundingComponent implements OnInit {
}
private sortFunders(funders: any[]): any[] {
const direction = this.sortDirection === 'asc' ? 1 : -1;
const sortedFunders = [...funders];
return sortedFunders.sort((first, second) => {
if (this.sortMode === 'top') {
const publicationCountDifference =
this.getPublicationCount(second) - this.getPublicationCount(first);
if (publicationCountDifference !== 0) {
return publicationCountDifference;
if (this.sortColumn !== 'name') {
const valueDifference =
direction *
(this.getSortColumnValue(first) - this.getSortColumnValue(second));
if (valueDifference !== 0) {
return valueDifference;
}
}
return this.getSortableFunderName(first).localeCompare(
this.getSortableFunderName(second),
'de',
{ sensitivity: 'base' },
return (
direction *
this.getSortableFunderName(first).localeCompare(
this.getSortableFunderName(second),
'de',
{ sensitivity: 'base' },
)
);
});
}
private getSortColumnValue(funder: any): number {
switch (this.sortColumn) {
case 'publications':
return this.getPublicationCount(funder);
case 'first':
return funder.author_position_count?.first ?? 0;
case 'middle':
return funder.author_position_count?.middle ?? 0;
case 'last':
return funder.author_position_count?.last ?? 0;
default:
return 0;
}
}
private getSortableFunderName(funder: any): string {
return funder.funder_name ?? '';
}
@@ -31,11 +31,12 @@
subscriptSizing="dynamic">
<mat-icon matPrefix fontIcon="sort"></mat-icon>
<mat-select
[value]="sortMode"
(selectionChange)="setSortMode($event.value)">
[value]="sortColumn"
(selectionChange)="setSort($event.value)">
<mat-select-trigger>Sortieren nach</mat-select-trigger>
<mat-option value="date">Datum</mat-option>
<mat-option value="year">Jahr</mat-option>
<mat-option value="title">Titel</mat-option>
<mat-option value="source">Quelle</mat-option>
</mat-select>
</mat-form-field>
</div>
@@ -44,8 +45,28 @@
<thead>
<tr>
<th>Patent</th>
<th>Quelle</th>
<th>Jahr</th>
<th
class="sortable"
[class.sort-active]="sortColumn === 'source'"
(click)="setSort('source')">
Quelle
@if (sortColumn === 'source') {
<mat-icon class="sort-icon">{{
sortDirection === 'asc' ? 'arrow_upward' : 'arrow_downward'
}}</mat-icon>
}
</th>
<th
class="sortable"
[class.sort-active]="sortColumn === 'year'"
(click)="setSort('year')">
Jahr
@if (sortColumn === 'year') {
<mat-icon class="sort-icon">{{
sortDirection === 'asc' ? 'arrow_upward' : 'arrow_downward'
}}</mat-icon>
}
</th>
<th>Erfinder</th>
<th>Anmelder</th>
</tr>
@@ -69,12 +90,85 @@
{{ patent.source }}
</span>
</td>
<td>{{ patent.publication_year ?? '-' }}</td>
<td class="patent-people" [title]="getInventorsLabel(patent)">
{{ getInventorsLabel(patent) }}
<td>
@if (patent.publication_year) {
<span class="year-badge">{{
patent.publication_year
}}</span>
} @else {
<span>-</span>
}
</td>
<td class="patent-people" [title]="getAssigneesLabel(patent)">
{{ getAssigneesLabel(patent) }}
<td class="patent-people">
@if (patent.inventors && patent.inventors.length) {
<div class="person-chips">
@for (
inventor of patent.inventors.slice(0, 2);
track inventor
) {
<span class="person-chip">
<mat-icon>person</mat-icon>
{{ inventor }}
</span>
}
@if (patent.inventors.length > 2) {
<span class="person-chip-row">
<span class="person-chip">
<mat-icon>person</mat-icon>
{{ patent.inventors[2] }}
</span>
@if (patent.inventors.length > 3) {
<span class="person-chip person-chip--more"
>+{{ patent.inventors.length - 3 }}</span
>
}
</span>
}
</div>
} @else {
<span>-</span>
}
</td>
<td class="patent-people">
@if (patent.assignees && patent.assignees.length) {
<div class="person-chips">
@for (
assignee of patent.assignees.slice(0, 2);
track assignee
) {
<span class="person-chip">
<mat-icon>{{
isAssigneeLikelyPerson(assignee, patent)
? 'person'
: 'apartment'
}}</mat-icon>
{{ assignee }}
</span>
}
@if (patent.assignees.length > 2) {
<span class="person-chip-row">
<span class="person-chip">
<mat-icon>{{
isAssigneeLikelyPerson(
patent.assignees[2],
patent
)
? 'person'
: 'apartment'
}}</mat-icon>
{{ patent.assignees[2] }}
</span>
@if (patent.assignees.length > 3) {
<span class="person-chip person-chip--more"
>+{{ patent.assignees.length - 3 }}</span
>
}
</span>
}
</div>
} @else {
<span>-</span>
}
</td>
</tr>
}
@@ -50,9 +50,24 @@ app-query-param-paginator {
text-align: left;
padding: 12px 16px;
border-bottom: 1px solid var(--sg-border);
font-size: 13px;
font-weight: 600;
font-size: 12px;
font-weight: 700;
color: var(--sg-text-muted);
&.sortable {
display: table-cell;
cursor: pointer;
-webkit-user-select: none;
user-select: none;
}
.sort-icon {
vertical-align: middle;
margin-left: 2px;
width: 14px;
height: 14px;
font-size: 14px;
}
}
tr {
@@ -80,22 +95,75 @@ app-query-param-paginator {
.patent-title {
color: var(--sg-text);
font-weight: 600;
max-width: 400px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 320px;
white-space: normal;
word-break: break-word;
}
.patent-people {
max-width: 220px;
color: var(--sg-text-muted);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 260px;
}
}
}
.year-badge {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 26px;
padding: 2px 10px;
border-radius: 999px;
border: 1px solid var(--sg-border);
color: var(--sg-text);
font-size: 0.8rem;
font-weight: 600;
}
.person-chips {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 4px;
}
.person-chip-row {
display: flex;
flex-direction: row;
align-items: center;
flex-wrap: wrap;
gap: 4px;
}
.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;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
mat-icon {
flex-shrink: 0;
width: 14px;
height: 14px;
font-size: 14px;
color: var(--sg-text-soft);
}
&--more {
color: var(--sg-text-muted);
font-weight: 600;
}
}
.match-badges {
display: flex;
flex-wrap: wrap;
@@ -16,7 +16,8 @@ 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';
type SortMode = 'date' | 'title';
type SortColumn = 'title' | 'year' | 'source';
type SortDirection = 'asc' | 'desc';
type SourceFilter = 'all' | 'EPO' | 'USPTO';
@Component({
@@ -46,14 +47,16 @@ export class PersonPatentsComponent {
error = false;
activeFilter: SourceFilter = 'all';
sortMode: SortMode = 'date';
sortColumn: SortColumn = 'year';
sortDirection: SortDirection = 'desc';
pageIndex = 0;
pageSize = 10;
constructor() {
const filterFromUrl = this.route.snapshot.queryParamMap.get('filter');
const sortFromUrl = this.route.snapshot.queryParamMap.get('sortBy');
const sortByFromUrl = this.route.snapshot.queryParamMap.get('sortBy');
const sortDirFromUrl = this.route.snapshot.queryParamMap.get('sortDir');
this.pageIndex = this.parsePageIndexParam(
this.route.snapshot.queryParamMap.get('page'),
);
@@ -64,8 +67,11 @@ export class PersonPatentsComponent {
if (this.isValidFilter(filterFromUrl)) {
this.activeFilter = filterFromUrl;
}
if (this.isValidSortMode(sortFromUrl)) {
this.sortMode = sortFromUrl;
if (this.isValidSortColumn(sortByFromUrl)) {
this.sortColumn = sortByFromUrl;
}
if (this.isValidSortDirection(sortDirFromUrl)) {
this.sortDirection = sortDirFromUrl;
}
this.route.parent?.data
@@ -113,8 +119,13 @@ export class PersonPatentsComponent {
this.pageSize = event.pageSize;
}
setSortMode(sortMode: SortMode): void {
this.sortMode = sortMode;
setSort(column: SortColumn): void {
if (this.sortColumn === column) {
this.sortDirection = this.sortDirection === 'asc' ? 'desc' : 'asc';
} else {
this.sortColumn = column;
this.sortDirection = column === 'year' ? 'desc' : 'asc';
}
this.applyFilter();
this.updateQueryParams();
}
@@ -140,15 +151,24 @@ export class PersonPatentsComponent {
}
private sortPatents(patents: PatentEntry[]): PatentEntry[] {
const direction = this.sortDirection === 'asc' ? 1 : -1;
return [...patents].sort((a, b) => {
if (this.sortMode === 'date') {
return (b.publication_date ?? '').localeCompare(
a.publication_date ?? '',
);
switch (this.sortColumn) {
case 'year': {
const yearA = a.publication_date ?? String(a.publication_year ?? '');
const yearB = b.publication_date ?? String(b.publication_year ?? '');
return direction * yearA.localeCompare(yearB);
}
case 'source':
return direction * a.source.localeCompare(b.source);
default:
return (
direction *
(a.title ?? '').localeCompare(b.title ?? '', 'de', {
sensitivity: 'base',
})
);
}
return (a.title ?? '').localeCompare(b.title ?? '', 'de', {
sensitivity: 'base',
});
});
}
@@ -157,7 +177,8 @@ export class PersonPatentsComponent {
relativeTo: this.route,
queryParams: {
filter: this.activeFilter,
sortBy: this.sortMode,
sortBy: this.sortColumn,
sortDir: this.sortDirection,
page: this.pageIndex,
size: this.pageSize,
},
@@ -180,8 +201,12 @@ export class PersonPatentsComponent {
return value === 'all' || value === 'EPO' || value === 'USPTO';
}
private isValidSortMode(value: string | null): value is SortMode {
return value === 'date' || value === 'title';
private isValidSortColumn(value: string | null): value is SortColumn {
return value === 'title' || value === 'year' || value === 'source';
}
private isValidSortDirection(value: string | null): value is SortDirection {
return value === 'asc' || value === 'desc';
}
getPagedPatents(): PatentEntry[] {
@@ -189,12 +214,40 @@ export class PersonPatentsComponent {
return this.filteredPatents.slice(start, start + this.pageSize);
}
getInventorsLabel(patent: PatentEntry): string {
return patent.inventors?.length ? patent.inventors.join(', ') : '-';
private static readonly ORG_SUFFIX_PATTERN =
/\b(Inc|Ltd|LLC|LLP|GmbH|Corp(oration)?|Co|KG|AG|SE|S\.?A\.?|N\.?V\.?|B\.?V\.?|PLC|Universit(y|ät|é)|Institut(e)?|Foundation|Laborator(y|ies)|Labs?|Group|Holdings?|Company|Gesellschaft)\b\.?/i;
private static readonly PERSON_SUFFIX_PATTERN =
/\b(Dr|Prof|PhD|Ph\.D|M\.D|Jr|Sr)\b\.?/i;
private normalizeNameForComparison(name: string): string {
return name
.normalize('NFD')
.replace(/[̀-ͯ]/g, '')
.replace(/[.,]/g, '')
.toUpperCase()
.split(/\s+/)
.filter(Boolean)
.sort()
.join(' ');
}
getAssigneesLabel(patent: PatentEntry): string {
return patent.assignees?.length ? patent.assignees.join(', ') : '-';
isAssigneeLikelyPerson(assignee: string, patent: PatentEntry): boolean {
if (PersonPatentsComponent.ORG_SUFFIX_PATTERN.test(assignee)) {
return false;
}
const normalizedAssignee = this.normalizeNameForComparison(
assignee.replace(PersonPatentsComponent.PERSON_SUFFIX_PATTERN, ''),
);
const matchesInventor = (patent.inventors ?? []).some(
(inventor) =>
this.normalizeNameForComparison(inventor) === normalizedAssignee,
);
if (matchesInventor) {
return true;
}
return PersonPatentsComponent.PERSON_SUFFIX_PATTERN.test(assignee);
}
formatDate(date: string | null | undefined): string {