Skip to content

Commit

Permalink
Use same error message in checkinbase dialog as in other dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
lkleisa committed Oct 20, 2023
1 parent ed36222 commit 668833b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<textarea matInput class="w-100" formControlName="changeInfo"></textarea>
<div *ngIf="isTouchedOrDirty('changeInfo')">
<mat-error *ngFor="let errorKey of getErrorKeysOfFormField('changeInfo')">
{{ getErrorMessage(errorKey).trim() }}
{{ errorMessages[errorKey.toUpperCase().trim()] }}
</mat-error>
</div>
</mat-form-field>
Expand All @@ -16,7 +16,7 @@
<textarea matInput formControlName="initiatives"></textarea>
<div *ngIf="isTouchedOrDirty('initiatives')">
<mat-error *ngFor="let errorKey of getErrorKeysOfFormField('initiatives')">
{{ getErrorMessage(errorKey).trim() }}
{{ errorMessages[errorKey.toUpperCase().trim()] }}
</mat-error>
</div>
</mat-form-field>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import errorMessages from '../../../../../assets/errors/error-messages.json';
export class CheckInBaseInformationsComponent {
@Input()
dialogForm!: FormGroup;
protected readonly errorMessages: any = errorMessages;

isTouchedOrDirty(name: string) {
return this.dialogForm.get(name)?.dirty || this.dialogForm.get(name)?.touched;
Expand All @@ -19,10 +20,4 @@ export class CheckInBaseInformationsComponent {
const errors = this.dialogForm.get(name)?.errors;
return errors == null ? [] : Object.keys(errors);
}

getErrorMessage(key: string) {
return errorMessages[key.toUpperCase() as keyof typeof errorMessages];
}

protected readonly errorMessages = errorMessages;
}

0 comments on commit 668833b

Please sign in to comment.