added project type selector and institution selector for EU Cordis Projects
This commit is contained in:
+12
@@ -0,0 +1,12 @@
|
||||
<app-searchable-select
|
||||
inputPlaceholder="Institution suchen..."
|
||||
icon="apartment"
|
||||
[label]="label()"
|
||||
selectedLabel="Ausgewählte Institutionen"
|
||||
fetchedLabel="Gefundene Institutionen"
|
||||
[fetchElements]="fetchInstitutions"
|
||||
[selectedElements]="selectedInstitutions()"
|
||||
[getSelectLabel]="getInstitutionLabel"
|
||||
[getSelectValue]="getInstitutionValue"
|
||||
[getSelectDescription]="getInstitutionDescription"
|
||||
(handleSelectChange)="handleInstitutionSelectChange.emit($event)" />
|
||||
+48
@@ -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<string>('Institutionen');
|
||||
selectedInstitutions =
|
||||
input.required<EuCordisOrganizationSelectorSummary[]>();
|
||||
|
||||
handleInstitutionSelectChange = output<EuCordisOrganizationSelectorSummary>();
|
||||
|
||||
fetchInstitutions = (
|
||||
searchTerm: string,
|
||||
): Observable<EuCordisOrganizationSelectorPage> => {
|
||||
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;
|
||||
};
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
<app-searchable-select
|
||||
inputPlaceholder="Typ suchen..."
|
||||
icon="category"
|
||||
[label]="label()"
|
||||
selectedLabel="Ausgewählte Typen"
|
||||
fetchedLabel="Weitere Typen"
|
||||
[fetchElements]="fetchprojectTypes"
|
||||
[selectedElements]="selectedEuProjectTypes()"
|
||||
[getSelectLabel]="getprojectTypeLabel"
|
||||
[getSelectValue]="getprojectTypeValue"
|
||||
(handleSelectChange)="handleEuProjectTypeSelectChange.emit($event)" />
|
||||
+57
@@ -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<string>('Typen');
|
||||
selectedEuProjectTypes = input.required<ProjectType[]>();
|
||||
|
||||
handleEuProjectTypeSelectChange = output<ProjectType>();
|
||||
|
||||
fetchprojectTypes = (searchTerm: string): Observable<ProjectTypePage> => {
|
||||
return new Observable<ProjectTypePage>((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;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user