From 2962b784adea442c4ecb5f65a6e4dbfd1c435d12 Mon Sep 17 00:00:00 2001 From: genja Date: Wed, 22 Jul 2026 23:41:27 +0200 Subject: [PATCH] added project type selector and institution selector for EU Cordis Projects --- ...hable-eu-institution-select.component.html | 12 ++++ ...hable-eu-institution-select.component.scss | 0 ...rchable-eu-institution-select.component.ts | 48 ++++++++++++++++ ...able-eu-project-type-select.component.html | 11 ++++ ...able-eu-project-type-select.component.scss | 0 ...chable-eu-project-type-select.component.ts | 57 +++++++++++++++++++ 6 files changed, 128 insertions(+) create mode 100644 webapp/src/app/shared/ui/searchable-eu-institution-select/searchable-eu-institution-select.component.html create mode 100644 webapp/src/app/shared/ui/searchable-eu-institution-select/searchable-eu-institution-select.component.scss create mode 100644 webapp/src/app/shared/ui/searchable-eu-institution-select/searchable-eu-institution-select.component.ts create mode 100644 webapp/src/app/shared/ui/searchable-eu-project-type-select/searchable-eu-project-type-select.component.html create mode 100644 webapp/src/app/shared/ui/searchable-eu-project-type-select/searchable-eu-project-type-select.component.scss create mode 100644 webapp/src/app/shared/ui/searchable-eu-project-type-select/searchable-eu-project-type-select.component.ts diff --git a/webapp/src/app/shared/ui/searchable-eu-institution-select/searchable-eu-institution-select.component.html b/webapp/src/app/shared/ui/searchable-eu-institution-select/searchable-eu-institution-select.component.html new file mode 100644 index 00000000..ea0f7c1f --- /dev/null +++ b/webapp/src/app/shared/ui/searchable-eu-institution-select/searchable-eu-institution-select.component.html @@ -0,0 +1,12 @@ + diff --git a/webapp/src/app/shared/ui/searchable-eu-institution-select/searchable-eu-institution-select.component.scss b/webapp/src/app/shared/ui/searchable-eu-institution-select/searchable-eu-institution-select.component.scss new file mode 100644 index 00000000..e69de29b diff --git a/webapp/src/app/shared/ui/searchable-eu-institution-select/searchable-eu-institution-select.component.ts b/webapp/src/app/shared/ui/searchable-eu-institution-select/searchable-eu-institution-select.component.ts new file mode 100644 index 00000000..bbd4254b --- /dev/null +++ b/webapp/src/app/shared/ui/searchable-eu-institution-select/searchable-eu-institution-select.component.ts @@ -0,0 +1,48 @@ +import { Component, inject, input, output } from '@angular/core'; + +import { ProjectsService } from '../../../api'; +import { Observable } from 'rxjs'; +import { SearchableSelectComponent } from '../searchable-select/searchable-select.component'; +import { EuCordisOrganizationSelectorPage } from '../../../api/model/euCordisOrganizationSelectorPage'; +import { EuCordisOrganizationSelectorSummary } from '../../../api/model/euCordisOrganizationSelectorSummary'; +@Component({ + selector: 'app-searchable-eu-institution-select', + imports: [SearchableSelectComponent], + templateUrl: './searchable-eu-institution-select.component.html', + styleUrl: './searchable-eu-institution-select.component.scss', +}) +export class SearchableEuInstitutionSelectComponent { + private readonly projectsService = inject(ProjectsService); + + label = input('Institutionen'); + selectedInstitutions = + input.required(); + + handleInstitutionSelectChange = output(); + + fetchInstitutions = ( + searchTerm: string, + ): Observable => { + return this.projectsService.getEuOrganizationAutocompleteForSelector( + searchTerm, + ); + }; + + getInstitutionLabel = ( + institution: EuCordisOrganizationSelectorSummary, + ): string => { + return institution.name ?? institution.short_name ?? 'Institution'; + }; + + getInstitutionValue = ( + institution: EuCordisOrganizationSelectorSummary, + ): string => { + return institution.id!; + }; + + getInstitutionDescription = ( + institution: EuCordisOrganizationSelectorSummary, + ): string => { + return institution.country + ' - ' + institution.city; + }; +} diff --git a/webapp/src/app/shared/ui/searchable-eu-project-type-select/searchable-eu-project-type-select.component.html b/webapp/src/app/shared/ui/searchable-eu-project-type-select/searchable-eu-project-type-select.component.html new file mode 100644 index 00000000..f2d998e4 --- /dev/null +++ b/webapp/src/app/shared/ui/searchable-eu-project-type-select/searchable-eu-project-type-select.component.html @@ -0,0 +1,11 @@ + diff --git a/webapp/src/app/shared/ui/searchable-eu-project-type-select/searchable-eu-project-type-select.component.scss b/webapp/src/app/shared/ui/searchable-eu-project-type-select/searchable-eu-project-type-select.component.scss new file mode 100644 index 00000000..e69de29b diff --git a/webapp/src/app/shared/ui/searchable-eu-project-type-select/searchable-eu-project-type-select.component.ts b/webapp/src/app/shared/ui/searchable-eu-project-type-select/searchable-eu-project-type-select.component.ts new file mode 100644 index 00000000..3a26e038 --- /dev/null +++ b/webapp/src/app/shared/ui/searchable-eu-project-type-select/searchable-eu-project-type-select.component.ts @@ -0,0 +1,57 @@ +import { Component, input, output } from '@angular/core'; +import { SearchableSelectComponent } from '../searchable-select/searchable-select.component'; +import { Observable } from 'rxjs'; + +export type ProjectType = { + id: string; + name: string; +}; + +export const projectTypes: ProjectType[] = [ + { id: 'h2020', name: 'Horizon 2020' }, + { id: 'heu', name: 'Horizon Europe' }, + { id: 'fp7', name: 'Framework Programme 7' }, +]; + +export const findprojectTypeById = (id: string): ProjectType | undefined => { + return projectTypes.find((projectType) => projectType.id === id); +}; + +type ProjectTypePage = { + elements?: ProjectType[]; + page?: number; + size?: number; + total?: number; +}; + +@Component({ + selector: 'app-searchable-eu-project-type-select', + imports: [SearchableSelectComponent], + templateUrl: './searchable-eu-project-type-select.component.html', + styleUrl: './searchable-eu-project-type-select.component.scss', +}) +export class SearchableEuProjectTypeSelectComponent { + label = input('Typen'); + selectedEuProjectTypes = input.required(); + + handleEuProjectTypeSelectChange = output(); + + fetchprojectTypes = (searchTerm: string): Observable => { + return new Observable((observer) => { + observer.next({ + elements: projectTypes.filter((projectType) => + projectType.name.toLowerCase().includes(searchTerm.toLowerCase()), + ), + }); + observer.complete(); + }); + }; + + getprojectTypeLabel = (projectType: ProjectType): string => { + return projectType.name; + }; + + getprojectTypeValue = (projectType: ProjectType): string => { + return projectType.id; + }; +}