@if (article.full_content) { -

+ [content]="article.full_content" + [highlights]="articleHighlights" /> } @else {

Kein Inhalt verfügbar.

} @@ -230,8 +231,8 @@ »{{ topic.source_keyword }}«

- Im Artikel hervorgehoben · klicken zum Suche zu - öffnen + Im Artikel hervorgehoben - klicken, um zum + ersten Vorkommen zu springen.

} @else {

diff --git a/webapp/src/app/modules/news-detail/news-detail.component.scss b/webapp/src/app/modules/news-detail/news-detail.component.scss index 1d31ab79..9577c0be 100644 --- a/webapp/src/app/modules/news-detail/news-detail.component.scss +++ b/webapp/src/app/modules/news-detail/news-detail.component.scss @@ -587,8 +587,6 @@ main { --topic-color: var(--sg-error); } -// ── Keyword highlights in article text ─────────────────────────────────────── - @keyframes kw-flash { 0% { background: color-mix(in srgb, var(--t) 45%, var(--sg-color-mix-base)); @@ -600,25 +598,3 @@ main { background: transparent; } } - -:host ::ng-deep .kw-mark { - background: transparent; - color: var(--t); - text-decoration: underline; - text-decoration-color: var(--t); - text-decoration-style: solid; - text-decoration-thickness: 2px; - text-underline-offset: 2px; - font-weight: inherit; - border-radius: 2px; - padding: 0 1px; - transition: background 0.15s; - - &:hover { - background: color-mix(in srgb, var(--t) 15%, var(--sg-color-mix-base)); - } - - &.kw-flash { - animation: kw-flash 2.4s ease-out forwards; - } -} diff --git a/webapp/src/app/modules/news-detail/news-detail.component.ts b/webapp/src/app/modules/news-detail/news-detail.component.ts index 707f191f..2c2b86a9 100644 --- a/webapp/src/app/modules/news-detail/news-detail.component.ts +++ b/webapp/src/app/modules/news-detail/news-detail.component.ts @@ -6,17 +6,22 @@ import { ViewChild, inject, } from '@angular/core'; -import { Location } from '@angular/common'; import { HttpClient } from '@angular/common/http'; import { ActivatedRoute, Router, RouterLink } from '@angular/router'; import { MatButtonModule } from '@angular/material/button'; import { MatIconModule } from '@angular/material/icon'; import { MatTooltipModule } from '@angular/material/tooltip'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; -import { DomSanitizer, SafeHtml } from '@angular/platform-browser'; - +import { + HighlightedTextComponent, + HighlightTerm, +} from '../../shared/ui/highlighted-text/highlighted-text.component'; import { WorksService } from '../../api'; import { topicHierarchyColor } from '../../resolvers/utils/topic-colors'; +import { + highlightKeywords, + topicKeywordColors, +} from '../../resolvers/utils/keyword-highlight'; import { LoadingComponent } from '../../shared/ui/loading/loading.component'; interface MentionedPerson { @@ -55,22 +60,21 @@ interface NewsArticleDetail { MatTooltipModule, RouterLink, LoadingComponent, + HighlightedTextComponent, ], templateUrl: './news-detail.component.html', styleUrl: './news-detail.component.scss', }) export class NewsDetailComponent implements OnInit { - @ViewChild('articleBody') articleBodyRef?: ElementRef; + @ViewChild('articleBody', { read: ElementRef }) + articleBodyRef?: ElementRef; private readonly router = inject(Router); private readonly destroyRef = inject(DestroyRef); private readonly route = inject(ActivatedRoute); private readonly httpClient = inject(HttpClient); private readonly worksService = inject(WorksService); - private readonly location = inject(Location); - private readonly sanitizer = inject(DomSanitizer); article: NewsArticleDetail | null = null; - highlightedContent: SafeHtml = this.sanitizer.bypassSecurityTrustHtml(''); loading = false; notFound = false; @@ -150,7 +154,7 @@ export class NewsDetailComponent implements OnInit { } navigateBack(): void { - this.location.back(); + this.router.navigate(['/news']); } formatDate(dateStr?: string | null): string { @@ -174,7 +178,6 @@ export class NewsDetailComponent implements OnInit { .subscribe({ next: (article) => { this.article = article; - this.highlightedContent = this.buildHighlightedContent(article); this.expandedTopicId = null; this.personsPage = 0; this.loading = false; @@ -186,62 +189,33 @@ export class NewsDetailComponent implements OnInit { }); } - private buildHighlightedContent(article: NewsArticleDetail): SafeHtml { - const text = article.full_content; - if (!text) return this.sanitizer.bypassSecurityTrustHtml(''); - const keywords = article.keywords ?? []; + get articleHighlights(): HighlightTerm[] { + const article = this.article; + if (!article) return []; - const keywordColorMap = new Map(); + const topicByKeyword = new Map(); for (const topic of article.topics ?? []) { if (topic.source_keyword) { - keywordColorMap.set( - topic.source_keyword.toLowerCase(), - this.getTopicColor(topic), - ); + topicByKeyword.set(topic.source_keyword.toLowerCase(), topic); } } - const orphanColors = [ - 'var(--sg-primary)', - 'var(--sg-blue-highlight)', - 'var(--sg-success)', - 'var(--sg-warning)', - 'var(--sg-error)', - ]; - let orphanIdx = 0; - let html = this.escapeHtml(text); - if (keywords.length) { - [...keywords] - .sort((a, b) => b.length - a.length) - .forEach((kw) => { - let color = keywordColorMap.get(kw.toLowerCase()); - if (!color) { - color = orphanColors[orphanIdx % orphanColors.length]; - orphanIdx++; - } - const kwHtml = this.escapeHtml(kw); - const re = new RegExp( - `(${this.escapeRegex(kwHtml)}[\\w\\u00C0-\\u024F]*)`, - 'gi', - ); - html = html.replace( - re, - `$1`, - ); - }); + const highlights: HighlightTerm[] = []; + for (const keyword of article.keywords ?? []) { + const topic = topicByKeyword.get(keyword.toLowerCase()); + if (!topic) continue; + + highlights.push({ + term: keyword, + topic: { + id: topic.id, + name: topic.display_name, + field_name: topic.field_name, + domain_name: topic.domain_name, + }, + }); } - return this.sanitizer.bypassSecurityTrustHtml(html); - } - private escapeHtml(text: string): string { - return text - .replace(/&/g, '&') - .replace(//g, '>') - .replace(/"/g, '"'); - } - - private escapeRegex(text: string): string { - return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); + return highlights; } } diff --git a/webapp/src/app/modules/news/news.component.html b/webapp/src/app/modules/news/news.component.html index c5fcd597..e0848c56 100644 --- a/webapp/src/app/modules/news/news.component.html +++ b/webapp/src/app/modules/news/news.component.html @@ -18,18 +18,24 @@

- - - Relevant - Nicht relevant - - + + + + @if (!isSearching()) { + + } +
diff --git a/webapp/src/app/modules/news/news.component.scss b/webapp/src/app/modules/news/news.component.scss index d668b89a..14ecda37 100644 --- a/webapp/src/app/modules/news/news.component.scss +++ b/webapp/src/app/modules/news/news.component.scss @@ -44,20 +44,36 @@ color: var(--sg-text-muted); } +$card-min-width: 380px; + .additional-filters { - display: flex; - align-items: center; - flex-wrap: wrap; - gap: 40px; + display: grid; + grid-template-columns: repeat(auto-fill, minmax($card-min-width, 1fr)); + align-items: stretch; + gap: 1.5rem; padding: 0 1rem 1rem; + + app-year-range-slider { + display: flex; + } + + ::ng-deep app-year-range-slider .year-filter { + height: 100%; + } + + ::ng-deep .mat-mdc-form-field-subscript-wrapper { + display: none; + } + + ::ng-deep .mat-mdc-form-field-icon-prefix { + padding: 0 4px 0 10px; + } } -.relevance-field { - width: 180px; -} - -.year-field { - min-width: 280px; +.relevance-field, +.sort-order-field { + flex: 1; + min-width: 0; } @media (max-width: 600px) { diff --git a/webapp/src/app/modules/news/news.component.ts b/webapp/src/app/modules/news/news.component.ts index 9d916390..13b99041 100644 --- a/webapp/src/app/modules/news/news.component.ts +++ b/webapp/src/app/modules/news/news.component.ts @@ -7,12 +7,10 @@ import { signal, } from '@angular/core'; import { HttpClient, HttpParams } from '@angular/common/http'; -import { FormControl, ReactiveFormsModule } from '@angular/forms'; +import { FormControl } from '@angular/forms'; import { ActivatedRoute, Router } from '@angular/router'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { debounceTime, merge } from 'rxjs'; -import { MatFormFieldModule } from '@angular/material/form-field'; -import { MatSelectModule } from '@angular/material/select'; import { WorksService } from '../../api'; import { @@ -24,7 +22,11 @@ import { NewsCardComponent, NEWS_MIN_YEAR, } from '../../shared/ui/news-card/news-card.component'; -import { SelectorOption } from '../../shared/ui/query-param-selector/query-param-selector.component'; +import { + QueryParamSelectorComponent, + SelectorOption, +} from '../../shared/ui/query-param-selector/query-param-selector.component'; +import { FilterCardComponent } from '../../shared/ui/filter-card/filter-card.component'; import { YearRangeSliderComponent } from '../../shared/ui/year-range-slider/year-range-slider.component'; interface NewsArticle extends NewsArticleBase { @@ -44,11 +46,10 @@ type SortOrder = 'desc' | 'asc'; @Component({ selector: 'app-news', imports: [ - ReactiveFormsModule, - MatFormFieldModule, - MatSelectModule, CardSearchComponent, NewsCardComponent, + FilterCardComponent, + QueryParamSelectorComponent, YearRangeSliderComponent, ], templateUrl: './news.component.html', @@ -64,11 +65,16 @@ export class NewsComponent implements OnInit { readonly minYear = NEWS_MIN_YEAR; readonly maxYear = new Date().getFullYear(); - private readonly sortingDirectionOptionsAll: SelectorOption[] = [ + readonly sortingDirectionOptionsAll: SelectorOption[] = [ { value: 'desc', display_name: 'Neueste zuerst' }, { value: 'asc', display_name: 'Älteste zuerst' }, ]; + readonly relevanceOptions: SelectorOption[] = [ + { value: 'relevant', display_name: 'Relevant' }, + { value: 'not_relevant', display_name: 'Nicht relevant' }, + ]; + readonly relevanceFilter = new FormControl([], { nonNullable: true, }); @@ -85,9 +91,6 @@ export class NewsComponent implements OnInit { readonly searchQuery = signal(''); readonly isSearching = computed(() => this.searchQuery().trim().length > 0); - readonly sortingDirectionOptions = computed(() => - this.isSearching() ? [] : this.sortingDirectionOptionsAll, - ); readonly page = computed(() => ({ page: this.currentPage, diff --git a/webapp/src/app/modules/organizations/organization-dialog/institution-removal-dialog.component.ts b/webapp/src/app/modules/organizations/organization-dialog/institution-removal-dialog.component.ts new file mode 100644 index 00000000..8e34d14b --- /dev/null +++ b/webapp/src/app/modules/organizations/organization-dialog/institution-removal-dialog.component.ts @@ -0,0 +1,65 @@ +import { Component, inject } from '@angular/core'; +import { MatButtonModule } from '@angular/material/button'; +import { + MAT_DIALOG_DATA, + MatDialogActions, + MatDialogContent, + MatDialogRef, + MatDialogTitle, +} from '@angular/material/dialog'; + +@Component({ + selector: 'app-institution-removal-dialog', + standalone: true, + imports: [ + MatButtonModule, + MatDialogActions, + MatDialogContent, + MatDialogTitle, + ], + template: ` +

Manuelle Auswahl entfernen

+ +

+ Möchtest du die manuelle Auswahl der Institution „{{ + data.institutionName + }}“ wirklich entfernen? +

+ @if (data.dependentCount === 1) { +

+ Dadurch wird außerdem 1 automatisch zugeordnete Institution aus der + Organisation entfernt. +

+ } @else if (data.dependentCount > 1) { +

+ Dadurch werden außerdem {{ data.dependentCount }} automatisch + zugeordnete Institutionen aus der Organisation entfernt. +

+ } +
+ + + + + `, +}) +export class InstitutionRemovalDialogComponent { + private readonly dialogRef = + inject>( + MatDialogRef, + ); + protected readonly data = inject<{ + institutionName: string; + dependentCount: number; + }>(MAT_DIALOG_DATA); + + protected close(): void { + this.dialogRef.close(false); + } + + protected confirm(): void { + this.dialogRef.close(true); + } +} diff --git a/webapp/src/app/modules/organizations/organization-dialog/organization-dialog.component.html b/webapp/src/app/modules/organizations/organization-dialog/organization-dialog.component.html index ee5a86f6..394da495 100644 --- a/webapp/src/app/modules/organizations/organization-dialog/organization-dialog.component.html +++ b/webapp/src/app/modules/organizations/organization-dialog/organization-dialog.component.html @@ -16,10 +16,85 @@ } - - Externe Institutions-ID - - +
+
+
+

OpenAlex-Institutionen

+

+ Bei der Auswahl werden untergeordnete und verbundene Institutionen + automatisch ergänzt. +

+
+ @if (isLoadingAssociations()) { + + } +
+ + + Institution hinzufügen + search + + @if (isSearchingInstitutions()) { + + } + + @for ( + institution of institutionSearchResults(); + track institution.id + ) { + + {{ institution.display_name }} + + {{ institution.country_code }} · {{ institution.type }} + + + } + + + +
+ @for (entry of institutions(); track entry.id) { +
+ apartment +
+ {{ entry.institution.display_name }} + {{ entry.id }} +
+ @for (label of originLabels(entry); track label.relationship) { + + {{ label.label }} + + } +
+
+ @if (entry.manuallySelected) { + + } +
+ } @empty { +

Noch keine Institution ausgewählt.

+ } +
+
@if (data.mode === 'edit') { @@ -31,7 +106,12 @@ - diff --git a/webapp/src/app/modules/organizations/organization-dialog/organization-dialog.component.scss b/webapp/src/app/modules/organizations/organization-dialog/organization-dialog.component.scss index 73a882d6..5fd27db0 100644 --- a/webapp/src/app/modules/organizations/organization-dialog/organization-dialog.component.scss +++ b/webapp/src/app/modules/organizations/organization-dialog/organization-dialog.component.scss @@ -1,7 +1,7 @@ .organization-form { display: grid; - gap: 12px; - min-width: min(540px, calc(100vw - 64px)); + gap: 18px; + min-width: min(680px, calc(100vw - 64px)); padding-top: 4px; } @@ -9,11 +9,101 @@ width: 100%; } +.institution-section { + display: grid; + gap: 12px; +} + +.section-heading { + display: flex; + align-items: flex-start; + justify-content: space-between; + gap: 16px; +} + +.section-heading h3 { + margin: 0 0 4px; + font-size: 16px; +} + +.section-heading p, +.empty-institutions { + margin: 0; + color: var(--sg-text-muted); + font-size: 13px; +} + +.institution-list { + display: grid; + gap: 8px; + max-height: 320px; + overflow: auto; +} + +.autocomplete-description { + display: block; + color: var(--sg-text-muted); + line-height: 1.2; +} + +.institution-item { + display: grid; + grid-template-columns: auto minmax(0, 1fr) auto; + align-items: center; + gap: 12px; + padding: 10px 8px 10px 12px; + border: 1px solid var(--sg-border-color, #d8d8d8); + border-radius: 8px; +} + +.institution-icon { + color: var(--sg-text-muted); +} + +.institution-details { + display: grid; + min-width: 0; + gap: 3px; +} + +.institution-details strong { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.institution-id { + color: var(--sg-text-muted); + font-size: 12px; +} + +.origin-labels { + display: flex; + flex-wrap: wrap; + gap: 5px; + margin-top: 3px; +} + +.origin-label { + padding: 2px 7px; + border-radius: 999px; + background: color-mix(in srgb, var(--mat-sys-primary) 10%, transparent); + color: var(--mat-sys-primary); + font-size: 11px; +} + +.empty-institutions { + padding: 14px; + border: 1px dashed var(--sg-border-color, #d8d8d8); + border-radius: 8px; + text-align: center; +} + mat-dialog-actions { padding: 12px 24px 20px; } -@media (max-width: 600px) { +@media (max-width: 760px) { .organization-form { min-width: 0; } diff --git a/webapp/src/app/modules/organizations/organization-dialog/organization-dialog.component.ts b/webapp/src/app/modules/organizations/organization-dialog/organization-dialog.component.ts index a192c306..c5039408 100644 --- a/webapp/src/app/modules/organizations/organization-dialog/organization-dialog.component.ts +++ b/webapp/src/app/modules/organizations/organization-dialog/organization-dialog.component.ts @@ -1,58 +1,108 @@ import { CommonModule } from '@angular/common'; -import { Component, inject } from '@angular/core'; +import { Component, computed, DestroyRef, inject, signal } from '@angular/core'; import { FormControl, FormGroup, ReactiveFormsModule, Validators, } from '@angular/forms'; +import { + MatAutocompleteModule, + MatAutocompleteSelectedEvent, +} from '@angular/material/autocomplete'; import { MatButtonModule } from '@angular/material/button'; import { MatCheckboxModule } from '@angular/material/checkbox'; import { MAT_DIALOG_DATA, + MatDialog, MatDialogModule, MatDialogRef, } from '@angular/material/dialog'; import { MatFormFieldModule } from '@angular/material/form-field'; import { MatIconModule } from '@angular/material/icon'; import { MatInputModule } from '@angular/material/input'; -import { InseOrganizationManagementModelOrganizationProfile } from '../../../api'; +import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'; +import { MatSnackBar, MatSnackBarModule } from '@angular/material/snack-bar'; +import { MatTooltipModule } from '@angular/material/tooltip'; +import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; +import { + catchError, + debounceTime, + distinctUntilChanged, + finalize, + of, + switchMap, +} from 'rxjs'; +import { + CreateOrganizationRequest, + InseOrganizationManagementModelOrganizationProfile, + Institution, + InstitutionAssociation, + InstitutionAssociationsResponse, + InstitutionsV2Service, + OrganizationService, + UpdateOrganizationRequest, +} from '../../../api'; +import { InstitutionRemovalDialogComponent } from './institution-removal-dialog.component'; -export interface CreateOrganizationPayload { - name: string; - other_inst_id?: string | null; +type Relationship = InstitutionAssociation.RelationshipEnum; + +interface InstitutionOrigin { + sourceId: string; + sourceName: string; + relationship: Relationship; } -export interface UpdateOrganizationPayload { - name?: string; - other_inst_id?: string | null; - deleted?: boolean; +interface EditableInstitution { + id: string; + institution: Institution; + manuallySelected: boolean; + origins: InstitutionOrigin[]; } +interface OriginLabel { + relationship: 'selected' | Relationship; + label: string; + tooltip?: string; +} + +type OrganizationWithInstitutions = + InseOrganizationManagementModelOrganizationProfile & { + institutionAssociations?: InstitutionAssociationsResponse[]; + }; + export interface OrganizationDialogData { mode: 'create' | 'edit'; - organization?: InseOrganizationManagementModelOrganizationProfile; + organization?: OrganizationWithInstitutions; + isCurrentOrganization?: boolean; } export type OrganizationDialogResult = - | { mode: 'create'; payload: CreateOrganizationPayload } + | { mode: 'create'; payload: CreateOrganizationRequest } | { mode: 'edit'; organizationId: string; - payload: UpdateOrganizationPayload; + payload: UpdateOrganizationRequest; }; +const cleanInstitutionId = (id: string): string => + id.split('/').filter(Boolean).pop() ?? id; + @Component({ selector: 'app-organization-dialog', imports: [ CommonModule, ReactiveFormsModule, + MatAutocompleteModule, MatButtonModule, MatCheckboxModule, MatDialogModule, MatFormFieldModule, MatIconModule, MatInputModule, + MatProgressSpinnerModule, + MatSnackBarModule, + MatTooltipModule, ], templateUrl: './organization-dialog.component.html', styleUrl: './organization-dialog.component.scss', @@ -66,23 +116,217 @@ export class OrganizationDialogComponent { OrganizationDialogResult | undefined > >(MatDialogRef); + private readonly dialog = inject(MatDialog); + private readonly organizationService = inject(OrganizationService); + private readonly institutionsService = inject(InstitutionsV2Service); + private readonly snackBar = inject(MatSnackBar); + private readonly destroyRef = inject(DestroyRef); protected readonly data = inject(MAT_DIALOG_DATA); + protected readonly isLoadingAssociations = signal(false); + protected readonly isSearchingInstitutions = signal(false); + protected readonly institutionSearchResults = signal([]); + private readonly selectedAssociations = signal< + InstitutionAssociationsResponse[] + >([...(this.data.organization?.institutionAssociations ?? [])]); + protected readonly institutions = computed(() => + this.expandInstitutions(this.selectedAssociations()), + ); + protected readonly institutionSearch = new FormControl( + '', + { nonNullable: true }, + ); + protected readonly form = new FormGroup({ name: new FormControl(this.data.organization?.name ?? '', { nonNullable: true, validators: [Validators.required], }), - otherInstId: new FormControl(this.data.organization?.other_inst_id ?? '', { - nonNullable: true, - }), - deleted: new FormControl(this.data.organization?.deleted ?? false, { - nonNullable: true, - }), + deleted: new FormControl( + { + value: this.data.organization?.deleted ?? false, + disabled: this.data.isCurrentOrganization ?? false, + }, + { nonNullable: true }, + ), }); + constructor() { + this.institutionSearch.valueChanges + .pipe( + debounceTime(300), + distinctUntilChanged(), + switchMap((value) => { + if (typeof value !== 'string' || !value.trim()) { + this.isSearchingInstitutions.set(false); + return of({ elements: [] as Institution[] }); + } + this.isSearchingInstitutions.set(true); + return this.institutionsService + .getInstitutionAutocompleteForSelector(value.trim()) + .pipe( + catchError(() => { + this.snackBar.open( + 'Institutionen konnten nicht geladen werden. Bitte versuche es später erneut.', + 'OK', + { duration: 5000 }, + ); + return of({ elements: [] as Institution[] }); + }), + finalize(() => this.isSearchingInstitutions.set(false)), + ); + }), + takeUntilDestroyed(this.destroyRef), + ) + .subscribe((page) => + this.institutionSearchResults.set(page.elements ?? []), + ); + } + + private expandInstitutions( + roots: InstitutionAssociationsResponse[], + ): EditableInstitution[] { + const entries = new Map(); + for (const root of roots) { + const id = cleanInstitutionId(root.id); + entries.set(id, { + id, + institution: { + id: `https://openalex.org/${id}`, + display_name: root.display_name, + }, + manuallySelected: true, + origins: [], + }); + } + for (const root of roots) { + const sourceId = cleanInstitutionId(root.id); + for (const association of root.associated_institutions ?? []) { + const id = cleanInstitutionId(association.id); + const entry = entries.get(id) ?? { + id, + institution: { + id: `https://openalex.org/${id}`, + display_name: association.display_name, + }, + manuallySelected: false, + origins: [], + }; + entry.origins.push({ + sourceId, + sourceName: root.display_name, + relationship: association.relationship, + }); + entries.set(id, entry); + } + } + return [...entries.values()]; + } + + protected selectInstitution(institution: Institution): void { + if (!institution.id || this.isLoadingAssociations()) return; + + const selectedId = cleanInstitutionId(institution.id); + this.isLoadingAssociations.set(true); + this.organizationService + .getOrganizationInstitutionAssociations([selectedId]) + .pipe(finalize(() => this.isLoadingAssociations.set(false))) + .subscribe({ + next: ([response]) => { + if (!response) return; + const roots = [...this.selectedAssociations()]; + const existingIndex = roots.findIndex( + (root) => cleanInstitutionId(root.id) === selectedId, + ); + if (existingIndex === -1) roots.push(response); + else roots[existingIndex] = response; + this.selectedAssociations.set(roots); + }, + error: () => { + this.snackBar.open( + 'Die Institution konnte nicht hinzugefügt werden. Bitte versuche es später erneut.', + 'OK', + { duration: 5000 }, + ); + }, + }); + } + + protected selectAutocompleteInstitution( + event: MatAutocompleteSelectedEvent, + ): void { + const institution = event.option.value as Institution; + this.institutionSearch.setValue('', { emitEvent: false }); + this.institutionSearchResults.set([]); + this.selectInstitution(institution); + } + + protected displayInstitution(institution: Institution | string): string { + return typeof institution === 'string' + ? institution + : (institution.display_name ?? ''); + } + + protected originLabels(entry: EditableInstitution): OriginLabel[] { + const labels: OriginLabel[] = []; + if (entry.manuallySelected) { + labels.push({ relationship: 'selected', label: 'Manuell ausgewählt' }); + } + for (const relationship of ['child', 'related'] as const) { + const sourceNames = [ + ...new Set( + entry.origins + .filter((origin) => origin.relationship === relationship) + .map((origin) => origin.sourceName), + ), + ]; + if (sourceNames.length === 0) continue; + labels.push({ + relationship, + label: relationship === 'child' ? 'Untergeordnet' : 'Verbunden', + tooltip: `Automatisch hinzugefügt durch:\n${sourceNames.map((name) => `• ${name}`).join('\n')}`, + }); + } + return labels; + } + + protected removeInstitution(entry: EditableInstitution): void { + if (!entry.manuallySelected) return; + + const remainingRoots = this.selectedAssociations().filter( + (root) => cleanInstitutionId(root.id) !== entry.id, + ); + const remainingIds = new Set( + this.expandInstitutions(remainingRoots).map( + (institution) => institution.id, + ), + ); + const dependentCount = this.institutions().filter( + (institution) => + institution.id !== entry.id && !remainingIds.has(institution.id), + ).length; + + this.dialog + .open< + InstitutionRemovalDialogComponent, + { institutionName: string; dependentCount: number }, + boolean | undefined + >(InstitutionRemovalDialogComponent, { + data: { + institutionName: entry.institution.display_name ?? entry.id, + dependentCount, + }, + width: '520px', + maxWidth: 'calc(100vw - 32px)', + }) + .afterClosed() + .subscribe((confirmed) => { + if (confirmed) this.selectedAssociations.set(remainingRoots); + }); + } + protected submit(): void { - if (this.form.invalid) { + if (this.form.invalid || this.isLoadingAssociations()) { this.form.markAllAsTouched(); return; } @@ -90,7 +334,9 @@ export class OrganizationDialogComponent { const value = this.form.getRawValue(); const payload = { name: value.name.trim(), - other_inst_id: value.otherInstId.trim(), + selected_openalex_institution_ids: this.selectedAssociations().map( + (root) => cleanInstitutionId(root.id), + ), }; if (this.data.mode === 'create') { diff --git a/webapp/src/app/modules/organizations/organizations.component.html b/webapp/src/app/modules/organizations/organizations.component.html index 14853ec0..b52e00b0 100644 --- a/webapp/src/app/modules/organizations/organizations.component.html +++ b/webapp/src/app/modules/organizations/organizations.component.html @@ -1,18 +1,20 @@
@@ -31,6 +33,32 @@ + + @if ($any(row).institutions.length > 0) { + + @for ( + institution of $any(row).institutions; + track institution.id; + let index = $index + ) { + @if (index < 3) { + {{ institution.display_name + }}{{ + index < 2 && index < $any(row).institutions.length - 1 ? ', ' : '' + }} + } + } + @if ($any(row).institutions.length > 3) { + + + {{ $any(row).institutions.length - 3 }} weitere + + } + + } @else { + Keine Institutionen + } + +
diff --git a/webapp/src/app/modules/organizations/organizations.component.scss b/webapp/src/app/modules/organizations/organizations.component.scss index c314dc8d..8b595ba9 100644 --- a/webapp/src/app/modules/organizations/organizations.component.scss +++ b/webapp/src/app/modules/organizations/organizations.component.scss @@ -6,6 +6,12 @@ } .page-header { + display: flex; + flex-direction: column; + gap: 6px; +} + +.page-header-meta { display: flex; align-items: center; justify-content: space-between; @@ -24,7 +30,7 @@ p { } .page-header p { - margin-top: 6px; + flex: 1 1 auto; } .status { @@ -49,7 +55,7 @@ p { padding: 16px; } - .page-header { + .page-header-meta { align-items: flex-start; flex-direction: column; } @@ -59,3 +65,8 @@ mat-card, mat-paginator { background-color: var(--sg-background); } + +.more-institutions, +.no-institutions { + color: var(--sg-text-muted); +} diff --git a/webapp/src/app/modules/organizations/organizations.component.ts b/webapp/src/app/modules/organizations/organizations.component.ts index 6cbaecb4..a06eff1c 100644 --- a/webapp/src/app/modules/organizations/organizations.component.ts +++ b/webapp/src/app/modules/organizations/organizations.component.ts @@ -16,11 +16,7 @@ import type { OrganizationDialogData, OrganizationDialogResult, } from './organization-dialog/organization-dialog.component'; -import { - InseOrganizationManagementModelOrganizationProfile, - OrganizationPage, - OrganizationService, -} from '../../api'; +import { OrganizationService } from '../../api'; import { GenericColumn, DataTableComponent, @@ -29,6 +25,11 @@ import { MatCardModule } from '@angular/material/card'; import { StatusPipe } from '../../shared/pipes/status.pipe'; import { QueryParamPaginatorComponent } from '../../shared/ui/query-param-paginator/query-param-paginator.component'; import { Router } from '@angular/router'; +import { + OrganizationPageWithInstitutions, + OrganizationWithInstitutions, +} from '../../resolvers/organizations-organizations.resolver'; +import { CredentialService } from '../../shared/services/credential.service'; @Component({ selector: 'app-organizations', @@ -52,10 +53,10 @@ export class OrganizationsComponent implements OnInit { private readonly dialog = inject(MatDialog); private readonly snackBar = inject(MatSnackBar); private readonly organizationService = inject(OrganizationService); + private readonly credentialService = inject(CredentialService); - organizationPage = input.required(); - organizationColumns: GenericColumn[] = - []; + organizationPage = input.required(); + organizationColumns: GenericColumn[] = []; organizationStatusTmp = viewChild.required>( 'organizationStatusTmp', @@ -63,6 +64,9 @@ export class OrganizationsComponent implements OnInit { organizationActionsTmp = viewChild.required>( 'organizationActionsTmp', ); + organizationInstitutionsTmp = viewChild.required>( + 'organizationInstitutionsTmp', + ); ngOnInit(): void { this.organizationColumns = [ @@ -73,10 +77,10 @@ export class OrganizationsComponent implements OnInit { accessorKey: 'name', }, { - id: 'other_inst_id', - header: 'Externe ID', - type: 'accessor', - accessorKey: 'other_inst_id', + id: 'institutions', + header: 'OpenAlex-Institutionen', + type: 'display', + cellTemplate: this.organizationInstitutionsTmp(), }, { id: 'member_count', @@ -104,16 +108,26 @@ export class OrganizationsComponent implements OnInit { this.openDialog({ mode: 'create' }); } - protected startEdit( - organization: InseOrganizationManagementModelOrganizationProfile, - ): void { - this.openDialog({ mode: 'edit', organization }); + protected startEdit(organization: OrganizationWithInstitutions): void { + this.openDialog({ + mode: 'edit', + organization, + isCurrentOrganization: this.isCurrentOrganization(organization), + }); + } + + protected isCurrentOrganization( + organization: OrganizationWithInstitutions, + ): boolean { + return organization.id === this.credentialService.effectiveOrganizationId(); } protected deleteOrganization( - organization: InseOrganizationManagementModelOrganizationProfile, + organization: OrganizationWithInstitutions, ): void { - if (organization.deleted) return; + if (organization.deleted || this.isCurrentOrganization(organization)) { + return; + } import('../../shared/ui/confirmation-dialog/confirmation-dialog.component').then( ({ ConfirmationDialogComponent }) => { @@ -134,7 +148,7 @@ export class OrganizationsComponent implements OnInit { } private softDeleteOrganization( - organization: InseOrganizationManagementModelOrganizationProfile, + organization: OrganizationWithInstitutions, ): void { this.organizationService.deleteOrganisation(organization.id).subscribe({ next: () => { @@ -146,8 +160,12 @@ export class OrganizationsComponent implements OnInit { queryParamsHandling: 'merge', }); }, - error: () => - this.showError('Organisation konnte nicht deaktiviert werden.'), + error: (error) => + this.showError( + this.isProtectedOrganizationError(error) + ? 'Die eigene Organisation kann nicht deaktiviert werden.' + : 'Organisation konnte nicht deaktiviert werden.', + ), }); } @@ -159,7 +177,7 @@ export class OrganizationsComponent implements OnInit { OrganizationDialogData, OrganizationDialogResult | undefined >(OrganizationDialogComponent, { - width: '620px', + width: '780px', maxWidth: 'calc(100vw - 32px)', data, }); @@ -192,13 +210,24 @@ export class OrganizationsComponent implements OnInit { }, error: (error) => this.showError( - error.status === 409 - ? 'Eine Organisation mit diesem Namen existiert bereits.' - : 'Organisation konnte nicht gespeichert werden.', + this.isProtectedOrganizationError(error) + ? 'Die eigene Organisation kann nicht deaktiviert werden.' + : error.status === 409 + ? 'Eine Organisation mit diesem Namen existiert bereits.' + : 'Organisation konnte nicht gespeichert werden.', ), }); } + private isProtectedOrganizationError(error: { + error?: { detail?: string }; + }): boolean { + return ( + error.error?.detail === + 'The organization of the real or effective account cannot be deleted.' + ); + } + private showError(message: string): void { this.snackBar.open(message, 'OK', { duration: 5000 }); } diff --git a/webapp/src/app/modules/patent-detail/patent-detail.component.html b/webapp/src/app/modules/patent-detail/patent-detail.component.html index 3ab15299..f05d50b4 100644 --- a/webapp/src/app/modules/patent-detail/patent-detail.component.html +++ b/webapp/src/app/modules/patent-detail/patent-detail.component.html @@ -138,6 +138,7 @@ track topic.topic_id ?? topic.topic_display_name ) { -
- - EPO - USPTO - +
+ + + EPO + USPTO + + +
diff --git a/webapp/src/app/modules/person-overview/person-overview.component.scss b/webapp/src/app/modules/person-overview/person-overview.component.scss index 02d0ba58..740a7e09 100644 --- a/webapp/src/app/modules/person-overview/person-overview.component.scss +++ b/webapp/src/app/modules/person-overview/person-overview.component.scss @@ -3,54 +3,3 @@ display: block; box-sizing: border-box; } - -.word-cloud-view { - min-height: 420px; -} - -.word-cloud-chart { - width: 100%; - min-height: 420px; - display: flex; - flex-wrap: wrap; - align-content: center; - align-items: baseline; - justify-content: center; - gap: 0.35em 1em; - padding: 1.5rem 1rem; - box-sizing: border-box; -} - -.word-cloud-word { - appearance: none; - border: none; - background: none; - padding: 0; - margin: 0; - font-family: 'Open Sans', Arial, sans-serif; - line-height: 1.1; - cursor: pointer; - transition: transform 0.15s ease; - - &:hover:not(:disabled), - &:focus-visible { - transform: scale(1.08); - outline: none; - } - - &:disabled { - cursor: default; - } -} - -.word-cloud-state, -.word-cloud-empty { - margin: 0; - min-height: 420px; - display: flex; - align-items: center; - justify-content: center; - color: var(--sg-text-muted); - font-size: 14px; - text-align: center; -} diff --git a/webapp/src/app/modules/person-overview/person-overview.component.ts b/webapp/src/app/modules/person-overview/person-overview.component.ts index ff8821fd..1aeb032c 100644 --- a/webapp/src/app/modules/person-overview/person-overview.component.ts +++ b/webapp/src/app/modules/person-overview/person-overview.component.ts @@ -1,9 +1,7 @@ -import { CommonModule } from '@angular/common'; import { Component, DestroyRef, OnInit, inject } from '@angular/core'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { ActivatedRoute, ParamMap, Router } from '@angular/router'; -import { MatTooltipModule } from '@angular/material/tooltip'; -import { combineLatest, distinctUntilChanged, map } from 'rxjs'; +import { combineLatest, distinctUntilChanged, map, of, switchMap } from 'rxjs'; import { TopicCount, TopicsByYear, WorksService } from '../../api'; import { @@ -14,27 +12,23 @@ import { TopicTimelineElement, TopicTimelineTopic, } from './components/research-timeline/research-timeline.component'; +import { + buildResearchWordcloud, + ResearchWordcloudComponent, + WordCloudTopicOccurrence, + WordCloudWord, +} from './components/research-wordcloud/research-wordcloud.component'; import { workQueryParamKeys } from '../../resolvers/work-page.resolver'; -import { TopicLegendTopic } from '../../resolvers/utils/topic-legend'; -import { topicHierarchyColor } from '../../resolvers/utils/topic-colors'; -import { buildTopicHierarchyTooltip } from '../../resolvers/utils/topic-tooltip'; - -export interface WordCloudWord { - name: string; - value: number; - topicId: string | undefined; - fieldName: string | undefined; - domainName: string | undefined; - color: string; - fontSize: number; - fontWeight: number; - tooltip: string; -} +import { + TopicLegendSelectionState, + TopicLegendTopic, +} from '../../resolvers/utils/topic-legend'; +import { PersonDataResolved } from '../../resolvers/person.resolver'; @Component({ selector: 'app-person-overview', standalone: true, - imports: [CommonModule, ResearchTimelineComponent, MatTooltipModule], + imports: [ResearchTimelineComponent, ResearchWordcloudComponent], templateUrl: './person-overview.component.html', styleUrl: './person-overview.component.scss', }) @@ -73,19 +67,13 @@ export class PersonOverviewComponent implements OnInit { wordCloudWords: WordCloudWord[] = []; wordCloudLegendTopics: TopicLegendTopic[] = []; loadingWordCloud = false; - wordCloudEmpty = false; + wordCloudLoadFailed = false; + activeLegendFieldIds: ReadonlySet = new Set(); + activeLegendSubfieldIds: ReadonlySet = new Set(); + personName = ''; + personPublicationsLink: unknown[] | null = null; - private rawTopicOccurrences: Array<{ - name: string; - topicId: string; - year: number | undefined; - fieldId: string | undefined; - fieldName: string | undefined; - domainId: string | undefined; - domainName: string | undefined; - subfieldId: string | undefined; - subfieldName: string | undefined; - }> = []; + private rawTopicOccurrences: WordCloudTopicOccurrence[] = []; ngOnInit(): void { combineLatest(this.route.pathFromRoot.map((route) => route.paramMap)) @@ -95,10 +83,16 @@ export class PersonOverviewComponent implements OnInit { takeUntilDestroyed(this.destroyRef), ) .subscribe((authorId) => { + this.personPublicationsLink = + authorId && authorId !== '0' + ? ['/person', authorId, 'publications'] + : null; this.loadTopicTimeline(authorId); this.loadWordCloud(authorId); }); + this.loadPersonName(); + this.route.queryParamMap .pipe(takeUntilDestroyed(this.destroyRef)) .subscribe((queryParams) => { @@ -230,6 +224,11 @@ export class PersonOverviewComponent implements OnInit { }); } + onLegendSelectionChange(selection: TopicLegendSelectionState): void { + this.activeLegendFieldIds = selection.fieldIds; + this.activeLegendSubfieldIds = selection.subfieldIds; + } + private findAuthorId(paramMaps: readonly ParamMap[]): string { return ( paramMaps @@ -347,18 +346,37 @@ export class PersonOverviewComponent implements OnInit { this.timelineEarlierYearsLoadFailed = false; } + private loadPersonName(): void { + combineLatest(this.route.pathFromRoot.map((route) => route.data)) + .pipe( + map((dataEntries) => + dataEntries + .map((data) => data['personData'] as PersonDataResolved | undefined) + .find((resolved): resolved is PersonDataResolved => + Boolean(resolved), + ), + ), + distinctUntilChanged(), + switchMap((resolved) => resolved?.personData$ ?? of(null)), + takeUntilDestroyed(this.destroyRef), + ) + .subscribe((response) => { + this.personName = response?.results?.[0]?.display_name ?? ''; + }); + } + private loadWordCloud(authorId: string): void { if (!authorId || authorId === '0') { this.wordCloudWords = []; this.wordCloudLegendTopics = []; - this.wordCloudEmpty = false; + this.wordCloudLoadFailed = false; this.loadingWordCloud = false; this.rawTopicOccurrences = []; return; } this.loadingWordCloud = true; - this.wordCloudEmpty = false; + this.wordCloudLoadFailed = false; this.wordCloudWords = []; this.wordCloudLegendTopics = []; @@ -389,104 +407,27 @@ export class PersonOverviewComponent implements OnInit { this.loadingWordCloud = false; - if (this.rawTopicOccurrences.length === 0) { - this.wordCloudLegendTopics = []; - this.wordCloudEmpty = true; - return; - } - setTimeout(() => this.rebuildWordCloud()); }, error: (error) => { console.error('Word cloud could not be loaded.', error); this.loadingWordCloud = false; + this.rawTopicOccurrences = []; this.wordCloudLegendTopics = []; - this.wordCloudEmpty = true; + this.wordCloudLoadFailed = true; }, }); } private rebuildWordCloud(): void { - const start = this.timelineStartYear; - const end = this.timelineEndYear; - const counts = new Map(); - const nameToId = new Map(); - const nameToColorInput = new Map(); + const wordCloud = buildResearchWordcloud( + this.rawTopicOccurrences, + this.timelineStartYear, + this.timelineEndYear, + ); - for (const occ of this.rawTopicOccurrences) { - if (start !== undefined && (occ.year === undefined || occ.year < start)) - continue; - if (end !== undefined && (occ.year === undefined || occ.year > end)) - continue; - counts.set(occ.name, (counts.get(occ.name) ?? 0) + 1); - if (!nameToId.has(occ.name)) { - nameToId.set(occ.name, occ.topicId); - nameToColorInput.set(occ.name, { - id: occ.topicId, - name: occ.name, - field_id: occ.fieldId, - field_name: occ.fieldName, - domain_id: occ.domainId, - domain_name: occ.domainName, - subfield_id: occ.subfieldId, - subfield_name: occ.subfieldName, - }); - } - } - - if (counts.size === 0) { - this.wordCloudWords = []; - this.wordCloudLegendTopics = []; - this.wordCloudEmpty = true; - return; - } - - this.wordCloudEmpty = false; - - const allValues = Array.from(counts.values()); - const minVal = Math.min(...allValues); - const maxVal = Math.max(...allValues); - const intensity = (v: number): number => - maxVal === minVal ? 1 : (v - minVal) / (maxVal - minVal); - - const sorted = Array.from(counts.entries()).sort((a, b) => b[1] - a[1]); - const topNames = sorted.slice(0, 30).map(([name]) => name); - - this.wordCloudLegendTopics = topNames - .map((name) => nameToColorInput.get(name)) - .filter((topic): topic is TopicLegendTopic => Boolean(topic)); - - const words = sorted.slice(0, 30).map(([name, value]): WordCloudWord => { - const t = intensity(value); - const colorInput = nameToColorInput.get(name); - return { - name, - value, - topicId: nameToId.get(name), - fieldName: colorInput?.field_name ?? undefined, - domainName: colorInput?.domain_name ?? undefined, - color: topicHierarchyColor(colorInput), - fontSize: Math.round(12 + t * (32 - 12)), - fontWeight: t > 0.66 ? 800 : t > 0.33 ? 600 : 400, - tooltip: buildTopicHierarchyTooltip({ - topicName: name, - subfieldName: colorInput?.subfield_name, - fieldName: colorInput?.field_name, - domainName: colorInput?.domain_name, - }), - }; - }); - - const centred: WordCloudWord[] = []; - words.forEach((word, i) => { - if (i % 2 === 0) { - centred.push(word); - } else { - centred.unshift(word); - } - }); - - this.wordCloudWords = centred; + this.wordCloudWords = wordCloud.words; + this.wordCloudLegendTopics = wordCloud.legendTopics; } private mapTimelineElements( diff --git a/webapp/src/app/modules/person-projects/person-projects.component.html b/webapp/src/app/modules/person-projects/person-projects.component.html index 958f8daa..16b344e7 100644 --- a/webapp/src/app/modules/person-projects/person-projects.component.html +++ b/webapp/src/app/modules/person-projects/person-projects.component.html @@ -1,22 +1,7 @@
- + @if (resultTabPanel) { + + } diff --git a/webapp/src/app/modules/person-projects/person-projects.component.ts b/webapp/src/app/modules/person-projects/person-projects.component.ts index 359a9d9c..519b28af 100644 --- a/webapp/src/app/modules/person-projects/person-projects.component.ts +++ b/webapp/src/app/modules/person-projects/person-projects.component.ts @@ -1,31 +1,33 @@ -import { Component } from '@angular/core'; +import { Component, computed } from '@angular/core'; import { RouterLink, RouterLinkActive, RouterOutlet } from '@angular/router'; import { MatCardModule } from '@angular/material/card'; import { MatTabsModule } from '@angular/material/tabs'; - +import { + LinkTabNavBarComponent, + LinkTabNavBarItem, +} from '../../shared/ui/link-tab-nav-bar/link-tab-nav-bar.component'; @Component({ selector: 'app-person-projects', standalone: true, - imports: [ - MatCardModule, - MatTabsModule, - RouterOutlet, - RouterLink, - RouterLinkActive, - ], + imports: [MatCardModule, MatTabsModule, RouterOutlet, LinkTabNavBarComponent], templateUrl: './person-projects.component.html', styleUrl: './person-projects.component.scss', }) export class PersonProjectsComponent { - readonly childRoutes = [ - { - path: 'dfg', - label: 'DFG-Projekte', - }, - { - path: 'eu', - label: 'EU-Projekte', - }, - ]; + _links = computed(() => { + const links: LinkTabNavBarItem[] = [ + { + label: 'DFG-Projekte', + path: 'dfg', + disabled: false, + }, + { + label: 'EU-Projekte', + path: 'eu', + disabled: false, + }, + ]; + return links; + }); } diff --git a/webapp/src/app/modules/person/person.component.html b/webapp/src/app/modules/person/person.component.html index 362af283..40abbf6b 100644 --- a/webapp/src/app/modules/person/person.component.html +++ b/webapp/src/app/modules/person/person.component.html @@ -130,22 +130,16 @@ - + @if (this.links()) { + + } } @else { ; - disabled: boolean; -}; +import { + LinkTabNavBarComponent, + LinkTabNavBarItem, +} from '../../shared/ui/link-tab-nav-bar/link-tab-nav-bar.component'; +import { + COMPANY_CONNECTION_ICON, + FUNDING_ICON, + NETWORK_ICON, + NEWS_ICON, + OVERVIEW_ICON, + PATENT_ICON, + PROJECT_ICON, + PUBLICATION_ICON, +} from '../../shared/ui/icons'; @Component({ selector: 'app-person', @@ -48,6 +72,7 @@ type PersonLink = { LoadingComponent, CountryFlagComponent, CareerStageChipComponent, + LinkTabNavBarComponent, ], templateUrl: './person.component.html', styleUrl: './person.component.scss', @@ -60,11 +85,35 @@ export class PersonComponent { private readonly destroyRef = inject(DestroyRef); readonly bookmarkService = inject(BookmarkService); + canFetchGdprRelevantData = input.required(); + + protected readonly navBar = viewChild('navBar'); + protected readonly activeLink = computed( + () => this.navBar()?.activeLink() ?? null, + ); + + private readonly tabPanelElement = viewChild('tabPanel', { + read: ElementRef, + }); + + private publicationFilterKey: string | null = null; + constructor() { this.bookmarkService .load() .pipe(takeUntilDestroyed(this.destroyRef)) .subscribe(); + + this.router.events + .pipe( + filter( + (event): event is NavigationEnd => event instanceof NavigationEnd, + ), + takeUntilDestroyed(this.destroyRef), + ) + .subscribe((event) => + this.scrollToPanelOnFilterChange(event.urlAfterRedirects), + ); } readonly params = toSignal(this.activatedRoute.paramMap); @@ -147,6 +196,13 @@ export class PersonComponent { readonly displayName = computed( () => this.person()?.display_name ?? 'Unbekannte Person', ); + + readonly personName = computed(() => this.person()?.display_name ?? ''); + + readonly personPublicationsLink = computed(() => { + const authorId = this.authorId(); + return authorId ? ['/person', authorId, 'publications'] : null; + }); readonly initials = computed(() => this.buildInitials(this.displayName())); readonly primaryAffiliation = computed( () => this.person()?.affiliations?.[0] ?? null, @@ -227,94 +283,108 @@ export class PersonComponent { { initialValue: [] }, ); - readonly links = computed(() => [ - { - label: 'Übersicht', - description: 'Übersicht über die Person', - path: 'overview', - disabled: false, - }, - { - label: 'Projekte', - description: 'Übersicht der durchgeführten Projekte der Person', - path: 'projects', - queryParams: { - page: 0, - size: 10, - sort_by: 'title', - sort_direction: 'asc', - search: '', + readonly links = computed(() => { + const links = [ + { + label: 'Übersicht', + description: 'Übersicht über die Person', + icon: OVERVIEW_ICON, + path: 'overview', + disabled: false, }, - disabled: false, - }, - { - label: 'Publikationen', - description: 'Übersicht der Publikationen der Person', - path: 'publications', - disabled: false, - }, - { - label: 'Netzwerk', - description: 'Kooperationsnetzwerk der Person', - path: 'network', - disabled: false, - queryParams: { - [collaborationGraphQueryParamKeys.minCollaborators]: '2', - [collaborationGraphQueryParamKeys.maxCollaborators]: '10', - [collaborationGraphQueryParamKeys.yearFrom]: '1900', - [collaborationGraphQueryParamKeys.yearTo]: new Date().getFullYear(), + ...(this.canFetchGdprRelevantData() + ? [ + { + label: 'Projekte', + description: 'Übersicht der durchgeführten Projekte der Person', + icon: PROJECT_ICON, + path: 'projects', + queryParams: { + page: 0, + size: 10, + sort_by: 'title', + sort_direction: 'asc', + search: '', + }, + disabled: false, + }, + ] + : []), + { + label: 'Publikationen', + description: 'Übersicht der Publikationen der Person', + icon: PUBLICATION_ICON, + path: 'publications', }, - }, - ...(this.companyConnectionsAvailable() - ? [ - { - label: 'Unternehmen', - description: 'Unternehmen, mit denen die Person verbunden ist', - path: 'company-connections', - disabled: false, - }, - ] - : []), - { - label: 'Förderungen', - description: 'Übersicht der Förderungen der Person', - path: 'funding', - disabled: false, - }, - { - label: 'Nachrichten', - description: 'Nachrichten über die Person', - path: 'news', - disabled: false, - }, - { - label: 'Patente', - description: 'Patente der Person', - path: 'patents', - disabled: false, - }, - ]); - - readonly activeLink = computed(() => { - const currentUrl = this.currentUrl(); - if (!currentUrl) { - return null; - } - - for (const link of this.links()) { - const linkUrl = this.router - .createUrlTree([link.path], { - relativeTo: this.activatedRoute, - }) - .toString(); - - if (linkUrl.startsWith(currentUrl) || currentUrl.startsWith(linkUrl)) { - return link; - } - } - return null; + { + label: 'Netzwerk', + description: 'Kooperationsnetzwerk der Person', + icon: NETWORK_ICON, + path: 'network', + disabled: false, + queryParams: { + [collaborationGraphQueryParamKeys.minCollaborators]: '2', + [collaborationGraphQueryParamKeys.maxCollaborators]: '10', + [collaborationGraphQueryParamKeys.yearFrom]: '1900', + [collaborationGraphQueryParamKeys.yearTo]: new Date().getFullYear(), + }, + }, + ...(this.companyConnectionsAvailable() + ? [ + { + label: 'Unternehmen', + description: 'Unternehmen, mit denen die Person verbunden ist', + icon: COMPANY_CONNECTION_ICON, + path: 'company-connections', + disabled: false, + }, + ] + : []), + { + label: 'Förderungen', + description: 'Übersicht der Förderungen der Person', + icon: FUNDING_ICON, + path: 'funding', + disabled: false, + }, + { + label: 'Nachrichten', + description: 'Nachrichten über die Person', + icon: NEWS_ICON, + path: 'news', + disabled: false, + }, + { + label: 'Patente', + description: 'Patente der Person', + icon: PATENT_ICON, + path: 'patents', + disabled: false, + }, + ]; + return links; }); + // readonly activeLink = computed(() => { + // const currentUrl = this.currentUrl(); + // if (!currentUrl) { + // return null; + // } + + // for (const link of this.links()) { + // const linkUrl = this.router + // .createUrlTree([link.path], { + // relativeTo: this.activatedRoute, + // }) + // .toString(); + + // if (linkUrl.startsWith(currentUrl) || currentUrl.startsWith(linkUrl)) { + // return link; + // } + // } + // return null; + // }); + onInterestingTagClick(selection: { id: string; name: string; @@ -332,6 +402,46 @@ export class PersonComponent { }); } + private scrollToPanelOnFilterChange(url: string): void { + const { queryParams } = this.router.parseUrl(url); + const filterKey = [workQueryParamKeys.topicId, workQueryParamKeys.years] + .map((key) => { + const value = queryParams[key]; + return Array.isArray(value) ? value.join(',') : (value ?? ''); + }) + .join('|'); + + const previousFilterKey = this.publicationFilterKey; + this.publicationFilterKey = filterKey; + + const hasFilter = filterKey !== '|'; + const isFirstNavigation = previousFilterKey === null; + + if (isFirstNavigation || !hasFilter || filterKey === previousFilterKey) { + return; + } + + this.scrollPanelIntoView(); + } + + private scrollPanelIntoView(): void { + const scrollToPanel = (): void => { + this.tabPanelElement()?.nativeElement.scrollIntoView({ + behavior: 'smooth', + block: 'start', + }); + }; + + requestAnimationFrame(scrollToPanel); + + setTimeout(() => { + const panel = this.tabPanelElement(); + if (panel && panel.nativeElement.getBoundingClientRect().top > 8) { + scrollToPanel(); + } + }, 400); + } + private getId(key: string): string | null { const ids = this.person()?.ids as Record | undefined; if (!ids) { diff --git a/webapp/src/app/modules/projects/dfg-details/dfg-details.component.html b/webapp/src/app/modules/projects/dfg-details/dfg-details.component.html index c9b6c1e9..19c3c6cc 100644 --- a/webapp/src/app/modules/projects/dfg-details/dfg-details.component.html +++ b/webapp/src/app/modules/projects/dfg-details/dfg-details.component.html @@ -37,8 +37,11 @@ circle {{ getStatusDisplay(dfgProject.funding_end) }}
- @if (dfgProject.link) { - + @if (dfgProject.page_url) { + open_in_new Zum Projekt @@ -135,41 +138,10 @@ } @if (getSubjectClassifications().length > 0) { - -
- category -

Fachsystematik

- {{ - getSubjectClassifications().length - }} -
-
- @for (entry of getSubjectClassifications(); track $index) { -
- @for ( - segment of getClassificationParentSegments(entry); - track $index - ) { - {{ segment }} - chevron_right - } -
- @for ( - leaf of getClassificationLeafSegments(entry); - track $index - ) { - - {{ leaf }} - - } -
-
- } -
-
+ } @@ -218,10 +190,7 @@