Enhance ObjectProperty component by adding AlertsDisplay for rendering alerts; update value checks for improved data handling and styling adjustments.

This commit is contained in:
Tom Butcher 2025-09-05 23:20:27 +01:00
parent 0eac407db4
commit e2a96949b3

View File

@ -38,6 +38,7 @@ import ObjectTypeSelect from './ObjectTypeSelect'
import ObjectTypeDisplay from './ObjectTypeDisplay' import ObjectTypeDisplay from './ObjectTypeDisplay'
import CodeBlockEditor from './CodeBlockEditor' import CodeBlockEditor from './CodeBlockEditor'
import StateDisplay from './StateDisplay' import StateDisplay from './StateDisplay'
import AlertsDisplay from './AlertsDisplay'
const { Text } = Typography const { Text } = Typography
@ -105,6 +106,10 @@ const ObjectProperty = ({
suffix = suffix(objectData) suffix = suffix(objectData)
} }
if (masterFilter && typeof masterFilter == 'function' && objectData) {
masterFilter = masterFilter(objectData)
}
if (!value) { if (!value) {
value = getPropertyValue(objectData, name) value = getPropertyValue(objectData, name)
} }
@ -116,7 +121,7 @@ const ObjectProperty = ({
formItemName = name ? name.split('.') : undefined formItemName = name ? name.split('.') : undefined
} }
var textParams = {} var textParams = { style: { whiteSpace: 'nowrap' } }
if (disabled == true) { if (disabled == true) {
textParams = { ...textParams, delete: true, type: 'secondary' } textParams = { ...textParams, delete: true, type: 'secondary' }
@ -317,7 +322,7 @@ const ObjectProperty = ({
) )
} }
case 'object': { case 'object': {
if (value && value.name) { if (value && value._id) {
return <ObjectDisplay object={value} objectType={objectType} /> return <ObjectDisplay object={value} objectType={objectType} />
} else { } else {
return ( return (
@ -385,9 +390,9 @@ const ObjectProperty = ({
) )
} }
} }
case 'mm': { case 'alerts': {
if (value != null) { if (value != null && value?.length != 0) {
return <Text {...textParams}>{`${value} mm`}</Text> return <AlertsDisplay alerts={value} />
} else { } else {
return ( return (
<Text type='secondary' {...textParams}> <Text type='secondary' {...textParams}>