diff --git a/webapp/src/app/shared/ui/bund-project-table/bund-project-table.component.html b/webapp/src/app/shared/ui/bund-project-table/bund-project-table.component.html new file mode 100644 index 00000000..83c8e2cf --- /dev/null +++ b/webapp/src/app/shared/ui/bund-project-table/bund-project-table.component.html @@ -0,0 +1,158 @@ + + + + + + {{ + element.funding_end == '2999' || element.funding_end == null + ? 'laufend' + : element.funding_end + }} + + + + + open_in_new + + + +
+ @for (classification of element.subject_classifications; track $index) { +

+ {{ classification.wissenschaftsbereich || '-' }} + → {{ classification.fachkollegium || '-' }} → + {{ classification.fachgebiet || '-' }} → + {{ classification.fach || '-' }} +

+ } @empty { + - + } +
+
+ + + + + + + + @let institutions = getProjectInstitutions(project); + +
+ @for ( + institution of isProjectInstitutionsExpanded(project) + ? institutions + : institutions.slice(0, 3); + track getProjectInstitutionId(institution) + ) { + + } @empty { + - + } + @if (institutions.length > 3) { + + } +
+
+ + + @let projectTopics = project.topics ?? []; + @let isTopicsExpanded = isProjectTopicsExpanded(project); + @let visibleTopics = + isTopicsExpanded ? projectTopics : projectTopics.slice(0, 3); +
+ @for (topic of visibleTopics; track $index) { + + + } @empty { + - + } + @if (projectTopics.length > 3) { + + } +
+
diff --git a/webapp/src/app/shared/ui/bund-project-table/bund-project-table.component.scss b/webapp/src/app/shared/ui/bund-project-table/bund-project-table.component.scss new file mode 100644 index 00000000..3fd1bb17 --- /dev/null +++ b/webapp/src/app/shared/ui/bund-project-table/bund-project-table.component.scss @@ -0,0 +1,220 @@ +.page { + padding: 28px 32px 42px; + max-width: 100%; + margin: 0 auto; +} + +// ------------------------ +// Shared tags & chips +// ------------------------ + +.publication-institution-tag { + display: inline-flex; + align-items: center; + padding: 2px 6px; + border: 1px solid var(--sg-primary-border, var(--sg-border)); + border-radius: 4px; + background: var(--sg-primary-soft); + color: var(--sg-primary); + font-size: 10px; + font-weight: 600; + line-height: normal; + max-width: 100%; + margin: 0; + font-family: inherit; + cursor: pointer; + transition: all 0.2s ease; + + &:hover, + &:focus-visible { + background: var(--sg-primary); + color: #fff; + border-color: var(--sg-primary); + outline: none; + box-shadow: + 0 0 0 2px var(--sg-background), + 0 0 0 4px var(--sg-primary); + } + + &.active { + border-color: var(--sg-primary); + box-shadow: + 0 0 0 1px #ffffff, + 0 0 0 3px var(--sg-primary); + } + + &.active:hover, + &.active:focus-visible { + background: var(--sg-primary); + color: #fff; + } + + .institution-icon { + flex-shrink: 0; + width: 12px; + height: 12px; + margin-right: 4px; + font-size: 12px; + } + + .institution-name { + display: -webkit-box; + -webkit-line-clamp: 2; + -webkit-box-orient: vertical; + overflow: hidden; + min-width: 0; + white-space: normal; + overflow-wrap: anywhere; + } + + .flag-img { + flex-shrink: 0; + margin-left: 6px; + border: 1px solid; + } + + .country-code { + flex-shrink: 0; + margin-left: 2px; + font-size: 9px; + } + + .institution-open-icon { + flex-shrink: 0; + width: 12px; + height: 12px; + margin-left: 5px; + font-size: 12px; + line-height: 1; + cursor: pointer; + opacity: 0; + transition: opacity 0.15s ease; + } + + &:hover .institution-open-icon { + opacity: 0.7; + } + + .institution-open-icon:hover { + opacity: 1; + } +} + +.publication-institution-more { + display: inline-flex; + align-items: center; + min-height: 24px; + padding: 3px 8px; + border: 1px solid var(--sg-border); + border-radius: var(--sg-radius-sm); + background: #fff; + color: var(--sg-text-muted); + font-family: inherit; + font-size: 11px; + line-height: 1.2; + cursor: pointer; + transition: all 0.2s ease; + + &:hover, + &:focus-visible { + border-color: var(--sg-primary); + color: var(--sg-primary); + background: var(--sg-surface-soft); + outline: none; + } +} + +// ------------------------ +// Containers for chips +// ------------------------ + +.topic-chips, +.institution-tags, +.author-tags { + display: flex; + flex-wrap: wrap; + gap: 6px; +} + +.topic-chips { + max-width: 320px; +} + +.institution-tags { + align-items: flex-start; + max-width: 280px; +} + +.author-tags { + align-items: flex-start; + max-width: 280px; + padding: 0.5rem 0; +} + +// ------------------------ +// Empty text +// ------------------------ + +.empty-text { + color: rgba(0, 0, 0, 0.54); +} + +// ------------------------ +// Classification container +// ------------------------ + +.classification-container { + max-width: 200px; +} + +// ------------------------ +// Data table overrides (applied via ::ng-deep) +// ------------------------ + +::ng-deep { + .mat-mdc-header-cell { + color: var(--sg-text-muted); + font-size: 12px; + font-weight: 700; + } + + .mat-mdc-row { + height: 86px; + } + + .mat-mdc-cell { + color: var(--sg-text); + border-bottom-color: var(--sg-border); + font-size: 13px; + } + + .table-wrap { + .mat-column-type, + .mat-column-year, + .mat-column-language, + .mat-column-citations, + .mat-mdc-header-cell { + text-align: center; + } + + .mat-mdc-cell:not(:last-child), + .mat-mdc-header-cell:not(:last-child) { + border-right: 1px solid var(--sg-border); + } + + .mat-column-institutions, + .mat-column-topics { + overflow: visible; + } + } +} + +// ------------------------ +// Responsive adjustments +// ------------------------ + +@media (max-width: 600px) { + .page { + padding: 16px; + } +} diff --git a/webapp/src/app/shared/ui/bund-project-table/bund-project-table.component.ts b/webapp/src/app/shared/ui/bund-project-table/bund-project-table.component.ts new file mode 100644 index 00000000..b40d5649 --- /dev/null +++ b/webapp/src/app/shared/ui/bund-project-table/bund-project-table.component.ts @@ -0,0 +1,369 @@ +import { + Component, + computed, + input, + OnInit, + TemplateRef, + viewChild, + inject, +} from '@angular/core'; +import { + BundProjectPage, + DfgProjectPage, + DfgProjectSummary, + Topic, +} from '../../../api'; +import { BundProjectSummary } from '../../../api/model/bundProjectSummary'; +import { TopicChipComponent } from '../topic-chip/topic-chip.component'; +import { + DataTableComponent, + GenericColumn, +} from '../data-table/data-table.component'; +import { RouterModule } from '@angular/router'; +import { MatIconModule } from '@angular/material/icon'; +import { MatButtonModule } from '@angular/material/button'; +import { QueryParamPaginatorComponent } from '../query-param-paginator/query-param-paginator.component'; +import { dfgProjectQueryParamKeys } from '../../../resolvers/dfg-projects.resolver'; +import { toSignal } from '@angular/core/rxjs-interop'; +import { ActivatedRoute, Router } from '@angular/router'; +import { DfgPersonSummary } from '../../../api/model/dfgPersonSummary'; +import { MatTooltip } from '@angular/material/tooltip'; +import { topicHierarchyColor } from '../../../resolvers/utils/topic-colors'; +@Component({ + selector: 'app-bund-project-table', + imports: [ + DataTableComponent, + RouterModule, + MatIconModule, + MatButtonModule, + QueryParamPaginatorComponent, + MatTooltip, + TopicChipComponent, + ], + templateUrl: './bund-project-table.component.html', + styleUrl: './bund-project-table.component.scss', +}) +export class BundProjectTableComponent implements OnInit { + private readonly activatedRoute = inject(ActivatedRoute); + private readonly router = inject(Router); + + page = input.required(); + authorFilterEnabled = input(false); + institutionFilterEnabled = input(false); + topicFilterEnabled = input(false); + + elements = computed(() => this.page().elements ?? []); + + queryParamMap = toSignal(this.activatedRoute.queryParamMap, { + initialValue: this.activatedRoute.snapshot.queryParamMap, + }); + + queryParamKeys = dfgProjectQueryParamKeys; + total = computed(() => this.page().total ?? 0); + + columns: GenericColumn[] = []; + titleTmp = viewChild.required>('titleTmp'); + authorsTmp = viewChild.required>('authorsTmp'); + institutionsTmp = viewChild.required>('institutionsTmp'); + fundingStartTmp = viewChild.required>('fundingStartTmp'); + fundingEndTmp = viewChild.required>('fundingEndTmp'); + actionsTmp = viewChild.required>('actionsTmp'); + detailRowTmp = viewChild.required>('detailRowTmp'); + topicsTmp = viewChild.required>('topicsTmp'); + + expandedProjectAuthorsId: string[] = []; + expandedProjectInstitutionsId: string[] = []; + expandedProjectTopicsId: string[] = []; + + selectedFundingStartYearsQueryParams = computed(() => { + return this.queryParamMap() + .getAll(this.queryParamKeys.funding_start) + .map(Number); + }); + + selectedFundingEndYearsQueryParams = computed(() => { + return this.queryParamMap() + .getAll(this.queryParamKeys.funding_end) + .map(Number); + }); + + selectedAuthorIdsQueryParams = computed(() => { + return this.queryParamMap().getAll(this.queryParamKeys.authorId); + }); + + selectedInstitutionIdsQueryParams = computed(() => { + return this.queryParamMap().getAll(this.queryParamKeys.institutionId); + }); + + selectedTopicIdsQueryParams = computed(() => { + return this.queryParamMap().getAll(this.queryParamKeys.topicId); + }); + + ngOnInit(): void { + this.columns = [ + { id: 'title', header: 'Titel', type: 'accessor', accessorKey: 'topic' }, + { + id: 'funding_start', + header: 'Förderbeginn', + type: 'accessor', + accessorKey: 'funding_start', + }, + { + id: 'funding_end', + header: 'Förderende', + type: 'accessor', + accessorKey: 'funding_end', + cellTemplate: this.fundingEndTmp(), + }, + // { + // id: 'names', + // header: 'Autoren', + // type: 'accessor', + // accessorKey: 'names', + // cellTemplate: this.authorsTmp(), + // }, + { + id: 'institutions', + header: 'Institutionen', + type: 'display', + cellTemplate: this.institutionsTmp(), + }, + { + id: 'professional_classification', + header: 'Fachliche Zuordnung', + type: 'display', + cellTemplate: this.detailRowTmp(), + }, + + { + id: 'topics', + header: 'Themen', + type: 'display', + cellTemplate: this.topicsTmp(), + }, + { + id: 'actions', + header: '', + type: 'display', + cellTemplate: this.actionsTmp(), + }, + ]; + } + + sortNames(names: string[] | undefined): string[] { + return [...(names ?? [])].sort((a, b) => a.localeCompare(b)); + } + isAuthorActive(authorId: number): boolean { + return ( + !!authorId && + this.authorFilterEnabled() && + this.selectedAuthorIdsQueryParams().includes(String(authorId)) + ); + } + // getProjectAuthors(project: DfgProjectSummary): DfgPersonSummary[] { + // return project.persons?.filter((a): a is DfgPersonSummary => !!a) || []; + // } + + // toggleProjectAuthorsExpansion(project: DfgProjectSummary): void { + // if (!project.id) return; + + // if (this.expandedProjectAuthorsId.includes(project.id)) { + // this.expandedProjectAuthorsId = this.expandedProjectAuthorsId.filter( + // (id) => id !== project.id, + // ); + // } else { + // this.expandedProjectAuthorsId.push(project.id); + // } + // } + isProjectPersonsExpanded(project: DfgProjectSummary): boolean { + if (!project.id) return false; + + return this.expandedProjectAuthorsId.includes(project.id); + } + // getAuthorTooltipText(author: DfgPersonSummary): string { + // if (this.authorFilterEnabled() && author.person_id) { + // return `Nach Autor filtern: ${author.full_name}`; + // } + // return `Autor: ${author.full_name}`; + // } + // filterByAuthor(authorId: number): void { + // if (!authorId || !this.authorFilterEnabled()) return; + // const selectedAuthorIds = this.selectedAuthorIdsQueryParams(); + // if (selectedAuthorIds.includes(String(authorId))) { + // this.router.navigate([], { + // queryParams: { + // [this.queryParamKeys.authorId]: selectedAuthorIds.filter( + // (id) => id !== String(authorId), + // ), + // [this.queryParamKeys.page]: 0, + // }, + // queryParamsHandling: 'merge', + // }); + // } else { + // this.router.navigate([], { + // queryParams: { + // [this.queryParamKeys.authorId]: [ + // ...selectedAuthorIds, + // String(authorId), + // ], + // [this.queryParamKeys.page]: 0, + // }, + // queryParamsHandling: 'merge', + // }); + // } + // } + + isProjectInstitutionsExpanded(project: DfgProjectSummary): boolean { + if (!project.id) return false; + + return this.expandedProjectInstitutionsId.includes(project.id); + } + + toggleProjectInstitutionsExpansion(project: DfgProjectSummary): void { + if (!project.id) return; + + if (this.expandedProjectInstitutionsId.includes(project.id)) { + this.expandedProjectInstitutionsId = + this.expandedProjectInstitutionsId.filter((id) => id !== project.id); + } else { + this.expandedProjectInstitutionsId.push(project.id); + } + } + + getProjectInstitutions(project: DfgProjectSummary): any[] { + const institutions = new Map(); + + for (const institution of project.institutions ?? []) { + const id = this.getProjectInstitutionId(institution); + if (!id) continue; + + institutions.set(id, institution); + } + + return Array.from(institutions.values()).sort((a, b) => + this.getProjectInstitutionName(a).localeCompare( + this.getProjectInstitutionName(b), + ), + ); + } + + getProjectInstitutionId(institution: any): string | null { + const id = institution.id; + + return id == null ? null : String(id); + } + + getProjectInstitutionName(institution: any): string { + return institution.institute_name_de ?? institution.institute_name_en; + } + + isInstitutionActive( + institutionId: string | number | null | undefined, + ): boolean { + return ( + !!institutionId && + this.institutionFilterEnabled() && + this.selectedInstitutionIdsQueryParams().includes(String(institutionId)) + ); + } + + filterByInstitution(institution: any): void { + const institutionId = this.getProjectInstitutionId(institution); + + if (!institutionId || !this.institutionFilterEnabled()) return; + + const selectedInstitutionIds = this.selectedInstitutionIdsQueryParams(); + + if (selectedInstitutionIds.includes(institutionId)) { + this.router.navigate([], { + queryParams: { + [this.queryParamKeys.institutionId]: selectedInstitutionIds.filter( + (id) => id !== institutionId, + ), + [this.queryParamKeys.page]: 0, + }, + queryParamsHandling: 'merge', + }); + } else { + this.router.navigate([], { + queryParams: { + [this.queryParamKeys.institutionId]: [ + ...selectedInstitutionIds, + institutionId, + ], + [this.queryParamKeys.page]: 0, + }, + queryParamsHandling: 'merge', + }); + } + } + + getInstitutionTooltipText(institution: any): string { + const name = this.getProjectInstitutionName(institution); + + if (this.institutionFilterEnabled()) { + return `Nach Institution filtern: ${name}`; + } + + return `Institution: ${name}`; + } + + getWorkTopicColor(topic: Topic): string { + return topicHierarchyColor({ + id: topic.id, + name: topic.display_name, + field_id: topic.field?.id, + field_name: topic.field?.display_name, + domain_id: topic.domain?.id, + domain_name: topic.domain?.display_name, + }); + } + + isTopicActive(topic: Topic): boolean { + return ( + !!topic.id && + this.authorFilterEnabled() && + this.selectedTopicIdsQueryParams().includes(topic.id) + ); + } + + filterByTopic(topic: Topic): void { + if (!topic.id || !this.topicFilterEnabled()) return; + const selectedTopicIds = this.selectedTopicIdsQueryParams(); + if (selectedTopicIds.includes(topic.id)) { + this.router.navigate([], { + queryParams: { + [this.queryParamKeys.topicId]: selectedTopicIds.filter( + (id) => id !== topic.id, + ), + [this.queryParamKeys.page]: 0, + }, + queryParamsHandling: 'merge', + }); + } else { + this.router.navigate([], { + queryParams: { + [this.queryParamKeys.topicId]: [...selectedTopicIds, topic.id], + [this.queryParamKeys.page]: 0, + }, + queryParamsHandling: 'merge', + }); + } + } + toggleProjectTopicsExpansion(project: DfgProjectSummary): void { + if (!project.id) return; + + if (this.expandedProjectTopicsId.includes(project.id)) { + this.expandedProjectTopicsId = this.expandedProjectTopicsId.filter( + (id) => id !== project.id, + ); + } else { + this.expandedProjectTopicsId.push(project.id); + } + } + isProjectTopicsExpanded(project: DfgProjectSummary): boolean { + if (!project.id) return false; + + return this.expandedProjectTopicsId.includes(project.id); + } +} diff --git a/webapp/src/app/shared/ui/bund-projects/bund-projects.component.html b/webapp/src/app/shared/ui/bund-projects/bund-projects.component.html new file mode 100644 index 00000000..1d0cb5ac --- /dev/null +++ b/webapp/src/app/shared/ui/bund-projects/bund-projects.component.html @@ -0,0 +1,19 @@ +
+ + + +
diff --git a/webapp/src/app/shared/ui/bund-projects/bund-projects.component.scss b/webapp/src/app/shared/ui/bund-projects/bund-projects.component.scss new file mode 100644 index 00000000..e69de29b diff --git a/webapp/src/app/shared/ui/bund-projects/bund-projects.component.ts b/webapp/src/app/shared/ui/bund-projects/bund-projects.component.ts new file mode 100644 index 00000000..18baaa84 --- /dev/null +++ b/webapp/src/app/shared/ui/bund-projects/bund-projects.component.ts @@ -0,0 +1,53 @@ +import { Component, computed, input } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; +import { toSignal } from '@angular/core/rxjs-interop'; +import { + BundProjectPage, + DfgPersonSummaryPage, + TopicPageV2, +} from '../../../api'; +import { DfgInstitutionSummaryPage } from '../../../api/model/dfgInstitutionSummaryPage'; +import { MatCardModule } from '@angular/material/card'; +import { MatTabsModule } from '@angular/material/tabs'; +import { ProjectFilterComponent } from '../project-filters/project-filters.component'; +import { BundProjectTableComponent } from '../bund-project-table/bund-project-table.component'; +import { bundProjectQueryParamKeys } from '../../../resolvers/bund-projects.resolver'; +@Component({ + selector: 'app-bund-projects', + imports: [ + MatCardModule, + MatTabsModule, + ProjectFilterComponent, + BundProjectTableComponent, + ], + templateUrl: './bund-projects.component.html', + styleUrl: './bund-projects.component.scss', +}) +export class BundProjectsComponent { + bundProjectPage = input.required(); + + selectedBundInstitutionsPage = input.required(); + selectedBundAuthorsPage = input.required(); + + selectedTopicsPage = input.required(); + + readonly bundQueryParamKeys = bundProjectQueryParamKeys; + + constructor( + private readonly router: Router, + private readonly activatedRoute: ActivatedRoute, + ) { + console.log('BundProjectsComponent created'); + } + ngOnInit(): void { + console.log('BUND PROJECTS', this.bundProjectPage()); + } + queryParamMap = toSignal(this.activatedRoute.queryParamMap, { + initialValue: this.activatedRoute.snapshot.queryParamMap, + }); + readonly topicFilterEnabled = computed( + () => + this.queryParamMap().get('fuzzy') === 'true' || + this.queryParamMap().get('fuzzy') === null, + ); +}