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,6 +104,7 @@ export class JsonFormComponent implements OnInit, ControlValueAccessor, Validato | ||
104 | fullscreenFinishFn: () => void; | 104 | fullscreenFinishFn: () => void; |
105 | 105 | ||
106 | private propagateChange = null; | 106 | private propagateChange = null; |
107 | + private propagateChangePending = false; | ||
107 | 108 | ||
108 | constructor(public elementRef: ElementRef, | 109 | constructor(public elementRef: ElementRef, |
109 | private translate: TranslateService, | 110 | private translate: TranslateService, |
@@ -120,6 +121,12 @@ export class JsonFormComponent implements OnInit, ControlValueAccessor, Validato | @@ -120,6 +121,12 @@ export class JsonFormComponent implements OnInit, ControlValueAccessor, Validato | ||
120 | 121 | ||
121 | registerOnChange(fn: any): void { | 122 | registerOnChange(fn: any): void { |
122 | this.propagateChange = fn; | 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 | registerOnTouched(fn: any): void { | 132 | registerOnTouched(fn: any): void { |
@@ -154,7 +161,11 @@ export class JsonFormComponent implements OnInit, ControlValueAccessor, Validato | @@ -154,7 +161,11 @@ export class JsonFormComponent implements OnInit, ControlValueAccessor, Validato | ||
154 | updateView() { | 161 | updateView() { |
155 | if (this.data) { | 162 | if (this.data) { |
156 | this.data.model = this.model; | 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,9 +33,9 @@ export default ThingsboardBaseComponent => class<P extends JsonFormFieldProps> | ||
33 | } | 33 | } |
34 | 34 | ||
35 | componentDidMount() { | 35 | componentDidMount() { |
36 | - /* if (typeof this.state.value !== 'undefined') { | 36 | + if (typeof this.state.value !== 'undefined') { |
37 | this.props.onChange(this.props.form.key, this.state.value); | 37 | this.props.onChange(this.props.form.key, this.state.value); |
38 | - }*/ | 38 | + } |
39 | } | 39 | } |
40 | 40 | ||
41 | onChangeValidate(e, forceUpdate?: boolean) { | 41 | onChangeValidate(e, forceUpdate?: boolean) { |
@@ -28,7 +28,7 @@ class ThingsboardCheckbox extends React.Component<JsonFormFieldProps, JsonFormFi | @@ -28,7 +28,7 @@ class ThingsboardCheckbox extends React.Component<JsonFormFieldProps, JsonFormFi | ||
28 | <Checkbox | 28 | <Checkbox |
29 | name={this.props.form.key.slice(-1)[0] + ''} | 29 | name={this.props.form.key.slice(-1)[0] + ''} |
30 | value={this.props.form.key.slice(-1)[0]} | 30 | value={this.props.form.key.slice(-1)[0]} |
31 | - defaultChecked={this.props.value || false} | 31 | + checked={this.props.value || false} |
32 | disabled={this.props.form.readonly} | 32 | disabled={this.props.form.readonly} |
33 | onChange={(e, checked) => { | 33 | onChange={(e, checked) => { |
34 | this.props.onChangeValidate(e); | 34 | this.props.onChangeValidate(e); |
@@ -134,11 +134,6 @@ $previewSize: 100px !default; | @@ -134,11 +134,6 @@ $previewSize: 100px !default; | ||
134 | display: none; | 134 | display: none; |
135 | } | 135 | } |
136 | 136 | ||
137 | - span.tb-toggle-icon { | ||
138 | - padding-top: 12px; | ||
139 | - padding-bottom: 12px; | ||
140 | - } | ||
141 | - | ||
142 | .tb-button-toggle .tb-toggle-icon { | 137 | .tb-button-toggle .tb-toggle-icon { |
143 | display: inline-block; | 138 | display: inline-block; |
144 | width: 15px; | 139 | width: 15px; |
@@ -103,7 +103,6 @@ | @@ -103,7 +103,6 @@ | ||
103 | predefinedName="aggregation.group-interval"> | 103 | predefinedName="aggregation.group-interval"> |
104 | </tb-timeinterval> | 104 | </tb-timeinterval> |
105 | </div> | 105 | </div> |
106 | - <span fxFlex></span> | ||
107 | <div fxLayout="row" class="tb-panel-actions"> | 106 | <div fxLayout="row" class="tb-panel-actions"> |
108 | <span fxFlex></span> | 107 | <span fxFlex></span> |
109 | <button type="submit" | 108 | <button type="submit" |