diff --git a/service/src/main/inse/models/bund_project.py b/service/src/main/inse/models/bund_project.py index 5de9413c..e1dc217f 100644 --- a/service/src/main/inse/models/bund_project.py +++ b/service/src/main/inse/models/bund_project.py @@ -108,10 +108,10 @@ class BundProject(BaseModel): examples=["Deutschland"], ) - implementing_agency: str | None = Field( + executing_agency: str | None = Field( default=None, validation_alias="Ausführende Stelle", - description="The implementing agency of the project", + description="The executing agency of the project", examples=[ "Universität Duisburg-Essen - Fachbereich Allgemeine Informatik - Lehrstuhl Networked Embedded Systems (NES)" ], diff --git a/service/src/main/inse/projects/model.py b/service/src/main/inse/projects/model.py index 4714225f..f1625692 100644 --- a/service/src/main/inse/projects/model.py +++ b/service/src/main/inse/projects/model.py @@ -88,7 +88,7 @@ class BundProjectHighlight(BaseModel): default_factory=list, description='Highlights from the Elasticsearch field "Zuwendungsempfänger".', ) - implementing_agency: list[str] = Field( + executing_agency: list[str] = Field( default_factory=list, description='Highlights from the Elasticsearch field "Ausführende Stelle".', ) @@ -146,7 +146,7 @@ class BundProjectSummary(BundProject): place=source.get("Ort"), state=source.get("Bundesland"), country=source.get("Staat"), - implementing_agency=source.get("Ausführende Stelle"), + executing_agency=source.get("Ausführende Stelle"), topic=source.get("Thema"), performance_plan_system=source.get("Leistungsplansystematik"), performance_plan_system_text=source.get( @@ -205,7 +205,7 @@ class BundProjectSummary(BundProject): recipient=cls._highlight_fragments( raw_highlight.get("Zuwendungsempfänger") ), - implementing_agency=cls._highlight_fragments( + executing_agency=cls._highlight_fragments( raw_highlight.get("Ausführende Stelle") ), ) @@ -215,7 +215,7 @@ class BundProjectSummary(BundProject): highlight.joint_project, highlight.topic, highlight.recipient, - highlight.implementing_agency, + highlight.executing_agency, ) ) diff --git a/webapp/src/app/api/model/bundProjectHighlight.ts b/webapp/src/app/api/model/bundProjectHighlight.ts index 40fd90d6..565f238b 100644 --- a/webapp/src/app/api/model/bundProjectHighlight.ts +++ b/webapp/src/app/api/model/bundProjectHighlight.ts @@ -28,6 +28,6 @@ export interface BundProjectHighlight { /** * Highlights from the Elasticsearch field \"Ausführende Stelle\". */ - implementing_agency?: Array; + executing_agency?: Array; } diff --git a/webapp/src/app/api/model/bundProjectSummary.ts b/webapp/src/app/api/model/bundProjectSummary.ts index e2a0c9ce..c651c6bd 100644 --- a/webapp/src/app/api/model/bundProjectSummary.ts +++ b/webapp/src/app/api/model/bundProjectSummary.ts @@ -1,7 +1,7 @@ /** * Innovation Search Engine API * - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -11,36 +11,38 @@ import { BundProjectHighlight } from './bundProjectHighlight'; import { Topic } from './topic'; import { BundInstitutionSummary } from './bundInstitutionSummary'; -export interface BundProjectSummary { - funding_code?: string | null; - department?: string | null; - department_fullname?: string | null; - referat?: string | null; - project_sponsor?: string | null; - project_sponsor_fullname?: string | null; - work_unit?: string | null; - recipient?: string | null; - municipal_code?: string | null; - municipality?: string | null; - place?: string | null; - state?: string | null; - country?: string | null; - implementing_agency?: string | null; - topic?: string | null; - performance_plan_system?: string | null; - performance_plan_system_text?: string | null; - funding_start?: string | null; - funding_end?: string | null; - grant_amount?: number | null; - funding_profile?: string | null; - joint_project?: string | null; - funding_type?: string | null; - publication_date?: string | null; - unix_timestamp?: number | null; - date?: string | null; - new?: boolean | null; - duration?: string | null; - oa_topics?: Array | null; - institution?: BundInstitutionSummary | null; - highlight?: BundProjectHighlight | null; + +export interface BundProjectSummary { + funding_code?: string | null; + department?: string | null; + department_fullname?: string | null; + referat?: string | null; + project_sponsor?: string | null; + project_sponsor_fullname?: string | null; + work_unit?: string | null; + recipient?: string | null; + municipal_code?: string | null; + municipality?: string | null; + place?: string | null; + state?: string | null; + country?: string | null; + executing_agency?: string | null; + topic?: string | null; + performance_plan_system?: string | null; + performance_plan_system_text?: string | null; + funding_start?: string | null; + funding_end?: string | null; + grant_amount?: number | null; + funding_profile?: string | null; + joint_project?: string | null; + funding_type?: string | null; + publication_date?: string | null; + unix_timestamp?: number | null; + date?: string | null; + 'new'?: boolean | null; + duration?: string | null; + oa_topics?: Array | null; + institution?: BundInstitutionSummary | null; + highlight?: BundProjectHighlight | null; } + diff --git a/webapp/src/app/modules/keywords-search/search-results/search-results-state.service.ts b/webapp/src/app/modules/keywords-search/search-results/search-results-state.service.ts index 179a17c6..802abafb 100644 --- a/webapp/src/app/modules/keywords-search/search-results/search-results-state.service.ts +++ b/webapp/src/app/modules/keywords-search/search-results/search-results-state.service.ts @@ -1,7 +1,7 @@ import { Injectable, computed, signal } from '@angular/core'; import { KeywordEntryWithTopic } from '../../../api/model/keywordEntryWithTopic'; import { Topic } from '../../../api'; - +import { TopicHierarchyColorInput } from '../../../resolvers/utils/topic-colors'; export type KeywordPatentLevel = 'broad' | 'coarse' | 'fine' | 'custom'; export interface PatentKeywordEntry { @@ -133,18 +133,63 @@ export class SearchResultsStateService { const keyword = entry.llm_keyword?.keyword?.trim().toLowerCase(); const topic = entry.topic_mapping?.topic; if (keyword && topic) { - map.set(keyword, topic); + map.set(this.normalize(keyword), topic); } } return map; }); + private normalize(str: string): string { + return str.toLowerCase().replace(/[^a-z0-9]+/g, ''); + } + private toTopicInput(topic: Topic): TopicHierarchyColorInput { + 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, + }; + } + // Resolve a topic for a given keyword term, using the following strategy: + // 1. Exact / case-insensitive match (cheap, most common case) + // 2. Normalized match — catches "machine learning" vs "machine-learning" + // 3. Last-resort fuzzy substring match, also normalized + public resolveTopicForTerm(term: string): TopicHierarchyColorInput | null { + const directMap = this.keywordTopicMap(); + + // 1. Exact / case-insensitive match (cheap, most common case) + const exact = directMap.get(term) ?? directMap.get(term.toLowerCase()); + if (exact) return this.toTopicInput(exact); + + // 2. Normalized match — catches "machine learning" vs "machine-learning" + const normalizedTerm = this.normalize(term); + if (normalizedTerm) { + const normalized = directMap.get(normalizedTerm); + if (normalized) return this.toTopicInput(normalized); + // 3. Last-resort fuzzy substring match, also normalized + for (const [keyword, mappedTopic] of directMap) { + const normalizedKeyword = this.normalize(keyword); + if (normalizedKeyword) { + if ( + normalizedKeyword.includes(normalizedTerm) || + normalizedTerm.includes(normalizedKeyword) + ) { + return this.toTopicInput(mappedTopic); + } + } + } + } + + return null; + } // Parallel topic-name list for trend dashboard strategies. Entries // without a resolvable keyword are skipped when building the lookup map // so they can never collide on an `undefined` key and shadow a real one. readonly topicsList = computed(() => { const list = this.keywords() .map((kw) => { - const normalized = kw.trim().toLowerCase(); + const normalized = this.normalize(kw); const entry = this.selectedKeywordEntries().find( (e) => e.llm_keyword?.keyword?.trim().toLowerCase() === normalized || diff --git a/webapp/src/app/resolvers/eu-cordis-projects.resolver.ts b/webapp/src/app/resolvers/eu-cordis-projects.resolver.ts index a9a14e26..0c602553 100644 --- a/webapp/src/app/resolvers/eu-cordis-projects.resolver.ts +++ b/webapp/src/app/resolvers/eu-cordis-projects.resolver.ts @@ -41,25 +41,6 @@ export const RESOLVING_PROJECT_PAGE_FOR = { type ResolvingEuProjectPageFor = (typeof RESOLVING_PROJECT_PAGE_FOR)[keyof typeof RESOLVING_PROJECT_PAGE_FOR]; -function getRepeatedOrCsv(routeQueryParamMap: any, key: string): string[] { - const repeatedValues = routeQueryParamMap.getAll(key) ?? []; - - const csvValues = - routeQueryParamMap - .get(key) - ?.split(',') - .map((value: string) => value.trim()) - .filter(Boolean) ?? []; - - return Array.from( - new Set( - [...repeatedValues, ...csvValues] - .map((value) => String(value).trim()) - .filter(Boolean), - ), - ); -} - export const euCordisProjectsResolver: ResolveFn = ( route, state, @@ -169,7 +150,7 @@ export const euCordisProjectsResolver: ResolveFn = ( } if (resolvingFor === RESOLVING_PROJECT_PAGE_FOR.KEYWORDS_SEARCH) { - const keywords = getRepeatedOrCsv(route.queryParamMap, 'keywords'); + const keywords = route.queryParamMap.get('keywords')?.split(',') ?? []; const selectedTopicIds = route.queryParamMap.getAll('topics'); const fuzzySearch = route.queryParamMap.get('fuzzy') === 'true'; 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 index cdaae4cd..7e2241e9 100644 --- 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 @@ -1,6 +1,7 @@ @@ -106,3 +107,61 @@ } + + @if (project.highlight) { + @let highlight = project.highlight; +
+
+ @if (highlight.topic.length > 0) { +
+

Titel

+ +
+ } + + @if (highlight.recipient.length > 0) { +
+

Zuwendungsempfänger

+ +
+ } + @if (highlight.joint_project.length > 0) { +
+

Verbundprojekt

+ +
+ } + @if (highlight.executing_agency.length > 0) { +
+

Ausführende Stelle

+ +
+ } +
+
+ } +
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 index 57b73879..63d6ff2d 100644 --- 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 @@ -205,6 +205,97 @@ } } } +// ------------------------ +// 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; + } +} // ------------------------ // Responsive adjustments 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 index 90a62735..ee723d0c 100644 --- 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 @@ -27,6 +27,12 @@ import { topicHierarchyColor } from '../../../resolvers/utils/topic-colors'; import { bundProjectQueryParamKeys } from '../../../resolvers/bund-projects.resolver'; 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 { + HighlightedTextComponent, + HighlightTerm, +} from '../highlighted-text/highlighted-text.component'; +import { MatDividerModule } from '@angular/material/divider'; @Component({ selector: 'app-bund-project-table', imports: [ @@ -42,6 +48,7 @@ import { ChipOverflowToggleComponent } from '../chip-overflow-toggle/chip-overfl ChipComponent, AppTopicChipComponent, SkTextDirective, + HighlightedTextComponent, ], templateUrl: './bund-project-table.component.html', styleUrl: './bund-project-table.component.scss', @@ -49,14 +56,19 @@ import { ChipOverflowToggleComponent } from '../chip-overflow-toggle/chip-overfl export class BundProjectTableComponent 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); topicFilterEnabled = input(false); elements = computed(() => this.page().elements ?? []); - + highlightRowEnabled = computed(() => { + return this.elements()[0]?.highlight ? true : false; + }); queryParamMap = toSignal(this.activatedRoute.queryParamMap, { initialValue: this.activatedRoute.snapshot.queryParamMap, }); @@ -353,4 +365,31 @@ export class BundProjectTableComponent implements OnInit { return this.expandedProjectTopicsId.includes(project.funding_code); } + /** + * 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.searchResultsStateService?.resolveTopicForTerm(term) ?? null, + })); + } } 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 ec8f7600..828a5c93 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,7 +1,7 @@ @@ -63,113 +63,107 @@ -
-
-
- - -
-
- -
- @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 (project.highlight) { + @let highlight = project.highlight; +
+
+
+ +
- } - @if (getProjectClassifications(project).length > 0) { -
-

Fachsystematik

- @for ( - classification of getProjectClassifications(project); - track $index - ) { - - } @empty { - - +
+ +
+ @if (getPanelLanguage(project) === 'de') { + @if (highlight.title_de.length > 0) { +
+

Titel

+ +
} - - } -
-
+ + @if (project.highlight?.abstract_de.length > 0) { +
+

Zusammenfassung

+ +
+ } + } @else { + @if (project.highlight?.title_en.length > 0) { +
+

Title

+ +
+ } + + @if (highlight.abstract_en.length > 0) { +
+

Abstract

+ +
+ } + } + @if (project.highlight?.subject_classifications?.length > 0) { +
+

Fachsystematik

+ @for ( + classification of getProjectClassifications(project); + track $index + ) { + + } @empty { + - + } +
+ } +
+
+ }
@let projectAuthors = getProjectAuthors(project); 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 f068c1aa..f785d1ba 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 @@ -26,7 +26,6 @@ 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, @@ -65,7 +64,9 @@ export class DfgProjectTableComponent implements OnInit { topicFilterEnabled = input(false); elements = computed(() => this.page().elements ?? []); - + highlightRowEnabled = computed(() => { + return this.elements()[0]?.highlight ? true : false; + }); queryParamMap = toSignal(this.activatedRoute.queryParamMap, { initialValue: this.activatedRoute.snapshot.queryParamMap, }); @@ -455,8 +456,12 @@ export class DfgProjectTableComponent implements OnInit { private readonly selectedPanelLanguage = new Map(); getPanelLanguage(project: DfgProjectSummary): HighlightLanguage { - if (!project.id) return 'de'; - return this.selectedPanelLanguage.get(project.id) ?? 'de'; + if (this.hasDePanelContent(project)) { + return this.selectedPanelLanguage.get(project.id) ?? 'de'; + } else if (this.hasEnPanelContent(project)) { + return this.selectedPanelLanguage.get(project.id) ?? 'en'; + } + return 'de'; // default to German if no content is available' } setPanelLanguage( @@ -467,15 +472,23 @@ export class DfgProjectTableComponent implements OnInit { this.selectedPanelLanguage.set(project.id, language); } - hasAnyPanelContent(project: DfgProjectSummary): boolean { - const language = this.getPanelLanguage(project); - + hasDePanelContent(project: DfgProjectSummary): boolean { const hasLocalizedContent = - language === 'de' - ? !!project.title_de || !!project.abstract_de - : !!project.title_en || !!project.abstract_en; + project.highlight?.title_de?.length || + project.highlight?.abstract_de?.length + ? true + : false; - return hasLocalizedContent || !!project.subject_classifications_raw?.length; + return hasLocalizedContent; + } + hasEnPanelContent(project: DfgProjectSummary): boolean { + const hasLocalizedContent = + project.highlight?.title_en?.length || + project.highlight?.abstract_en?.length + ? true + : false; + + return hasLocalizedContent; } getClassificationHighlightTerms( project: DfgProjectSummary, @@ -528,40 +541,7 @@ export class DfgProjectTableComponent implements OnInit { getHighlightTerms(terms: string[] | null | undefined): HighlightTerm[] { return (terms ?? []).map((term) => ({ term, - topic: this.resolveTopicForTerm(term), + topic: this.searchResultsStateService?.resolveTopicForTerm(term) ?? null, })); } - - 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, - }; - } } diff --git a/webapp/src/app/shared/ui/eu-project-table/eu-project-table.component.html b/webapp/src/app/shared/ui/eu-project-table/eu-project-table.component.html index 4e4a2b50..026b639b 100644 --- a/webapp/src/app/shared/ui/eu-project-table/eu-project-table.component.html +++ b/webapp/src/app/shared/ui/eu-project-table/eu-project-table.component.html @@ -1,6 +1,7 @@ @@ -146,3 +147,70 @@ open_in_new + + @if (project.highlight) { + @let highlight = project.highlight; +
+
+ @if (highlight.title.length > 0) { +
+

Titel

+ +
+ } + + @if (highlight.objective.length > 0) { +
+

Zusammenfassung

+ +
+ } + @if (highlight.acronym.length > 0) { +
+

Akronym

+ +
+ } + @if (highlight.cordis_topic_text.length > 0) { +
+

Cordis-Thema

+ +
+ } + @if (highlight.keywords.length > 0) { +
+

Schlüsselwörter

+ +
+ } +
+
+ } +
diff --git a/webapp/src/app/shared/ui/eu-project-table/eu-project-table.component.scss b/webapp/src/app/shared/ui/eu-project-table/eu-project-table.component.scss index 39334f9f..abe02090 100644 --- a/webapp/src/app/shared/ui/eu-project-table/eu-project-table.component.scss +++ b/webapp/src/app/shared/ui/eu-project-table/eu-project-table.component.scss @@ -142,7 +142,97 @@ .classification-container { max-width: 200px; } +// ------------------------ +// 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; + } +} // ------------------------ // Data table overrides (applied via ::ng-deep) // ------------------------ diff --git a/webapp/src/app/shared/ui/eu-project-table/eu-project-table.component.ts b/webapp/src/app/shared/ui/eu-project-table/eu-project-table.component.ts index 3ce72773..585b9b30 100644 --- a/webapp/src/app/shared/ui/eu-project-table/eu-project-table.component.ts +++ b/webapp/src/app/shared/ui/eu-project-table/eu-project-table.component.ts @@ -33,6 +33,12 @@ import { topicHierarchyColor } from '../../../resolvers/utils/topic-colors'; import { ChipComponent } from '../chip/chip.component'; import { AppAuthorChipComponent } from '../app-author-chip/app-author-chip.component'; import { ChipOverflowToggleComponent } from '../chip-overflow-toggle/chip-overflow-toggle.component'; +import { + HighlightedTextComponent, + HighlightTerm, +} from '../highlighted-text/highlighted-text.component'; +import { MatDividerModule } from '@angular/material/divider'; +import { SearchResultsStateService } from '../../../modules/keywords-search/search-results/search-results-state.service'; @Component({ selector: 'app-eu-project-table', imports: [ @@ -49,6 +55,8 @@ import { ChipOverflowToggleComponent } from '../chip-overflow-toggle/chip-overfl ChipComponent, AppAuthorChipComponent, SkTextDirective, + MatDividerModule, + HighlightedTextComponent, ], templateUrl: './eu-project-table.component.html', styleUrl: './eu-project-table.component.scss', @@ -56,7 +64,10 @@ import { ChipOverflowToggleComponent } from '../chip-overflow-toggle/chip-overfl export class EuProjectTableComponent { private readonly activatedRoute = inject(ActivatedRoute); private readonly router = inject(Router); - + private readonly searchResultsStateService = inject( + SearchResultsStateService, + { optional: true }, + ); queryParamKeys = euProjectQueryParamKeys; page = input(); @@ -73,6 +84,9 @@ export class EuProjectTableComponent { return this.page()?.total ?? 0; }); + highlightRowEnabled = computed(() => { + return this.projects()[0]?.highlight ? true : false; + }); queryParamMap = toSignal(this.activatedRoute.queryParamMap, { initialValue: this.activatedRoute.snapshot.queryParamMap, }); @@ -94,7 +108,12 @@ export class EuProjectTableComponent { selectedTypesQueryParams = computed(() => { return this.queryParamMap().getAll(this.queryParamKeys.projectType); }); - + keywordTopicMap = computed(() => { + return ( + this.searchResultsStateService?.keywordTopicMap() ?? + new Map() + ); + }); projectTypeTmp = viewChild.required>('projectTypeTmp'); fundingStartTmp = viewChild.required>('fundingStartTmp'); fundingEndTmp = viewChild.required>('fundingEndTmp'); @@ -507,4 +526,33 @@ export class EuProjectTableComponent { ? this.expandedProjectTopicsIds.filter((id) => id !== projectId) : [...this.expandedProjectTopicsIds, projectId]; } + // Highlighted Text + /** + * 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.searchResultsStateService?.resolveTopicForTerm(term) ?? null, + })); + } }