From d06c1954a50e219a0fc19a5e267bec68b4dc8aa8 Mon Sep 17 00:00:00 2001 From: Khuder Khalti Date: Tue, 4 Aug 2026 20:36:33 +0200 Subject: [PATCH] feat(person-funding, person-patents, institution-patents, keywords-patents): add sortable column headers and refine inventor/assignee chip styling --- .../institution-patents.component.html | 137 ++++++++++++++++-- .../institution-patents.component.scss | 86 +++++++++-- .../institution-patents.component.ts | 114 +++++++++++---- .../keywords-patents.component.html | 122 ++++++++++++++-- .../keywords-patents.component.scss | 106 +++++++++----- .../keywords-patents.component.ts | 88 ++++++++--- .../person-funding.component.html | 71 +++++++-- .../person-funding.component.scss | 35 +++-- .../person-funding.component.ts | 80 +++++++--- .../person-patents.component.html | 114 +++++++++++++-- .../person-patents.component.scss | 90 ++++++++++-- .../person-patents.component.ts | 95 +++++++++--- 12 files changed, 942 insertions(+), 196 deletions(-) diff --git a/webapp/src/app/modules/institution-patents/institution-patents.component.html b/webapp/src/app/modules/institution-patents/institution-patents.component.html index 290cf522..fbb05df2 100644 --- a/webapp/src/app/modules/institution-patents/institution-patents.component.html +++ b/webapp/src/app/modules/institution-patents/institution-patents.component.html @@ -54,11 +54,13 @@ subscriptSizing="dynamic"> + [value]="sortColumn" + (selectionChange)="setSort($event.value)"> Sortieren nach - Datum + Jahr Titel + Quelle + Match-Typ @@ -67,11 +69,41 @@ Patent - Quelle - Jahr + + Quelle + @if (sortColumn === 'source') { + {{ + sortDirection === 'asc' ? 'arrow_upward' : 'arrow_downward' + }} + } + + + Jahr + @if (sortColumn === 'year') { + {{ + sortDirection === 'asc' ? 'arrow_upward' : 'arrow_downward' + }} + } + Erfinder Applicant/Assignee - Match-Typ + + Match-Typ + @if (sortColumn === 'matchType') { + {{ + sortDirection === 'asc' ? 'arrow_upward' : 'arrow_downward' + }} + } + Personen @@ -94,9 +126,86 @@ {{ patent.source }} - {{ patent.publication_year ?? '-' }} - {{ getInventorsPreview(patent) }} - {{ getAssigneesPreview(patent) }} + + @if (patent.publication_year) { + {{ + patent.publication_year + }} + } @else { + - + } + + + @if (patent.inventors && patent.inventors.length) { +
+ @for ( + inventor of patent.inventors.slice(0, 2); + track inventor + ) { + + person + {{ inventor }} + + } + @if (patent.inventors.length > 2) { + + + person + {{ patent.inventors[2] }} + + @if (patent.inventors.length > 3) { + +{{ patent.inventors.length - 3 }} + } + + } +
+ } @else { + - + } + + + @if (patent.assignees && patent.assignees.length) { +
+ @for ( + assignee of patent.assignees.slice(0, 2); + track assignee + ) { + + {{ + isAssigneeLikelyPerson(assignee, patent) + ? 'person' + : 'apartment' + }} + {{ assignee }} + + } + @if (patent.assignees.length > 2) { + + + {{ + isAssigneeLikelyPerson( + patent.assignees[2], + patent + ) + ? 'person' + : 'apartment' + }} + {{ patent.assignees[2] }} + + @if (patent.assignees.length > 3) { + +{{ patent.assignees.length - 3 }} + } + + } +
+ } @else { + - + } + @@ -118,6 +227,10 @@ '/person', author.openalex_author_id, ]" + [appComponentTooltip]="AuthorTooltipComponent" + [tooltipInputs]="{ + authorId: author.openalex_author_id, + }" (click)="$event.stopPropagation()"> {{ author.author_name }} @@ -197,7 +310,11 @@
  • + [routerLink]="['/person', author.openalex_author_id]" + [appComponentTooltip]="AuthorTooltipComponent" + [tooltipInputs]="{ + authorId: author.openalex_author_id, + }"> {{ author.author_name }}
  • diff --git a/webapp/src/app/modules/institution-patents/institution-patents.component.scss b/webapp/src/app/modules/institution-patents/institution-patents.component.scss index 4b3fdb39..c0827596 100644 --- a/webapp/src/app/modules/institution-patents/institution-patents.component.scss +++ b/webapp/src/app/modules/institution-patents/institution-patents.component.scss @@ -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; diff --git a/webapp/src/app/modules/institution-patents/institution-patents.component.ts b/webapp/src/app/modules/institution-patents/institution-patents.component.ts index 196200d0..ea75813b 100644 --- a/webapp/src/app/modules/institution-patents/institution-patents.component.ts +++ b/webapp/src/app/modules/institution-patents/institution-patents.component.ts @@ -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 { diff --git a/webapp/src/app/modules/keywords-search/keywords-patents/keywords-patents.component.html b/webapp/src/app/modules/keywords-search/keywords-patents/keywords-patents.component.html index 20d2eef7..838a42ad 100644 --- a/webapp/src/app/modules/keywords-search/keywords-patents/keywords-patents.component.html +++ b/webapp/src/app/modules/keywords-search/keywords-patents/keywords-patents.component.html @@ -31,11 +31,12 @@ subscriptSizing="dynamic"> + [value]="sortColumn()" + (selectionChange)="setSort($event.value)"> Sortieren nach - Datum + Jahr Titel + Quelle @@ -44,8 +45,32 @@ Patent - Quelle - Jahr + + Quelle + @if (sortColumn() === 'source') { + {{ + sortDirection() === 'asc' + ? 'arrow_upward' + : 'arrow_downward' + }} + } + + + Jahr + @if (sortColumn() === 'year') { + {{ + sortDirection() === 'asc' + ? 'arrow_upward' + : 'arrow_downward' + }} + } + Erfinder Anmelder @@ -66,16 +91,85 @@ {{ item.patent.source }}
    - {{ item.patent.publication_year ?? '-' }} - - {{ getInventorsLabel(item.patent) }} + + @if (item.patent.publication_year) { + {{ + item.patent.publication_year + }} + } @else { + - + } - - {{ getAssigneesLabel(item.patent) }} + + @if (item.patent.inventors && item.patent.inventors.length) { +
    + @for ( + inventor of item.patent.inventors.slice(0, 2); + track inventor + ) { + + person + {{ inventor }} + + } + @if (item.patent.inventors.length > 2) { + + + person + {{ item.patent.inventors[2] }} + + @if (item.patent.inventors.length > 3) { + +{{ item.patent.inventors.length - 3 }} + } + + } +
    + } @else { + - + } + + + @if (item.patent.assignees && item.patent.assignees.length) { +
    + @for ( + assignee of item.patent.assignees.slice(0, 2); + track assignee + ) { + + {{ + isAssigneeLikelyPerson(assignee, item.patent) + ? 'person' + : 'apartment' + }} + {{ assignee }} + + } + @if (item.patent.assignees.length > 2) { + + + {{ + isAssigneeLikelyPerson( + item.patent.assignees[2], + item.patent + ) + ? 'person' + : 'apartment' + }} + {{ item.patent.assignees[2] }} + + @if (item.patent.assignees.length > 3) { + +{{ item.patent.assignees.length - 3 }} + } + + } +
    + } @else { + - + } } diff --git a/webapp/src/app/modules/keywords-search/keywords-patents/keywords-patents.component.scss b/webapp/src/app/modules/keywords-search/keywords-patents/keywords-patents.component.scss index a8ddbb74..75c648eb 100644 --- a/webapp/src/app/modules/keywords-search/keywords-patents/keywords-patents.component.scss +++ b/webapp/src/app/modules/keywords-search/keywords-patents/keywords-patents.component.scss @@ -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 { diff --git a/webapp/src/app/modules/keywords-search/keywords-patents/keywords-patents.component.ts b/webapp/src/app/modules/keywords-search/keywords-patents/keywords-patents.component.ts index 4a636af1..4674b509 100644 --- a/webapp/src/app/modules/keywords-search/keywords-patents/keywords-patents.component.ts +++ b/webapp/src/app/modules/keywords-search/keywords-patents/keywords-patents.component.ts @@ -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(); activeFilter = signal('all'); - sortMode = signal('date'); + sortColumn = signal('year'); + sortDirection = signal('desc'); selectedMatch = signal(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', - }); }); } } diff --git a/webapp/src/app/modules/person-funding/person-funding.component.html b/webapp/src/app/modules/person-funding/person-funding.component.html index 85a34c96..70bec121 100644 --- a/webapp/src/app/modules/person-funding/person-funding.component.html +++ b/webapp/src/app/modules/person-funding/person-funding.component.html @@ -33,22 +33,75 @@ subscriptSizing="dynamic"> + [value]="sortColumn" + (selectionChange)="setSort($event.value)"> Sortieren nach - Name - Top Förderer + Förderer + Publikationen + Erstautor + Mitautor + Letztautor - - - - - + + + + + diff --git a/webapp/src/app/modules/person-funding/person-funding.component.scss b/webapp/src/app/modules/person-funding/person-funding.component.scss index 282f90e9..079c6a46 100644 --- a/webapp/src/app/modules/person-funding/person-funding.component.scss +++ b/webapp/src/app/modules/person-funding/person-funding.component.scss @@ -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); diff --git a/webapp/src/app/modules/person-funding/person-funding.component.ts b/webapp/src/app/modules/person-funding/person-funding.component.ts index b6e5c211..7a5bac13 100644 --- a/webapp/src/app/modules/person-funding/person-funding.component.ts +++ b/webapp/src/app/modules/person-funding/person-funding.component.ts @@ -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 ?? ''; } diff --git a/webapp/src/app/modules/person-patents/person-patents.component.html b/webapp/src/app/modules/person-patents/person-patents.component.html index 398004ef..b32185a7 100644 --- a/webapp/src/app/modules/person-patents/person-patents.component.html +++ b/webapp/src/app/modules/person-patents/person-patents.component.html @@ -31,11 +31,12 @@ subscriptSizing="dynamic"> + [value]="sortColumn" + (selectionChange)="setSort($event.value)"> Sortieren nach - Datum + Jahr Titel + Quelle @@ -44,8 +45,28 @@ - - + + @@ -69,12 +90,85 @@ {{ patent.source }} - - - + } diff --git a/webapp/src/app/modules/person-patents/person-patents.component.scss b/webapp/src/app/modules/person-patents/person-patents.component.scss index 6bed2a07..9c9c1410 100644 --- a/webapp/src/app/modules/person-patents/person-patents.component.scss +++ b/webapp/src/app/modules/person-patents/person-patents.component.scss @@ -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; diff --git a/webapp/src/app/modules/person-patents/person-patents.component.ts b/webapp/src/app/modules/person-patents/person-patents.component.ts index ece9c4dd..508f41ed 100644 --- a/webapp/src/app/modules/person-patents/person-patents.component.ts +++ b/webapp/src/app/modules/person-patents/person-patents.component.ts @@ -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 {
    FördererPublikationenErstautorMitautorLetztautor + Förderer + @if (sortColumn === 'name') { + {{ + sortDirection === 'asc' ? 'arrow_upward' : 'arrow_downward' + }} + } + + Publikationen + @if (sortColumn === 'publications') { + {{ + sortDirection === 'asc' ? 'arrow_upward' : 'arrow_downward' + }} + } + + Erstautor + @if (sortColumn === 'first') { + {{ + sortDirection === 'asc' ? 'arrow_upward' : 'arrow_downward' + }} + } + + Mitautor + @if (sortColumn === 'middle') { + {{ + sortDirection === 'asc' ? 'arrow_upward' : 'arrow_downward' + }} + } + + Letztautor + @if (sortColumn === 'last') { + {{ + sortDirection === 'asc' ? 'arrow_upward' : 'arrow_downward' + }} + } +
    PatentQuelleJahr + Quelle + @if (sortColumn === 'source') { + {{ + sortDirection === 'asc' ? 'arrow_upward' : 'arrow_downward' + }} + } + + Jahr + @if (sortColumn === 'year') { + {{ + sortDirection === 'asc' ? 'arrow_upward' : 'arrow_downward' + }} + } + Erfinder Anmelder
    {{ patent.publication_year ?? '-' }} - {{ getInventorsLabel(patent) }} + + @if (patent.publication_year) { + {{ + patent.publication_year + }} + } @else { + - + } - {{ getAssigneesLabel(patent) }} + + @if (patent.inventors && patent.inventors.length) { +
    + @for ( + inventor of patent.inventors.slice(0, 2); + track inventor + ) { + + person + {{ inventor }} + + } + @if (patent.inventors.length > 2) { + + + person + {{ patent.inventors[2] }} + + @if (patent.inventors.length > 3) { + +{{ patent.inventors.length - 3 }} + } + + } +
    + } @else { + - + } +
    + @if (patent.assignees && patent.assignees.length) { +
    + @for ( + assignee of patent.assignees.slice(0, 2); + track assignee + ) { + + {{ + isAssigneeLikelyPerson(assignee, patent) + ? 'person' + : 'apartment' + }} + {{ assignee }} + + } + @if (patent.assignees.length > 2) { + + + {{ + isAssigneeLikelyPerson( + patent.assignees[2], + patent + ) + ? 'person' + : 'apartment' + }} + {{ patent.assignees[2] }} + + @if (patent.assignees.length > 3) { + +{{ patent.assignees.length - 3 }} + } + + } +
    + } @else { + - + }