From 75084782b767f51f6158ada1984cf339c6302960 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 20 Jun 2022 16:42:21 +0200 Subject: Handle input error in custom input text --- .../app/shared/shared-forms/dynamic-form-field.component.html | 4 ++-- .../app/shared/shared-forms/dynamic-form-field.component.ts | 11 +++++++++++ client/src/app/shared/shared-forms/input-text.component.html | 3 +++ client/src/app/shared/shared-forms/input-text.component.ts | 1 + 4 files changed, 17 insertions(+), 2 deletions(-) (limited to 'client/src/app/shared/shared-forms') diff --git a/client/src/app/shared/shared-forms/dynamic-form-field.component.html b/client/src/app/shared/shared-forms/dynamic-form-field.component.html index 61f9ae8ff..2dd6cf4ad 100644 --- a/client/src/app/shared/shared-forms/dynamic-form-field.component.html +++ b/client/src/app/shared/shared-forms/dynamic-form-field.component.html @@ -18,7 +18,7 @@ - + @@ -40,7 +40,7 @@
-
+
{{ formErrors[setting.name] }}
diff --git a/client/src/app/shared/shared-forms/dynamic-form-field.component.ts b/client/src/app/shared/shared-forms/dynamic-form-field.component.ts index b63890797..e1a1f8034 100644 --- a/client/src/app/shared/shared-forms/dynamic-form-field.component.ts +++ b/client/src/app/shared/shared-forms/dynamic-form-field.component.ts @@ -12,4 +12,15 @@ export class DynamicFormFieldComponent { @Input() form: FormGroup @Input() formErrors: any @Input() setting: RegisterClientFormFieldOptions + + hasDedicatedFormError () { + const dedicated = new Set([ + 'input-checkbox', + 'input', + 'select', + 'input-textarea' + ]) + + return dedicated.has(this.setting.type) + } } diff --git a/client/src/app/shared/shared-forms/input-text.component.html b/client/src/app/shared/shared-forms/input-text.component.html index f890c4f02..abb53a085 100644 --- a/client/src/app/shared/shared-forms/input-text.component.html +++ b/client/src/app/shared/shared-forms/input-text.component.html @@ -3,6 +3,7 @@ [id]="inputId" [autocomplete]="autocomplete" [value]="value" [placeholder]="placeholder" [tabindex]="tabindex" [(ngModel)]="value" (ngModelChange)="update()" [readonly]="readonly" #input (click)="input.select()" (input)="update()" (change)="update()" [type]="inputType" class="form-control" + [ngClass]="{ 'input-error': formError }" />
+ +
{{ formError }}
diff --git a/client/src/app/shared/shared-forms/input-text.component.ts b/client/src/app/shared/shared-forms/input-text.component.ts index ed4637c17..d667ed663 100644 --- a/client/src/app/shared/shared-forms/input-text.component.ts +++ b/client/src/app/shared/shared-forms/input-text.component.ts @@ -24,6 +24,7 @@ export class InputTextComponent implements ControlValueAccessor { @Input() withCopy = false @Input() readonly = false @Input() show = false + @Input() formError: string constructor (private notifier: Notifier) { } -- cgit v1.2.3