Browse Source

refactoring

pull/11319/head
mpetrov 2 years ago
parent
commit
c2c54e5104
  1. 20
      ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-slave-config/modbus-slave-config.component.ts

20
ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/modbus/modbus-slave-config/modbus-slave-config.component.ts

@ -127,8 +127,8 @@ export class ModbusSlaveConfigComponent implements ControlValueAccessor, Validat
this.observeValueChanges();
this.observeTypeChange();
this.observeShowSecurity();
this.observeFormEnable();
this.observeShowSecurity();
}
get protocolType(): ModbusProtocolType {
@ -173,15 +173,6 @@ export class ModbusSlaveConfigComponent implements ControlValueAccessor, Validat
});
}
private observeFormEnable(): void {
this.enableSlaveControl.valueChanges
.pipe(takeUntil(this.destroy$))
.subscribe(value => {
this.updateFormEnableState(value);
this.slaveConfigFormGroup.updateValueAndValidity({emitEvent: !!this.onChange});
});
}
private observeTypeChange(): void {
this.slaveConfigFormGroup.get('type').valueChanges
.pipe(takeUntil(this.destroy$))
@ -191,6 +182,15 @@ export class ModbusSlaveConfigComponent implements ControlValueAccessor, Validat
});
}
private observeFormEnable(): void {
this.enableSlaveControl.valueChanges
.pipe(takeUntil(this.destroy$))
.subscribe(value => {
this.updateFormEnableState(value);
this.slaveConfigFormGroup.updateValueAndValidity({emitEvent: !!this.onChange});
});
}
private updateMethodType(type: ModbusProtocolType): void {
if (this.slaveConfigFormGroup.get('method').value !== ModbusMethodType.RTU) {
this.slaveConfigFormGroup.get('method').patchValue(

Loading…
Cancel
Save