From 7a90ad1f3e90c481fe188459d22fa6f2850c7de5 Mon Sep 17 00:00:00 2001 From: Nicolas Fedor Date: Sat, 13 Apr 2024 19:59:22 +0100 Subject: [PATCH] Address Comments --- ...eate-or-update-account-dialog.component.ts | 18 ++-- .../create-or-update-account-dialog.html | 28 ------- ...ate-or-update-activity-dialog.component.ts | 18 ++-- .../create-or-update-activity-dialog.html | 83 ------------------- apps/client/src/app/util/form.util.ts | 25 ++++++ apps/client/src/app/util/validation.util.ts | 27 ------ 6 files changed, 47 insertions(+), 152 deletions(-) create mode 100644 apps/client/src/app/util/form.util.ts delete mode 100644 apps/client/src/app/util/validation.util.ts diff --git a/apps/client/src/app/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.component.ts b/apps/client/src/app/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.component.ts index fb7fe2cb0..e64daf14c 100644 --- a/apps/client/src/app/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.component.ts +++ b/apps/client/src/app/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.component.ts @@ -1,7 +1,7 @@ import { CreateAccountDto } from '@ghostfolio/api/app/account/create-account.dto'; import { UpdateAccountDto } from '@ghostfolio/api/app/account/update-account.dto'; import { DataService } from '@ghostfolio/client/services/data.service'; -import { validateObjectForForm } from '@ghostfolio/client/util/validation.util'; +import { validateObjectForForm } from '@ghostfolio/client/util/form.util'; import { Currency } from '@ghostfolio/common/interfaces'; import { @@ -116,14 +116,18 @@ export class CreateOrUpdateAccountDialog implements OnDestroy { if (this.data.account.id) { (account as UpdateAccountDto).id = this.data.account.id; - validateObjectForForm(account, UpdateAccountDto, this.accountForm, () => { - this.dialogRef.close({ account }); - }); + validateObjectForForm(account, UpdateAccountDto, this.accountForm).then( + () => { + this.dialogRef.close({ account }); + } + ); } else { delete (account as CreateAccountDto).id; - validateObjectForForm(account, CreateAccountDto, this.accountForm, () => { - this.dialogRef.close({ account }); - }); + validateObjectForForm(account, CreateAccountDto, this.accountForm).then( + () => { + this.dialogRef.close({ account }); + } + ); } } diff --git a/apps/client/src/app/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.html b/apps/client/src/app/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.html index 007835a21..e2981462f 100644 --- a/apps/client/src/app/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.html +++ b/apps/client/src/app/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.html @@ -18,9 +18,6 @@ matInput (keydown.enter)="$event.stopPropagation()" /> - - {{ accountForm.controls['name'].errors?.validationError }} -
@@ -30,11 +27,6 @@ formControlName="currency" [currencies]="currencies" /> - - {{ accountForm.controls['currency'].errors?.validationError }} -
@@ -49,11 +41,6 @@ {{ accountForm.controls['currency']?.value?.value }} - - {{ accountForm.controls['balance'].errors?.validationError }} -
@@ -84,11 +71,6 @@ } - - {{ accountForm.controls['platformId'].errors?.validationError }} -
@@ -101,11 +83,6 @@ matInput (keyup.enter)="$event.stopPropagation()" > - - {{ accountForm.controls['comment'].errors?.validationError }} -
@@ -118,11 +95,6 @@ Account ID - - {{ accountForm.controls['accountId'].errors?.validationError }} -
} diff --git a/apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.component.ts b/apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.component.ts index 3d78802ba..25264cb56 100644 --- a/apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.component.ts +++ b/apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.component.ts @@ -1,7 +1,7 @@ import { CreateOrderDto } from '@ghostfolio/api/app/order/create-order.dto'; import { UpdateOrderDto } from '@ghostfolio/api/app/order/update-order.dto'; import { DataService } from '@ghostfolio/client/services/data.service'; -import { validateObjectForForm } from '@ghostfolio/client/util/validation.util'; +import { validateObjectForForm } from '@ghostfolio/client/util/form.util'; import { getDateFormatString } from '@ghostfolio/common/helper'; import { translate } from '@ghostfolio/ui/i18n'; @@ -477,15 +477,19 @@ export class CreateOrUpdateActivityDialog implements OnDestroy { if (this.data.activity.id) { (activity as UpdateOrderDto).id = this.data.activity.id; - validateObjectForForm(activity, UpdateOrderDto, this.activityForm, () => { - this.dialogRef.close({ activity }); - }); + validateObjectForForm(activity, UpdateOrderDto, this.activityForm).then( + () => { + this.dialogRef.close({ activity }); + } + ); } else { (activity as CreateOrderDto).updateAccountBalance = this.activityForm.controls['updateAccountBalance'].value; - validateObjectForForm(activity, CreateOrderDto, this.activityForm, () => { - this.dialogRef.close({ activity }); - }); + validateObjectForForm(activity, CreateOrderDto, this.activityForm).then( + () => { + this.dialogRef.close({ activity }); + } + ); } } diff --git a/apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.html b/apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.html index cc999d3bf..b868badb8 100644 --- a/apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.html +++ b/apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.html @@ -71,11 +71,6 @@ > - - {{ activityForm.controls['type'].errors?.validationError }} -
@@ -108,11 +103,6 @@
- - {{ activityForm.controls['accountId'].errors?.validationError }} -
@@ -134,11 +124,6 @@ formControlName="searchSymbol" [isLoading]="isLoading" /> - - {{ activityForm.controls['searchSymbol'].errors?.validationError }} -
Name - - {{ activityForm.controls['name'].errors?.validationError }} -
@@ -167,11 +147,6 @@ currency }} - - {{ activityForm.controls['currency'].errors?.validationError }} -
@@ -197,11 +172,6 @@ /> - - {{ activityForm.controls['date'].errors?.validationError }} -
Quantity - - {{ activityForm.controls['quantity'].errors?.validationError }} -
- Oops! Could not get the historical exchange rate - from - {{ - activityForm.controls['date']?.value | date: defaultDateFormat - }}