From 89f13592f000aa269bbda3cc06cdef9c09d73691 Mon Sep 17 00:00:00 2001 From: Dmitriymush Date: Thu, 28 Mar 2024 11:03:30 +0200 Subject: [PATCH] UI: added error state matcher for gateway connectors config --- .../gateway/gateway-connectors.component.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-connectors.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-connectors.component.ts index 2a70d60b02..4ad9fce364 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-connectors.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-connectors.component.ts @@ -17,7 +17,15 @@ import { AfterViewInit, ChangeDetectorRef, Component, ElementRef, Input, NgZone, ViewChild } from '@angular/core'; import { Store } from '@ngrx/store'; import { AppState } from '@core/core.state'; -import { FormBuilder, FormGroup, UntypedFormControl, ValidatorFn, Validators } from '@angular/forms'; +import { + FormBuilder, + FormControl, + FormGroup, + FormGroupDirective, NgForm, + UntypedFormControl, + ValidatorFn, + Validators +} from '@angular/forms'; import { EntityId } from '@shared/models/id/entity-id'; import { AttributeService } from '@core/http/attribute.service'; import { TranslateService } from '@ngx-translate/core'; @@ -51,10 +59,18 @@ import { import { MatDialog } from '@angular/material/dialog'; import { AddConnectorDialogComponent } from '@home/components/widget/lib/gateway/dialog/add-connector-dialog.component'; import { takeUntil } from 'rxjs/operators'; +import { ErrorStateMatcher } from '@angular/material/core'; + +export class ForceErrorStateMatcher implements ErrorStateMatcher { + isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean { + return (control && control.invalid); + } +} @Component({ selector: 'tb-gateway-connector', templateUrl: './gateway-connectors.component.html', + providers: [{ provide: ErrorStateMatcher, useClass: ForceErrorStateMatcher }], styleUrls: ['./gateway-connectors.component.scss'] }) export class GatewayConnectorComponent extends PageComponent implements AfterViewInit {