import { Component, computed, input, OnInit, TemplateRef, viewChild, } from '@angular/core'; import { CordisEuProject, CordisEuProjectPage } from '../../../api'; import { DataTableComponent, GenericColumn, } from '../data-table/data-table.component'; import { RouterModule } from '@angular/router'; import { MatIconModule } from '@angular/material/icon'; import { MatButtonModule } from '@angular/material/button'; import { CurrencyPipe, DatePipe } from '@angular/common'; import { QueryParamPaginatorComponent } from '../query-param-paginator/query-param-paginator.component'; import { projectQueryParamKeys } from '../../../resolvers/dfg-projects.resolver'; @Component({ selector: 'app-eu-project-table', imports: [ DataTableComponent, RouterModule, MatIconModule, MatButtonModule, DatePipe, CurrencyPipe, QueryParamPaginatorComponent, ], templateUrl: './eu-project-table.component.html', styleUrl: './eu-project-table.component.scss', }) export class EuProjectTableComponent implements OnInit { page = input.required(); queryParamKeys = projectQueryParamKeys; elements = computed(() => this.page().elements ?? []); total = computed(() => this.page().total ?? 0); columns: GenericColumn[] = []; fundingStartTmp = viewChild.required>('fundingStartTmp'); fundingEndTmp = viewChild.required>('fundingEndTmp'); fundingAmountTmp = viewChild.required>('fundingAmountTmp'); actionsTmp = viewChild.required>('actionsTmp'); ngOnInit(): void { this.columns = [ { id: 'title', header: 'Titel', type: 'accessor', accessorKey: 'title' }, { id: 'startDate', header: 'Startdatum', type: 'display', cellTemplate: this.fundingStartTmp(), }, { id: 'endDate', header: 'Enddatum', type: 'display', cellTemplate: this.fundingEndTmp(), }, { id: 'ecMaxContribution', header: 'Förderbetrag (EU)', type: 'display', cellTemplate: this.fundingAmountTmp(), }, { id: 'actions', header: '', type: 'display', cellTemplate: this.actionsTmp(), }, ]; } }