|
|
|
@ -34,8 +34,12 @@ import { |
|
|
|
ControlValueAccessor, |
|
|
|
FormArray, |
|
|
|
FormBuilder, |
|
|
|
NG_VALIDATORS, |
|
|
|
NG_VALUE_ACCESSOR, |
|
|
|
UntypedFormControl, |
|
|
|
UntypedFormGroup, |
|
|
|
ValidationErrors, |
|
|
|
Validator, |
|
|
|
} from '@angular/forms'; |
|
|
|
import { |
|
|
|
ModbusMasterConfig, |
|
|
|
@ -58,12 +62,17 @@ import { TbTableDatasource } from '@shared/components/table/table-datasource.abs |
|
|
|
provide: NG_VALUE_ACCESSOR, |
|
|
|
useExisting: forwardRef(() => ModbusMasterTableComponent), |
|
|
|
multi: true |
|
|
|
}, |
|
|
|
{ |
|
|
|
provide: NG_VALIDATORS, |
|
|
|
useExisting: forwardRef(() => ModbusMasterTableComponent), |
|
|
|
multi: true |
|
|
|
} |
|
|
|
], |
|
|
|
standalone: true, |
|
|
|
imports: [CommonModule, SharedModule] |
|
|
|
}) |
|
|
|
export class ModbusMasterTableComponent implements ControlValueAccessor, AfterViewInit, OnInit, OnDestroy { |
|
|
|
export class ModbusMasterTableComponent implements ControlValueAccessor, Validator, AfterViewInit, OnInit, OnDestroy { |
|
|
|
|
|
|
|
@ViewChild('searchInput') searchInputField: ElementRef; |
|
|
|
|
|
|
|
@ -130,6 +139,12 @@ export class ModbusMasterTableComponent implements ControlValueAccessor, AfterVi |
|
|
|
this.pushDataAsFormArrays(master.slaves); |
|
|
|
} |
|
|
|
|
|
|
|
validate(masterControl: UntypedFormControl): ValidationErrors | null { |
|
|
|
return masterControl.parent.get('slave').enabled || this.slaves.controls.length ? null : { |
|
|
|
slavesFormGroup: {valid: false} |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
enterFilterMode(): void { |
|
|
|
this.textSearchMode = true; |
|
|
|
this.cdr.detectChanges(); |
|
|
|
|