diff --git a/portal-frontend/src/app/shared/owner-dialogs/owner-dialog/owner-dialog.component.ts b/portal-frontend/src/app/shared/owner-dialogs/owner-dialog/owner-dialog.component.ts index 8a2ec1c184..ceaec693ba 100644 --- a/portal-frontend/src/app/shared/owner-dialogs/owner-dialog/owner-dialog.component.ts +++ b/portal-frontend/src/app/shared/owner-dialogs/owner-dialog/owner-dialog.component.ts @@ -120,34 +120,32 @@ export class OwnerDialogComponent { const res = await this.data.ownerService.create(createDto); this.dialogRef.close(res); } else { - this.markFormGroupTouched(this.form) + this.form.markAllAsTouched() } } - private markFormGroupTouched(formGroup: FormGroup) { - Object.values(formGroup.controls).forEach(control => { - control.markAsTouched() - }) - } - async onClose() { this.dialogRef.close(); } async onSave() { - const document = await this.uploadPendingFile(this.pendingFile); - const updateDto: ApplicationOwnerUpdateDto = { - organizationName: this.organizationName.getRawValue(), - firstName: this.firstName.getRawValue(), - lastName: this.lastName.getRawValue(), - corporateSummaryUuid: document?.uuid, - email: this.email.getRawValue()!, - phoneNumber: this.phoneNumber.getRawValue()!, - typeCode: this.type.getRawValue()!, - }; - if (this.existingUuid) { - const res = await this.data.ownerService.update(this.existingUuid, updateDto); - this.dialogRef.close(res); + if (this.form.valid) { + const document = await this.uploadPendingFile(this.pendingFile); + const updateDto: ApplicationOwnerUpdateDto = { + organizationName: this.organizationName.getRawValue(), + firstName: this.firstName.getRawValue(), + lastName: this.lastName.getRawValue(), + corporateSummaryUuid: document?.uuid, + email: this.email.getRawValue()!, + phoneNumber: this.phoneNumber.getRawValue()!, + typeCode: this.type.getRawValue()!, + }; + if (this.existingUuid) { + const res = await this.data.ownerService.update(this.existingUuid, updateDto); + this.dialogRef.close(res); + } + } else { + this.form.markAllAsTouched() } }