diff --git a/ui-ngx/src/app/shared/components/json-form/json-form.component.ts b/ui-ngx/src/app/shared/components/json-form/json-form.component.ts index ca07c1e6eb..31e0f4282f 100644 --- a/ui-ngx/src/app/shared/components/json-form/json-form.component.ts +++ b/ui-ngx/src/app/shared/components/json-form/json-form.component.ts @@ -104,6 +104,7 @@ export class JsonFormComponent implements OnInit, ControlValueAccessor, Validato fullscreenFinishFn: () => void; private propagateChange = null; + private propagateChangePending = false; constructor(public elementRef: ElementRef, private translate: TranslateService, @@ -120,6 +121,12 @@ export class JsonFormComponent implements OnInit, ControlValueAccessor, Validato registerOnChange(fn: any): void { this.propagateChange = fn; + if (this.propagateChangePending) { + this.propagateChangePending = false; + setTimeout(() => { + this.propagateChange(this.data); + }, 0); + } } registerOnTouched(fn: any): void { @@ -154,7 +161,11 @@ export class JsonFormComponent implements OnInit, ControlValueAccessor, Validato updateView() { if (this.data) { this.data.model = this.model; - this.propagateChange(this.data); + if (this.propagateChange) { + this.propagateChange(this.data); + } else { + this.propagateChangePending = true; + } } } diff --git a/ui-ngx/src/app/shared/components/json-form/react/json-form-base-component.tsx b/ui-ngx/src/app/shared/components/json-form/react/json-form-base-component.tsx index b033271d1d..440e71c7a3 100644 --- a/ui-ngx/src/app/shared/components/json-form/react/json-form-base-component.tsx +++ b/ui-ngx/src/app/shared/components/json-form/react/json-form-base-component.tsx @@ -33,9 +33,9 @@ export default ThingsboardBaseComponent => class
}
componentDidMount() {
- /* if (typeof this.state.value !== 'undefined') {
+ if (typeof this.state.value !== 'undefined') {
this.props.onChange(this.props.form.key, this.state.value);
- }*/
+ }
}
onChangeValidate(e, forceUpdate?: boolean) {
diff --git a/ui-ngx/src/app/shared/components/json-form/react/json-form-checkbox.tsx b/ui-ngx/src/app/shared/components/json-form/react/json-form-checkbox.tsx
index d0fe753e20..88fcc4be54 100644
--- a/ui-ngx/src/app/shared/components/json-form/react/json-form-checkbox.tsx
+++ b/ui-ngx/src/app/shared/components/json-form/react/json-form-checkbox.tsx
@@ -28,7 +28,7 @@ class ThingsboardCheckbox extends React.Component