From ce3d929fecf2a6dd8e15834b8babbe9f184d315a Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Thu, 23 Dec 2021 15:50:47 +0200 Subject: [PATCH] Fix json form default values handling --- .../json-form/react/json-form-base-component.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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 17885e7c50..f0f5456191 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 @@ -16,6 +16,7 @@ import * as React from 'react'; import JsonFormUtils from './json-form-utils'; import { JsonFormFieldProps, JsonFormFieldState } from '@shared/components/json-form/react/json-form.models'; +import { isDefinedAndNotNull } from '@core/utils'; export default ThingsboardBaseComponent => class

extends React.Component { @@ -96,13 +97,13 @@ export default ThingsboardBaseComponent => class

} } } else { - if (!value && typeof this.props.form.default !== 'undefined') { + if (!value && isDefinedAndNotNull(this.props.form.default)) { value = this.props.form.default; } - if (!value && this.props.form.schema && typeof this.props.form.schema.default !== 'undefined') { + if (!value && this.props.form.schema && isDefinedAndNotNull(this.props.form.schema.default)) { value = this.props.form.schema.default; } - if (!value && this.props.form.titleMap && typeof this.props.form.titleMap[0].value !== 'undefined') { + if (!value && this.props.form.titleMap && isDefinedAndNotNull(this.props.form.titleMap[0].value)) { value = this.props.form.titleMap[0].value; } }