From be592296d0a7afe18ff9ddcf4c0a5b08ab853d97 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Thu, 19 Dec 2024 20:14:41 +0100 Subject: [PATCH] Refactoring --- .../portfolio-summary/portfolio-summary.component.ts | 9 +++------ .../src/app/core/notification/notification.service.ts | 6 +++--- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/apps/client/src/app/components/portfolio-summary/portfolio-summary.component.ts b/apps/client/src/app/components/portfolio-summary/portfolio-summary.component.ts index 53bae9da4..3189a338f 100644 --- a/apps/client/src/app/components/portfolio-summary/portfolio-summary.component.ts +++ b/apps/client/src/app/components/portfolio-summary/portfolio-summary.component.ts @@ -54,16 +54,13 @@ export class PortfolioSummaryComponent implements OnChanges { public onEditEmergencyFund() { this.notificationService.prompt({ confirmFn: (value) => { - // If empty/deleted value by user, default to 0. const emergencyFund = parseFloat(value.trim()) || 0; - if (emergencyFund >= 0) { - this.emergencyFundChanged.emit(emergencyFund); - } + + this.emergencyFundChanged.emit(emergencyFund); }, confirmLabel: $localize`Save`, defaultValue: this.summary.emergencyFund?.total?.toString() ?? '0', - title: $localize`Please enter the amount of your emergency fund:`, - valueLabel: $localize`Emergency fund` + title: $localize`Please set the amount of your emergency fund.` }); } } diff --git a/apps/client/src/app/core/notification/notification.service.ts b/apps/client/src/app/core/notification/notification.service.ts index 4fec0a009..1b58db64a 100644 --- a/apps/client/src/app/core/notification/notification.service.ts +++ b/apps/client/src/app/core/notification/notification.service.ts @@ -101,9 +101,9 @@ export class NotificationService { valueLabel: aParams.valueLabel }); - return dialog.afterClosed().subscribe((value: string) => { - if (value !== undefined && isFunction(aParams.confirmFn)) { - aParams.confirmFn(value); + return dialog.afterClosed().subscribe((result: string) => { + if (result !== 'discard' && isFunction(aParams.confirmFn)) { + aParams.confirmFn(result); } }); }