Commit 7bc1e2c58efe36eb798ef4a15758f77a526d68a1
1 parent
87ade8ad
JSON form component improvements. Fix timewindow panel
Showing
5 changed files
with
15 additions
and
10 deletions
... | ... | @@ -104,6 +104,7 @@ export class JsonFormComponent implements OnInit, ControlValueAccessor, Validato |
104 | 104 | fullscreenFinishFn: () => void; |
105 | 105 | |
106 | 106 | private propagateChange = null; |
107 | + private propagateChangePending = false; | |
107 | 108 | |
108 | 109 | constructor(public elementRef: ElementRef, |
109 | 110 | private translate: TranslateService, |
... | ... | @@ -120,6 +121,12 @@ export class JsonFormComponent implements OnInit, ControlValueAccessor, Validato |
120 | 121 | |
121 | 122 | registerOnChange(fn: any): void { |
122 | 123 | this.propagateChange = fn; |
124 | + if (this.propagateChangePending) { | |
125 | + this.propagateChangePending = false; | |
126 | + setTimeout(() => { | |
127 | + this.propagateChange(this.data); | |
128 | + }, 0); | |
129 | + } | |
123 | 130 | } |
124 | 131 | |
125 | 132 | registerOnTouched(fn: any): void { |
... | ... | @@ -154,7 +161,11 @@ export class JsonFormComponent implements OnInit, ControlValueAccessor, Validato |
154 | 161 | updateView() { |
155 | 162 | if (this.data) { |
156 | 163 | this.data.model = this.model; |
157 | - this.propagateChange(this.data); | |
164 | + if (this.propagateChange) { | |
165 | + this.propagateChange(this.data); | |
166 | + } else { | |
167 | + this.propagateChangePending = true; | |
168 | + } | |
158 | 169 | } |
159 | 170 | } |
160 | 171 | ... | ... |
... | ... | @@ -33,9 +33,9 @@ export default ThingsboardBaseComponent => class<P extends JsonFormFieldProps> |
33 | 33 | } |
34 | 34 | |
35 | 35 | componentDidMount() { |
36 | - /* if (typeof this.state.value !== 'undefined') { | |
36 | + if (typeof this.state.value !== 'undefined') { | |
37 | 37 | this.props.onChange(this.props.form.key, this.state.value); |
38 | - }*/ | |
38 | + } | |
39 | 39 | } |
40 | 40 | |
41 | 41 | onChangeValidate(e, forceUpdate?: boolean) { | ... | ... |
... | ... | @@ -28,7 +28,7 @@ class ThingsboardCheckbox extends React.Component<JsonFormFieldProps, JsonFormFi |
28 | 28 | <Checkbox |
29 | 29 | name={this.props.form.key.slice(-1)[0] + ''} |
30 | 30 | value={this.props.form.key.slice(-1)[0]} |
31 | - defaultChecked={this.props.value || false} | |
31 | + checked={this.props.value || false} | |
32 | 32 | disabled={this.props.form.readonly} |
33 | 33 | onChange={(e, checked) => { |
34 | 34 | this.props.onChangeValidate(e); | ... | ... |