Merge branch 'dev' of https://project.nes.uni-due.de/gitea/lbs/smartguide into refactor/static_topic_cache
This commit is contained in:
@@ -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)"
|
||||
],
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -1,33 +1,31 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Highlighted matching fragments from a BUND project search.
|
||||
*/
|
||||
export interface BundProjectHighlight {
|
||||
/**
|
||||
* Highlights from the Elasticsearch field \"Verbundprojekt\".
|
||||
*/
|
||||
joint_project?: Array<string>;
|
||||
/**
|
||||
* Highlights from the Elasticsearch field \"Thema\".
|
||||
*/
|
||||
topic?: Array<string>;
|
||||
/**
|
||||
* Highlights from the Elasticsearch field \"Zuwendungsempfänger\".
|
||||
*/
|
||||
recipient?: Array<string>;
|
||||
/**
|
||||
* Highlights from the Elasticsearch field \"Ausführende Stelle\".
|
||||
*/
|
||||
implementing_agency?: Array<string>;
|
||||
export interface BundProjectHighlight {
|
||||
/**
|
||||
* Highlights from the Elasticsearch field \"Verbundprojekt\".
|
||||
*/
|
||||
joint_project?: Array<string>;
|
||||
/**
|
||||
* Highlights from the Elasticsearch field \"Thema\".
|
||||
*/
|
||||
topic?: Array<string>;
|
||||
/**
|
||||
* Highlights from the Elasticsearch field \"Zuwendungsempfänger\".
|
||||
*/
|
||||
recipient?: Array<string>;
|
||||
/**
|
||||
* Highlights from the Elasticsearch field \"Ausführende Stelle\".
|
||||
*/
|
||||
executing_agency?: Array<string>;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ export interface BundProjectSummary {
|
||||
place?: string | null;
|
||||
state?: string | null;
|
||||
country?: string | null;
|
||||
implementing_agency?: string | null;
|
||||
executing_agency?: string | null;
|
||||
topic?: string | null;
|
||||
performance_plan_system?: string | null;
|
||||
performance_plan_system_text?: string | null;
|
||||
|
||||
+48
-3
@@ -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 ||
|
||||
|
||||
@@ -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<EuCordisProjectSearchPage> = (
|
||||
route,
|
||||
state,
|
||||
@@ -169,7 +150,7 @@ export const euCordisProjectsResolver: ResolveFn<EuCordisProjectSearchPage> = (
|
||||
}
|
||||
|
||||
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';
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<app-data-table
|
||||
[columns]="columns"
|
||||
[data]="elements()"
|
||||
[detailTemplate]="highlightRowEnabled() ? expandedProject : null"
|
||||
[queryParamSortKey]="queryParamKeys.sortBy"
|
||||
[queryParamSortDirectionKey]="queryParamKeys.sortDirection" />
|
||||
|
||||
@@ -106,3 +107,61 @@
|
||||
}
|
||||
</div>
|
||||
</ng-template>
|
||||
<ng-template #expandedProject let-project>
|
||||
@if (project.highlight) {
|
||||
@let highlight = project.highlight;
|
||||
<section class="project-panel" aria-label="Weitere Projektdetails">
|
||||
<div class="project-panel__content">
|
||||
@if (highlight.topic.length > 0) {
|
||||
<article class="panel-field panel-field--full">
|
||||
<h4 class="panel-field__label">Titel</h4>
|
||||
<app-highlighted-text
|
||||
class="panel-field__text"
|
||||
[content]="project.topic"
|
||||
[highlights]="
|
||||
getHighlightTerms(extractHighlightTerms(highlight.topic))
|
||||
" />
|
||||
</article>
|
||||
}
|
||||
|
||||
@if (highlight.recipient.length > 0) {
|
||||
<article class="panel-field panel-field--full">
|
||||
<h4 class="panel-field__label">Zuwendungsempfänger</h4>
|
||||
<app-highlighted-text
|
||||
class="panel-field__text"
|
||||
[content]="project.recipient"
|
||||
[highlights]="
|
||||
getHighlightTerms(extractHighlightTerms(highlight.recipient))
|
||||
" />
|
||||
</article>
|
||||
}
|
||||
@if (highlight.joint_project.length > 0) {
|
||||
<article class="panel-field panel-field--full">
|
||||
<h4 class="panel-field__label">Verbundprojekt</h4>
|
||||
<app-highlighted-text
|
||||
class="panel-field__text"
|
||||
[content]="project.joint_project"
|
||||
[highlights]="
|
||||
getHighlightTerms(
|
||||
extractHighlightTerms(highlight.joint_project)
|
||||
)
|
||||
" />
|
||||
</article>
|
||||
}
|
||||
@if (highlight.executing_agency.length > 0) {
|
||||
<article class="panel-field panel-field--full">
|
||||
<h4 class="panel-field__label">Ausführende Stelle</h4>
|
||||
<app-highlighted-text
|
||||
class="panel-field__text"
|
||||
[content]="project.executing_agency"
|
||||
[highlights]="
|
||||
getHighlightTerms(
|
||||
extractHighlightTerms(highlight.executing_agency)
|
||||
)
|
||||
" />
|
||||
</article>
|
||||
}
|
||||
</div>
|
||||
</section>
|
||||
}
|
||||
</ng-template>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<BundProjectPage>();
|
||||
authorFilterEnabled = input<boolean>(false);
|
||||
institutionFilterEnabled = input<boolean>(false);
|
||||
topicFilterEnabled = input<boolean>(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 <em>...</em>).
|
||||
*/
|
||||
extractHighlightTerms(fragments: string[] | null | undefined): string[] {
|
||||
const terms = new Set<string>();
|
||||
|
||||
for (const fragment of fragments ?? []) {
|
||||
if (typeof fragment !== 'string') continue;
|
||||
|
||||
const matches = fragment.matchAll(/<em>(.*?)<\/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,
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<app-data-table
|
||||
[columns]="columns"
|
||||
[data]="elements()"
|
||||
[detailTemplate]="expandedProject"
|
||||
[detailTemplate]="highlightRowEnabled() ? expandedProject : null"
|
||||
[queryParamSortKey]="queryParamKeys.sortBy"
|
||||
[queryParamSortDirectionKey]="queryParamKeys.sortDirection" />
|
||||
|
||||
@@ -63,113 +63,107 @@
|
||||
</div>
|
||||
</ng-template>
|
||||
<ng-template #expandedProject let-project>
|
||||
<section class="project-panel" aria-label="Weitere Projektdetails">
|
||||
<header class="project-panel__header">
|
||||
<div class="language-toggle" role="group" aria-label="Sprache wählen">
|
||||
<button
|
||||
type="button"
|
||||
class="language-toggle__button"
|
||||
[class.active]="getPanelLanguage(project) === 'de'"
|
||||
(click)="setPanelLanguage(project, 'de')">
|
||||
DE
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="language-toggle__button"
|
||||
[class.active]="getPanelLanguage(project) === 'en'"
|
||||
(click)="setPanelLanguage(project, 'en')">
|
||||
EN
|
||||
</button>
|
||||
</div>
|
||||
</header>
|
||||
<mat-divider />
|
||||
<div class="project-panel__content">
|
||||
@if (getPanelLanguage(project) === 'de') {
|
||||
@if (project.title_de) {
|
||||
<article class="panel-field panel-field--full">
|
||||
<h4 class="panel-field__label">Titel</h4>
|
||||
<app-highlighted-text
|
||||
class="panel-field__text"
|
||||
[content]="project.title_de"
|
||||
[highlights]="
|
||||
getHighlightTerms(
|
||||
extractHighlightTerms(project.highlight?.title_de)
|
||||
)
|
||||
" />
|
||||
</article>
|
||||
}
|
||||
|
||||
@if (project.abstract_de) {
|
||||
<article class="panel-field panel-field--full">
|
||||
<h4 class="panel-field__label">Zusammenfassung</h4>
|
||||
<app-highlighted-text
|
||||
class="panel-field__text"
|
||||
[content]="project.abstract_de"
|
||||
[highlights]="
|
||||
getHighlightTerms(
|
||||
extractHighlightTerms(project.highlight?.abstract_de)
|
||||
)
|
||||
" />
|
||||
</article>
|
||||
}
|
||||
} @else {
|
||||
@if (project.title_en) {
|
||||
<article class="panel-field panel-field--full">
|
||||
<h4 class="panel-field__label">Title</h4>
|
||||
<app-highlighted-text
|
||||
class="panel-field__text"
|
||||
[content]="project.title_en"
|
||||
[highlights]="
|
||||
getHighlightTerms(
|
||||
extractHighlightTerms(project.highlight?.title_en)
|
||||
)
|
||||
" />
|
||||
</article>
|
||||
}
|
||||
|
||||
@if (project.abstract_en) {
|
||||
<article class="panel-field panel-field--full">
|
||||
<h4 class="panel-field__label">Abstract</h4>
|
||||
<app-highlighted-text
|
||||
class="panel-field__text"
|
||||
[content]="project.abstract_en"
|
||||
[highlights]="
|
||||
getHighlightTerms(
|
||||
extractHighlightTerms(project.highlight?.abstract_en)
|
||||
)
|
||||
" />
|
||||
</article>
|
||||
}
|
||||
}
|
||||
|
||||
@if (!hasAnyPanelContent(project)) {
|
||||
<div class="project-panel__empty">
|
||||
<mat-icon aria-hidden="true">info</mat-icon>
|
||||
<span>Keine weiteren Angaben vorhanden.</span>
|
||||
@if (project.highlight) {
|
||||
@let highlight = project.highlight;
|
||||
<section class="project-panel" aria-label="Weitere Projektdetails">
|
||||
<header class="project-panel__header">
|
||||
<div class="language-toggle" role="group" aria-label="Sprache wählen">
|
||||
<button
|
||||
[disabled]="!hasDePanelContent(project)"
|
||||
type="button"
|
||||
class="language-toggle__button"
|
||||
[class.active]="getPanelLanguage(project) === 'de'"
|
||||
(click)="setPanelLanguage(project, 'de')">
|
||||
DE
|
||||
</button>
|
||||
<button
|
||||
[disabled]="!hasEnPanelContent(project)"
|
||||
type="button"
|
||||
class="language-toggle__button"
|
||||
[class.active]="getPanelLanguage(project) === 'en'"
|
||||
(click)="setPanelLanguage(project, 'en')">
|
||||
EN
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
@if (getProjectClassifications(project).length > 0) {
|
||||
<article class="panel-field panel-field--full">
|
||||
<h4 class="panel-field__label">Fachsystematik</h4>
|
||||
@for (
|
||||
classification of getProjectClassifications(project);
|
||||
track $index
|
||||
) {
|
||||
<app-highlighted-text
|
||||
class="panel-field__text"
|
||||
[content]="getClassificationFullChain(classification)"
|
||||
[highlights]="
|
||||
getHighlightTerms(
|
||||
getClassificationHighlightTerms(project, $index)
|
||||
)
|
||||
" />
|
||||
} @empty {
|
||||
<span class="empty-text">-</span>
|
||||
</header>
|
||||
<mat-divider />
|
||||
<div class="project-panel__content">
|
||||
@if (getPanelLanguage(project) === 'de') {
|
||||
@if (highlight.title_de.length > 0) {
|
||||
<article class="panel-field panel-field--full">
|
||||
<h4 class="panel-field__label">Titel</h4>
|
||||
<app-highlighted-text
|
||||
class="panel-field__text"
|
||||
[content]="project.title_de"
|
||||
[highlights]="
|
||||
getHighlightTerms(extractHighlightTerms(highlight.title_de))
|
||||
" />
|
||||
</article>
|
||||
}
|
||||
</article>
|
||||
}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@if (project.highlight?.abstract_de.length > 0) {
|
||||
<article class="panel-field panel-field--full">
|
||||
<h4 class="panel-field__label">Zusammenfassung</h4>
|
||||
<app-highlighted-text
|
||||
class="panel-field__text"
|
||||
[content]="project.abstract_de"
|
||||
[highlights]="
|
||||
getHighlightTerms(
|
||||
extractHighlightTerms(highlight.abstract_de)
|
||||
)
|
||||
" />
|
||||
</article>
|
||||
}
|
||||
} @else {
|
||||
@if (project.highlight?.title_en.length > 0) {
|
||||
<article class="panel-field panel-field--full">
|
||||
<h4 class="panel-field__label">Title</h4>
|
||||
<app-highlighted-text
|
||||
class="panel-field__text"
|
||||
[content]="project.title_en"
|
||||
[highlights]="
|
||||
getHighlightTerms(extractHighlightTerms(highlight.title_en))
|
||||
" />
|
||||
</article>
|
||||
}
|
||||
|
||||
@if (highlight.abstract_en.length > 0) {
|
||||
<article class="panel-field panel-field--full">
|
||||
<h4 class="panel-field__label">Abstract</h4>
|
||||
<app-highlighted-text
|
||||
class="panel-field__text"
|
||||
[content]="project.abstract_en"
|
||||
[highlights]="
|
||||
getHighlightTerms(
|
||||
extractHighlightTerms(highlight.abstract_en)
|
||||
)
|
||||
" />
|
||||
</article>
|
||||
}
|
||||
}
|
||||
@if (project.highlight?.subject_classifications?.length > 0) {
|
||||
<article class="panel-field panel-field--full">
|
||||
<h4 class="panel-field__label">Fachsystematik</h4>
|
||||
@for (
|
||||
classification of getProjectClassifications(project);
|
||||
track $index
|
||||
) {
|
||||
<app-highlighted-text
|
||||
class="panel-field__text"
|
||||
[content]="getClassificationFullChain(classification)"
|
||||
[highlights]="
|
||||
getHighlightTerms(
|
||||
getClassificationHighlightTerms(project, $index)
|
||||
)
|
||||
" />
|
||||
} @empty {
|
||||
<span class="empty-text">-</span>
|
||||
}
|
||||
</article>
|
||||
}
|
||||
</div>
|
||||
</section>
|
||||
}
|
||||
</ng-template>
|
||||
<ng-template #authorsTmp let-project>
|
||||
@let projectAuthors = getProjectAuthors(project);
|
||||
|
||||
@@ -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<boolean>(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<string, HighlightLanguage>();
|
||||
|
||||
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,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<app-data-table
|
||||
[columns]="columns()"
|
||||
[data]="projects()"
|
||||
[detailTemplate]="highlightRowEnabled() ? expandedProject : null"
|
||||
[queryParamSortKey]="queryParamKeys.sortBy"
|
||||
[queryParamSortDirectionKey]="queryParamKeys.sortDirection" />
|
||||
|
||||
@@ -146,3 +147,70 @@
|
||||
<mat-icon>open_in_new</mat-icon>
|
||||
</a>
|
||||
</ng-template>
|
||||
<ng-template #expandedProject let-project>
|
||||
@if (project.highlight) {
|
||||
@let highlight = project.highlight;
|
||||
<section class="project-panel" aria-label="Weitere Projektdetails">
|
||||
<div class="project-panel__content">
|
||||
@if (highlight.title.length > 0) {
|
||||
<article class="panel-field panel-field--full">
|
||||
<h4 class="panel-field__label">Titel</h4>
|
||||
<app-highlighted-text
|
||||
class="panel-field__text"
|
||||
[content]="project.title"
|
||||
[highlights]="
|
||||
getHighlightTerms(extractHighlightTerms(highlight.title))
|
||||
" />
|
||||
</article>
|
||||
}
|
||||
|
||||
@if (highlight.objective.length > 0) {
|
||||
<article class="panel-field panel-field--full">
|
||||
<h4 class="panel-field__label">Zusammenfassung</h4>
|
||||
<app-highlighted-text
|
||||
class="panel-field__text"
|
||||
[content]="project.objective"
|
||||
[highlights]="
|
||||
getHighlightTerms(extractHighlightTerms(highlight.objective))
|
||||
" />
|
||||
</article>
|
||||
}
|
||||
@if (highlight.acronym.length > 0) {
|
||||
<article class="panel-field panel-field--full">
|
||||
<h4 class="panel-field__label">Akronym</h4>
|
||||
<app-highlighted-text
|
||||
class="panel-field__text"
|
||||
[content]="project.acronym"
|
||||
[highlights]="
|
||||
getHighlightTerms(extractHighlightTerms(highlight.acronym))
|
||||
" />
|
||||
</article>
|
||||
}
|
||||
@if (highlight.cordis_topic_text.length > 0) {
|
||||
<article class="panel-field panel-field--full">
|
||||
<h4 class="panel-field__label">Cordis-Thema</h4>
|
||||
<app-highlighted-text
|
||||
class="panel-field__text"
|
||||
[content]="project.cordis_topic_text"
|
||||
[highlights]="
|
||||
getHighlightTerms(
|
||||
extractHighlightTerms(highlight.cordis_topic_text)
|
||||
)
|
||||
" />
|
||||
</article>
|
||||
}
|
||||
@if (highlight.keywords.length > 0) {
|
||||
<article class="panel-field panel-field--full">
|
||||
<h4 class="panel-field__label">Schlüsselwörter</h4>
|
||||
<app-highlighted-text
|
||||
class="panel-field__text"
|
||||
[content]="project.keywords"
|
||||
[highlights]="
|
||||
getHighlightTerms(extractHighlightTerms(highlight.keywords))
|
||||
" />
|
||||
</article>
|
||||
}
|
||||
</div>
|
||||
</section>
|
||||
}
|
||||
</ng-template>
|
||||
|
||||
@@ -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)
|
||||
// ------------------------
|
||||
|
||||
@@ -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<EuCordisProjectSearchPage | undefined>();
|
||||
@@ -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<string, Topic>()
|
||||
);
|
||||
});
|
||||
projectTypeTmp = viewChild.required<TemplateRef<unknown>>('projectTypeTmp');
|
||||
fundingStartTmp = viewChild.required<TemplateRef<unknown>>('fundingStartTmp');
|
||||
fundingEndTmp = viewChild.required<TemplateRef<unknown>>('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 <em>...</em>).
|
||||
*/
|
||||
extractHighlightTerms(fragments: string[] | null | undefined): string[] {
|
||||
const terms = new Set<string>();
|
||||
|
||||
for (const fragment of fragments ?? []) {
|
||||
if (typeof fragment !== 'string') continue;
|
||||
|
||||
const matches = fragment.matchAll(/<em>(.*?)<\/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,
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user