Browse Source

Refactoring

pull/4117/head
Thomas Kaul 8 months ago
parent
commit
be592296d0
  1. 9
      apps/client/src/app/components/portfolio-summary/portfolio-summary.component.ts
  2. 6
      apps/client/src/app/core/notification/notification.service.ts

9
apps/client/src/app/components/portfolio-summary/portfolio-summary.component.ts

@ -54,16 +54,13 @@ export class PortfolioSummaryComponent implements OnChanges {
public onEditEmergencyFund() { public onEditEmergencyFund() {
this.notificationService.prompt({ this.notificationService.prompt({
confirmFn: (value) => { confirmFn: (value) => {
// If empty/deleted value by user, default to 0.
const emergencyFund = parseFloat(value.trim()) || 0; const emergencyFund = parseFloat(value.trim()) || 0;
if (emergencyFund >= 0) {
this.emergencyFundChanged.emit(emergencyFund); this.emergencyFundChanged.emit(emergencyFund);
}
}, },
confirmLabel: $localize`Save`, confirmLabel: $localize`Save`,
defaultValue: this.summary.emergencyFund?.total?.toString() ?? '0', defaultValue: this.summary.emergencyFund?.total?.toString() ?? '0',
title: $localize`Please enter the amount of your emergency fund:`, title: $localize`Please set the amount of your emergency fund.`
valueLabel: $localize`Emergency fund`
}); });
} }
} }

6
apps/client/src/app/core/notification/notification.service.ts

@ -101,9 +101,9 @@ export class NotificationService {
valueLabel: aParams.valueLabel valueLabel: aParams.valueLabel
}); });
return dialog.afterClosed().subscribe((value: string) => { return dialog.afterClosed().subscribe((result: string) => {
if (value !== undefined && isFunction(aParams.confirmFn)) { if (result !== 'discard' && isFunction(aParams.confirmFn)) {
aParams.confirmFn(value); aParams.confirmFn(result);
} }
}); });
} }

Loading…
Cancel
Save