Browse Source

OPC-UA Data mapping crushing on creating empty connector fix

pull/11174/head
mpetrov 2 years ago
parent
commit
474162bb05
  1. 16
      ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/mapping-table/mapping-table.component.ts

16
ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/mapping-table/mapping-table.component.ts

@ -33,6 +33,7 @@ import { debounceTime, distinctUntilChanged, map, take, takeUntil } from 'rxjs/o
import { import {
ControlValueAccessor, ControlValueAccessor,
FormBuilder, FormBuilder,
FormGroup,
NG_VALIDATORS, NG_VALIDATORS,
NG_VALUE_ACCESSOR, NG_VALUE_ACCESSOR,
UntypedFormArray, UntypedFormArray,
@ -206,13 +207,26 @@ export class MappingTableComponent implements ControlValueAccessor, Validator, A
if (isDefinedAndNotNull(index)) { if (isDefinedAndNotNull(index)) {
this.mappingFormGroup.at(index).patchValue(res); this.mappingFormGroup.at(index).patchValue(res);
} else { } else {
this.mappingFormGroup.push(this.fb.group(res)); this.mappingFormGroup.push(this.getMappedDialogDataFormGroup(res));
} }
this.mappingFormGroup.markAsDirty(); this.mappingFormGroup.markAsDirty();
} }
}); });
} }
private getMappedDialogDataFormGroup(mappingValue: MappingValue): FormGroup {
Object.keys(mappingValue).forEach(key => {
if (Array.isArray(mappingValue[key])) {
mappingValue = {
...mappingValue,
[key]: this.fb.control(mappingValue[key]),
};
}
});
return this.fb.group(mappingValue);
}
private updateTableData(value: ConnectorMapping[], textSearch?: string): void { private updateTableData(value: ConnectorMapping[], textSearch?: string): void {
let tableValue = value.map(mappingValue => this.getMappingValue(mappingValue)); let tableValue = value.map(mappingValue => this.getMappingValue(mappingValue));
if (textSearch) { if (textSearch) {

Loading…
Cancel
Save