diff --git a/webapp/src/app/shared/ui/dfg-project-table/dfg-project-table.component.html b/webapp/src/app/shared/ui/dfg-project-table/dfg-project-table.component.html index 790baa53..ec8f7600 100644 --- a/webapp/src/app/shared/ui/dfg-project-table/dfg-project-table.component.html +++ b/webapp/src/app/shared/ui/dfg-project-table/dfg-project-table.component.html @@ -1,6 +1,7 @@ @@ -9,7 +10,9 @@ queryParamPageKey="page" queryParamSizeKey="size" [pageSizeOptions]="[10, 25, 50]" /> - + + {{ element.title_de }} + {{ @@ -42,12 +45,11 @@ + matTooltipPosition="above"> category - {{ - getClassificationFullChain(classification) - }} + + {{ getClassificationFullChain(classification) }} } @empty { - @@ -60,7 +62,115 @@ } + +
+
+
+ + +
+
+ +
+ @if (getPanelLanguage(project) === 'de') { + @if (project.title_de) { +
+

Titel

+ +
+ } + @if (project.abstract_de) { +
+

Zusammenfassung

+ +
+ } + } @else { + @if (project.title_en) { +
+

Title

+ +
+ } + + @if (project.abstract_en) { +
+

Abstract

+ +
+ } + } + + @if (!hasAnyPanelContent(project)) { +
+ + Keine weiteren Angaben vorhanden. +
+ } + @if (getProjectClassifications(project).length > 0) { +
+

Fachsystematik

+ @for ( + classification of getProjectClassifications(project); + track $index + ) { + + } @empty { + - + } +
+ } +
+
+
@let projectAuthors = getProjectAuthors(project); @let isProjectAuthorsExpanded = isProjectPersonsExpanded(project); diff --git a/webapp/src/app/shared/ui/dfg-project-table/dfg-project-table.component.scss b/webapp/src/app/shared/ui/dfg-project-table/dfg-project-table.component.scss index 0698910b..53b53598 100644 --- a/webapp/src/app/shared/ui/dfg-project-table/dfg-project-table.component.scss +++ b/webapp/src/app/shared/ui/dfg-project-table/dfg-project-table.component.scss @@ -203,3 +203,249 @@ padding: 16px; } } +// ------------------------ +// Expanded project highlights +// ------------------------ + +.project-highlight-details { + width: 100%; + padding: 10px 14px 12px; + color: var(--sg-text); + background: var(--sg-background); + border-top: 1px solid var(--sg-border); +} + +.highlight-header { + margin-bottom: 8px; +} + +.highlight-header__title { + display: flex; + align-items: flex-start; + gap: 7px; + + > mat-icon { + flex: 0 0 auto; + width: 19px; + height: 19px; + color: var(--sg-primary); + font-size: 19px; + } + + h3 { + margin: 0; + font-size: 13px; + font-weight: 700; + line-height: 1.2; + } + + p { + margin: 1px 0 0; + color: var(--sg-text-muted); + font-size: 10px; + line-height: 1.3; + } +} + +.highlight-content-grid { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); + gap: 7px; +} + +.highlight-section { + min-width: 0; + border: 1px solid var(--sg-border); + border-radius: 5px; + overflow: hidden; +} + +.highlight-section__header, +.classification-highlight-section__header { + display: flex; + align-items: center; + justify-content: space-between; + gap: 7px; + min-height: 32px; + padding: 4px 7px; + background: var(--sg-primary-soft); + border-bottom: 1px solid var(--sg-border); +} + +.highlight-section__heading { + display: flex; + align-items: center; + min-width: 0; + gap: 5px; + + mat-icon { + flex: 0 0 auto; + width: 15px; + height: 15px; + color: var(--sg-primary); + font-size: 15px; + } + + h4 { + margin: 0; + font-size: 11px; + font-weight: 700; + } +} + +.language-toggle { + display: inline-flex; + flex: 0 0 auto; + padding: 1px; + border: 1px solid var(--sg-border); + border-radius: 4px; + background: var(--sg-background); +} + +.language-toggle__button { + min-width: 27px; + padding: 2px 5px; + border: 0; + border-radius: 3px; + color: var(--sg-text-muted); + background: transparent; + font-family: inherit; + font-size: 9px; + font-weight: 700; + line-height: 1.4; + cursor: pointer; + + &:hover, + &:focus-visible { + color: var(--sg-primary); + outline: none; + } + + &.active { + color: var(--sg-background); + background: var(--sg-primary); + } +} + +.language-label { + flex: 0 0 auto; + padding: 2px 5px; + border: 1px solid var(--sg-border); + border-radius: 3px; + color: var(--sg-text-muted); + background: var(--sg-background); + font-size: 9px; + font-weight: 700; +} + +.highlight-section__body { + display: grid; + gap: 4px; + padding: 6px 7px; +} + +.highlight-snippet { + margin: 0; + padding: 4px 6px; + border-left: 2px solid var(--sg-primary); + border-radius: 0 3px 3px 0; + background: color-mix( + in srgb, + var(--sg-primary-soft) 55%, + var(--sg-background) + ); + font-size: 11px; + line-height: 1.4; + overflow-wrap: anywhere; +} +// ------------------------ +// Expanded project panel +// ------------------------ + +.project-panel { + width: 100%; + padding: 12px 16px 14px; + color: var(--sg-text); + background: var(--sg-background); + border-top: 1px solid var(--sg-border); +} + +.project-panel__header { + display: flex; + align-items: flex-start; + justify-content: space-between; + gap: 12px; + margin-bottom: 10px; +} + +.project-panel__heading { + display: flex; + align-items: flex-start; + gap: 8px; + + > mat-icon { + flex: 0 0 auto; + width: 19px; + height: 19px; + color: var(--sg-primary); + font-size: 19px; + } + + h3 { + margin: 0; + font-size: 13px; + font-weight: 700; + line-height: 1.2; + } + + p { + margin: 1px 0 0; + color: var(--sg-text-muted); + font-size: 11px; + line-height: 1.3; + } +} + +.project-panel__content { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); + gap: 10px; +} + +.panel-field { + min-width: 0; + + &--full { + grid-column: 1 / -1; + } +} + +.panel-field__label { + color: var(--sg-text-muted); + font-size: 10px; + font-weight: 700; + text-transform: uppercase; + letter-spacing: 0.02em; +} + +.panel-field__text { + margin: 0; + font-size: 12px; + line-height: 1.5; + overflow-wrap: anywhere; +} + +.project-panel__empty { + display: flex; + align-items: center; + gap: 6px; + grid-column: 1 / -1; + color: var(--sg-text-muted); + font-size: 12px; + + mat-icon { + width: 16px; + height: 16px; + font-size: 16px; + } +} diff --git a/webapp/src/app/shared/ui/dfg-project-table/dfg-project-table.component.ts b/webapp/src/app/shared/ui/dfg-project-table/dfg-project-table.component.ts index d748e6c7..f068c1aa 100644 --- a/webapp/src/app/shared/ui/dfg-project-table/dfg-project-table.component.ts +++ b/webapp/src/app/shared/ui/dfg-project-table/dfg-project-table.component.ts @@ -25,6 +25,15 @@ import { MatTooltip } from '@angular/material/tooltip'; import { topicHierarchyColor } from '../../../resolvers/utils/topic-colors'; import { SkTextDirective } from '../../../custom-directives/sk-text.directive'; import { ChipOverflowToggleComponent } from '../chip-overflow-toggle/chip-overflow-toggle.component'; +import { SearchResultsStateService } from '../../../modules/keywords-search/search-results/search-results-state.service'; +import { TopicHierarchyColorInput } from '../../../resolvers/utils/topic-colors'; +import { + HighlightedTextComponent, + HighlightTerm, +} from '../highlighted-text/highlighted-text.component'; +import { MatDividerModule } from '@angular/material/divider'; +type HighlightLanguage = 'de' | 'en'; + @Component({ selector: 'app-dfg-project-table', imports: [ @@ -37,6 +46,8 @@ import { ChipOverflowToggleComponent } from '../chip-overflow-toggle/chip-overfl MatTooltip, AppTopicChipComponent, SkTextDirective, + HighlightedTextComponent, + MatDividerModule, ], templateUrl: './dfg-project-table.component.html', styleUrl: './dfg-project-table.component.scss', @@ -44,7 +55,10 @@ import { ChipOverflowToggleComponent } from '../chip-overflow-toggle/chip-overfl export class DfgProjectTableComponent implements OnInit { private readonly activatedRoute = inject(ActivatedRoute); private readonly router = inject(Router); - + private readonly searchResultsStateService = inject( + SearchResultsStateService, + { optional: true }, + ); page = input.required(); authorFilterEnabled = input(false); institutionFilterEnabled = input(false); @@ -99,10 +113,21 @@ export class DfgProjectTableComponent implements OnInit { selectedTopicMatchesQueryParams = computed(() => { return this.queryParamMap().get('topics')?.split(',') || []; }); - + keywordTopicMap = computed(() => { + return ( + this.searchResultsStateService?.keywordTopicMap() ?? + new Map() + ); + }); ngOnInit(): void { this.columns = [ - { id: 'title', header: 'Titel', type: 'accessor', accessorKey: 'title' }, + { + id: 'title', + header: 'Titel', + type: 'accessor', + accessorKey: 'title_de', + cellTemplate: this.titleTmp(), + }, { id: 'funding_start', header: 'Förderbeginn', @@ -130,7 +155,7 @@ export class DfgProjectTableComponent implements OnInit { cellTemplate: this.institutionsTmp(), }, { - id: 'professional_classification', + id: 'subject_classifications_raw', header: 'Fachsystematik', type: 'display', cellTemplate: this.detailRowTmp(), @@ -426,4 +451,117 @@ export class DfgProjectTableComponent implements OnInit { getClassificationTooltipText(classification: any): string { return this.getClassificationFullChain(classification); } + + private readonly selectedPanelLanguage = new Map(); + + getPanelLanguage(project: DfgProjectSummary): HighlightLanguage { + if (!project.id) return 'de'; + return this.selectedPanelLanguage.get(project.id) ?? 'de'; + } + + setPanelLanguage( + project: DfgProjectSummary, + language: HighlightLanguage, + ): void { + if (!project.id) return; + this.selectedPanelLanguage.set(project.id, language); + } + + hasAnyPanelContent(project: DfgProjectSummary): boolean { + const language = this.getPanelLanguage(project); + + const hasLocalizedContent = + language === 'de' + ? !!project.title_de || !!project.abstract_de + : !!project.title_en || !!project.abstract_en; + + return hasLocalizedContent || !!project.subject_classifications_raw?.length; + } + getClassificationHighlightTerms( + project: DfgProjectSummary, + index: number, + ): string[] { + const classificationHighlights = + project.highlight?.subject_classifications ?? []; + const terms = new Set(); + + for (const highlight of classificationHighlights) { + if (highlight.offset !== index) continue; + + for (const fragments of [ + highlight.wissenschaftsbereich, + highlight.fachkollegium, + highlight.fachgebiet, + highlight.fachgebiet_de, + highlight.fach, + ]) { + for (const term of this.extractHighlightTerms(fragments)) { + terms.add(term); + } + } + } + + return Array.from(terms); + } + /** + * Extracts the distinct matched terms out of Elasticsearch-style + * highlight fragments (terms wrapped in ...). + */ + extractHighlightTerms(fragments: string[] | null | undefined): string[] { + const terms = new Set(); + + for (const fragment of fragments ?? []) { + if (typeof fragment !== 'string') continue; + + const matches = fragment.matchAll(/(.*?)<\/em>/gi); + for (const match of matches) { + const term = match[1]?.trim(); + if (term) { + terms.add(term); + } + } + } + + return Array.from(terms); + } + + getHighlightTerms(terms: string[] | null | undefined): HighlightTerm[] { + return (terms ?? []).map((term) => ({ + term, + topic: this.resolveTopicForTerm(term), + })); + } + + private resolveTopicForTerm(term: string): TopicHierarchyColorInput | null { + const topic = + this.keywordTopicMap().get(term) ?? + this.keywordTopicMap().get(term.toLowerCase()); + //Attempt to find a topic for the term by checking if the term is a substring of any keyword in the keywordTopicMap + if (!topic) { + for (const [keyword, mappedTopic] of this.keywordTopicMap()) { + if ( + keyword.toLowerCase().includes(term.toLowerCase()) || + term.toLowerCase().includes(keyword.toLowerCase()) + ) { + return { + id: mappedTopic.id, + name: mappedTopic.display_name, + field_id: mappedTopic.field?.id, + field_name: mappedTopic.field?.display_name, + domain_id: mappedTopic.domain?.id, + domain_name: mappedTopic.domain?.display_name, + }; + } + } + } + if (!topic) return null; + return { + 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, + }; + } }