fix: applied currency and date pipes where possible
LocationBasedServices/smartguide/pipeline/head This commit looks good
LocationBasedServices/smartguide/pipeline/head This commit looks good
This commit is contained in:
@@ -53,14 +53,16 @@
|
||||
<div class="metric-item">
|
||||
<mat-icon>calendar_today</mat-icon>
|
||||
<div class="metric-content">
|
||||
<strong>{{ getStartDate() || 'N/A' }}</strong>
|
||||
<strong>{{ bundProject.funding_start_date | date: 'dd.MM.yyyy' }}</strong>
|
||||
<span>Förderbeginn</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="metric-item">
|
||||
<mat-icon>event_busy</mat-icon>
|
||||
<div class="metric-content">
|
||||
<strong>{{ getFundingStatus(getEndDate()) }}</strong>
|
||||
<strong>{{
|
||||
getFundingStatus(bundProject.funding_end_date)
|
||||
}}</strong>
|
||||
<span>Förderende</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -77,7 +79,9 @@
|
||||
<div class="metric-item">
|
||||
<mat-icon>paid</mat-icon>
|
||||
<div class="metric-content">
|
||||
<strong>{{ getFundingAmountDisplay() }}</strong>
|
||||
<strong>{{
|
||||
bundProject.funding_amount | currency: 'EUR' : 'symbol' : '1.0-0' : 'de'
|
||||
}}</strong>
|
||||
<span>Fördersumme</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -351,7 +355,12 @@
|
||||
@if (bundProject.funding_amount) {
|
||||
<div class="detail-row">
|
||||
<dt>Fördersumme</dt>
|
||||
<dd>{{ getFundingAmountDisplay() }}</dd>
|
||||
<dd>
|
||||
{{
|
||||
bundProject.funding_amount
|
||||
| currency: 'EUR' : 'symbol' : '1.0-0' : 'de'
|
||||
}}
|
||||
</dd>
|
||||
</div>
|
||||
}
|
||||
@if (bundProject.funding_amount) {
|
||||
@@ -374,12 +383,15 @@
|
||||
<dt>Förderende</dt>
|
||||
<dd>{{ getFundingStatus(getEndDate()) }}</dd>
|
||||
</div> -->
|
||||
@if (getDuration()) {
|
||||
<div class="detail-row">
|
||||
<dt>Laufzeit</dt>
|
||||
<dd>{{ getDuration() }}</dd>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="detail-row">
|
||||
<dt>Laufzeit</dt>
|
||||
<dd>
|
||||
von {{ bundProject.funding_start_date | date: 'dd.MM.yyyy' }} bis
|
||||
{{ bundProject.funding_end_date | date: 'dd.MM.yyyy' }}
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
@if (bundProject.joint_project) {
|
||||
<div class="detail-row">
|
||||
<dt>Gemeinschaftsprojekt</dt>
|
||||
|
||||
@@ -4,7 +4,6 @@ import { CommonModule } from '@angular/common';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { BundProjectDetails } from '../../../api/model/bundProjectDetails';
|
||||
import { formatGermanDate } from '../../../resolvers/utils/formatters';
|
||||
|
||||
@Component({
|
||||
selector: 'app-bund-details',
|
||||
@@ -45,18 +44,6 @@ export class BundDetailsComponent implements OnInit {
|
||||
: `${fundingEndDate}`;
|
||||
}
|
||||
|
||||
formatCurrency(amount: number | null | undefined): string {
|
||||
if (amount === null || amount === undefined) return 'N/A';
|
||||
|
||||
// Format as Euro with thousands separators
|
||||
return new Intl.NumberFormat('de-DE', {
|
||||
style: 'currency',
|
||||
currency: 'EUR',
|
||||
minimumFractionDigits: 0,
|
||||
maximumFractionDigits: 0,
|
||||
}).format(amount);
|
||||
}
|
||||
|
||||
searchForPersonName(personName: string): void {
|
||||
this.router.navigate(['/persons'], {
|
||||
queryParams: {
|
||||
@@ -110,22 +97,7 @@ export class BundDetailsComponent implements OnInit {
|
||||
getAssociatedPersons(): string[] {
|
||||
return this.bundProject?.associated_persons || [];
|
||||
}
|
||||
getStartDate(): string {
|
||||
return formatGermanDate(this.bundProject?.funding_start_date ?? '');
|
||||
}
|
||||
|
||||
getEndDate(): string {
|
||||
return formatGermanDate(this.bundProject?.funding_end_date ?? '');
|
||||
}
|
||||
|
||||
getDuration(): string {
|
||||
const start = this.bundProject?.funding_start_date;
|
||||
const end = this.bundProject?.funding_end_date;
|
||||
|
||||
if (!start || !end) return '';
|
||||
|
||||
return `von ${formatGermanDate(start)} bis ${formatGermanDate(end)}`;
|
||||
}
|
||||
/**
|
||||
* All institutions as a simple list.
|
||||
*/
|
||||
@@ -140,13 +112,6 @@ export class BundDetailsComponent implements OnInit {
|
||||
return this.bundProject?.is_new === true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get display name for funding amount
|
||||
*/
|
||||
getFundingAmountDisplay(): string {
|
||||
if (!this.bundProject?.funding_amount) return 'N/A';
|
||||
return this.formatCurrency(this.bundProject.funding_amount);
|
||||
}
|
||||
getStatusDisplay(fundingEndDate: string | null | undefined): string {
|
||||
if (!fundingEndDate) return 'N/A';
|
||||
if (fundingEndDate === '2999') return 'Laufend';
|
||||
|
||||
@@ -72,14 +72,14 @@
|
||||
<div class="metric-item">
|
||||
<mat-icon>calendar_today</mat-icon>
|
||||
<div class="metric-content">
|
||||
<strong>{{ formatDate(euProject.startDate) || 'N/A' }}</strong>
|
||||
<strong>{{ euProject.startDate | date: 'dd.MM.yyyy' }}</strong>
|
||||
<span>Förderbeginn</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="metric-item">
|
||||
<mat-icon>event_busy</mat-icon>
|
||||
<div class="metric-content">
|
||||
<strong>{{ formatDate(euProject.endDate) || 'N/A' }}</strong>
|
||||
<strong>{{ euProject.endDate | date: 'dd.MM.yyyy' }}</strong>
|
||||
<span>Förderende</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -94,7 +94,10 @@
|
||||
<div class="metric-item">
|
||||
<mat-icon>euro_symbol</mat-icon>
|
||||
<div class="metric-content">
|
||||
<strong>{{ formatCurr(euProject.ecMaxContribution) }}</strong>
|
||||
<strong>{{
|
||||
euProject.ecMaxContribution
|
||||
| currency: 'EUR' : 'symbol' : '1.0-0' : 'de'
|
||||
}}</strong>
|
||||
<span>EU-Beitrag</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -103,7 +106,10 @@
|
||||
<div class="metric-item">
|
||||
<mat-icon>attach_money</mat-icon>
|
||||
<div class="metric-content">
|
||||
<strong>{{ formatCurr(euProject.totalCost) }}</strong>
|
||||
<strong>{{
|
||||
euProject.totalCost
|
||||
| currency: 'EUR' : 'symbol' : '1.0-0' : 'de'
|
||||
}}</strong>
|
||||
<span>Gesamtkosten</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -368,19 +374,29 @@
|
||||
@if (euProject.ecMaxContribution) {
|
||||
<div class="detail-row">
|
||||
<dt>Max. EU-Beitrag</dt>
|
||||
<dd>{{ formatCurr(euProject.ecMaxContribution) }}</dd>
|
||||
<dd>
|
||||
{{
|
||||
euProject.ecMaxContribution
|
||||
| currency: 'EUR' : 'symbol' : '1.0-0' : 'de'
|
||||
}}
|
||||
</dd>
|
||||
</div>
|
||||
}
|
||||
@if (euProject.totalCost) {
|
||||
<div class="detail-row">
|
||||
<dt>Gesamtkosten</dt>
|
||||
<dd>{{ formatCurr(euProject.totalCost) }}</dd>
|
||||
<dd>
|
||||
{{
|
||||
euProject.totalCost
|
||||
| currency: 'EUR' : 'symbol' : '1.0-0' : 'de'
|
||||
}}
|
||||
</dd>
|
||||
</div>
|
||||
}
|
||||
@if (euProject.ecSignatureDate) {
|
||||
<div class="detail-row">
|
||||
<dt>EU-Unterzeichnung</dt>
|
||||
<dd>{{ formatDate(euProject.ecSignatureDate) }}</dd>
|
||||
<dd>{{ euProject.ecSignatureDate | date: 'dd.MM.yyyy' }}</dd>
|
||||
</div>
|
||||
}
|
||||
@if (euProject.nature) {
|
||||
@@ -402,22 +418,21 @@
|
||||
<div class="detail-row">
|
||||
<dt>Laufzeit</dt>
|
||||
<dd>
|
||||
{{
|
||||
getDuration(euProject.startDate, euProject.endDate) ||
|
||||
'N/A'
|
||||
}}
|
||||
von
|
||||
{{ euProject.startDate | date: 'dd.MM.yyyy' }}
|
||||
bis {{ euProject.endDate | date: 'dd.MM.yyyy' }}
|
||||
</dd>
|
||||
</div>
|
||||
@if (euProject.ecSignatureDate) {
|
||||
<div class="detail-row">
|
||||
<dt>EU-Unterzeichnung</dt>
|
||||
<dd>{{ formatDate(euProject.ecSignatureDate) }}</dd>
|
||||
<dd>{{ euProject.ecSignatureDate | date: 'dd.MM.yyyy' }}</dd>
|
||||
</div>
|
||||
}
|
||||
@if (euProject.contentUpdateDate) {
|
||||
<div class="detail-row">
|
||||
<dt>Letzte Aktualisierung</dt>
|
||||
<dd>{{ formatDate(euProject.contentUpdateDate) }}</dd>
|
||||
<dd>{{ euProject.contentUpdateDate | date: 'dd.MM.yyyy' }}</dd>
|
||||
</div>
|
||||
}
|
||||
@if (euProject.grantDoi) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// eu-details.component.ts (refactored)
|
||||
import { Component, OnInit, inject, OnDestroy } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { CommonModule, CurrencyPipe } from '@angular/common';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatChipsModule } from '@angular/material/chips';
|
||||
@@ -15,10 +15,7 @@ import { OrganizationsTableComponent } from './organizations-table/organizations
|
||||
import { PublicationsTableComponent } from './publications-table/publications-table.component';
|
||||
import { PatentsCardsComponent } from './patents-cards/patents-cards.component';
|
||||
import { DeliverablesCardsComponent } from './deliverables-cards/deliverables-cards.component';
|
||||
import {
|
||||
formatCurrency,
|
||||
formatGermanDate,
|
||||
} from '../../../resolvers/utils/formatters';
|
||||
|
||||
export type TabType =
|
||||
| 'overview'
|
||||
| 'organizations'
|
||||
@@ -42,6 +39,7 @@ export type TabType =
|
||||
PublicationsTableComponent,
|
||||
PatentsCardsComponent,
|
||||
DeliverablesCardsComponent,
|
||||
CurrencyPipe,
|
||||
],
|
||||
templateUrl: './eu-details.component.html',
|
||||
styleUrl: './eu-details.component.scss',
|
||||
@@ -325,25 +323,6 @@ export class EuDetailsComponent implements OnInit, OnDestroy {
|
||||
return end >= now ? 'Laufend' : 'Abgeschlossen';
|
||||
}
|
||||
|
||||
getDuration(start: string | undefined, end: string | undefined): string {
|
||||
if (!start || !end) return '';
|
||||
return `von ${formatGermanDate(start)} bis ${formatGermanDate(end)}`;
|
||||
}
|
||||
|
||||
formatDate(date: string | undefined): string | undefined {
|
||||
if (date) {
|
||||
return formatGermanDate(date);
|
||||
}
|
||||
return date;
|
||||
}
|
||||
|
||||
formatCurr(value: number | undefined | null): string | null | undefined {
|
||||
if (value) {
|
||||
return formatCurrency(value);
|
||||
}
|
||||
return String(value);
|
||||
}
|
||||
|
||||
getStatusColor(status: string | null | undefined): string {
|
||||
if (!status) return '#95a5a6';
|
||||
|
||||
|
||||
+5
-3
@@ -43,7 +43,9 @@
|
||||
<img
|
||||
alt=""
|
||||
class="country-flag"
|
||||
[src]="`https://flagcdn.io/${getSvgByCountryCode(org.country)}.svg`"
|
||||
[src]="
|
||||
`https://flagcdn.io/${getSvgByCountryCode(org.country)}.svg`
|
||||
"
|
||||
height="10" />
|
||||
</span>
|
||||
} @else {
|
||||
@@ -58,7 +60,7 @@
|
||||
<td mat-cell *matCellDef="let org">
|
||||
@if (org.ecContribution) {
|
||||
<span class="currency-value">{{
|
||||
formatCurr(org.ecContribution)
|
||||
org.ecContribution | currency: 'EUR' : 'symbol' : '1.0-0' : 'de'
|
||||
}}</span>
|
||||
} @else {
|
||||
<span class="empty-value">—</span>
|
||||
@@ -118,4 +120,4 @@
|
||||
</table>
|
||||
</div>
|
||||
</mat-card>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+2
-8
@@ -4,10 +4,10 @@ import { Router } from '@angular/router';
|
||||
import { MatIcon } from '@angular/material/icon';
|
||||
import { MatCard } from '@angular/material/card';
|
||||
import { HEUOrganization } from '../../../../../api';
|
||||
import { formatCurrency } from '../../../../../resolvers/utils/formatters';
|
||||
import { CurrencyPipe } from '@angular/common';
|
||||
@Component({
|
||||
selector: 'app-organizations-table',
|
||||
imports: [MatTableModule, MatIcon, MatCard],
|
||||
imports: [MatTableModule, MatIcon, MatCard, CurrencyPipe],
|
||||
templateUrl: './organizations-table.component.html',
|
||||
styleUrl: './organizations-table.component.scss',
|
||||
})
|
||||
@@ -46,10 +46,4 @@ export class OrganizationsTableComponent {
|
||||
getOrgsCount(): number {
|
||||
return this.orgs?.length || 0;
|
||||
}
|
||||
formatCurr(value: number | undefined | null) {
|
||||
if (value) {
|
||||
return formatCurrency(value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,8 +62,8 @@
|
||||
<mat-divider />
|
||||
<div class="card-metadata">
|
||||
<span
|
||||
>Von {{ fundingProject.start_date | date }} bis
|
||||
{{ fundingProject.end_date | date }}</span
|
||||
>Von {{ fundingProject.start_date | date: 'dd.MM.yyyy' }} bis
|
||||
{{ fundingProject.end_date | date: 'dd.MM.yyyy' }}</span
|
||||
>
|
||||
</div>
|
||||
<mat-divider />
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
export function formatGermanDate(dateString: string): string {
|
||||
if (!dateString) return '';
|
||||
|
||||
return new Intl.DateTimeFormat('de-DE', {
|
||||
day: 'numeric',
|
||||
month: 'long',
|
||||
year: 'numeric',
|
||||
}).format(new Date(dateString));
|
||||
}
|
||||
|
||||
export function formatCurrency(amount: number | null | undefined): string {
|
||||
if (amount === null || amount === undefined) return 'N/A';
|
||||
|
||||
return new Intl.NumberFormat('de-DE', {
|
||||
style: 'currency',
|
||||
currency: 'EUR',
|
||||
minimumFractionDigits: 0,
|
||||
maximumFractionDigits: 0,
|
||||
}).format(amount);
|
||||
}
|
||||
Reference in New Issue
Block a user