From cd83679232e5b398773a015aedfb7fe667a2192a Mon Sep 17 00:00:00 2001 From: Tom Butcher Date: Mon, 14 Jul 2025 23:09:56 +0100 Subject: [PATCH] Add support for additional property types in ObjectProperty component, including variance, markdown, and object list displays. Enhance prop types to accommodate functions for prefix, suffix, and object type. Update ObjectInfo to pass custom property props. --- .../Dashboard/common/ObjectInfo.jsx | 5 +- .../Dashboard/common/ObjectProperty.jsx | 65 +++++++++++++++++-- 2 files changed, 62 insertions(+), 8 deletions(-) diff --git a/src/components/Dashboard/common/ObjectInfo.jsx b/src/components/Dashboard/common/ObjectInfo.jsx index 397dff8..65818a5 100644 --- a/src/components/Dashboard/common/ObjectInfo.jsx +++ b/src/components/Dashboard/common/ObjectInfo.jsx @@ -13,6 +13,7 @@ const ObjectInfo = ({ properties = [], required = undefined, visibleProperties = {}, + objectPropertyProps = {}, ...rest }) => { const allItems = getModelProperties(type) @@ -55,6 +56,7 @@ const ObjectInfo = ({ children: ( @@ -91,7 +93,8 @@ ObjectInfo.propTypes = { type: PropTypes.string.isRequired, objectData: PropTypes.object, required: PropTypes.bool, - visibleProperties: PropTypes.object + visibleProperties: PropTypes.object, + objectPropertyProps: PropTypes.object } export default ObjectInfo diff --git a/src/components/Dashboard/common/ObjectProperty.jsx b/src/components/Dashboard/common/ObjectProperty.jsx index 0a73426..c702d88 100644 --- a/src/components/Dashboard/common/ObjectProperty.jsx +++ b/src/components/Dashboard/common/ObjectProperty.jsx @@ -37,6 +37,10 @@ import { getPropertyValue } from '../../../database/ObjectModels' import PropertyChanges from './PropertyChanges' import NetGrossDisplay from './NetGrossDisplay' import NetGrossInput from './NetGrossInput' +import ObjectList from './ObjectList' +import VarianceDisplay from './VarianceDisplay' +import OperationDisplay from './OperationDisplay' +import MarkdownDisplay from './MarkdownDisplay' const { Text } = Typography @@ -71,7 +75,7 @@ const ObjectProperty = ({ initial = false, ...rest }) => { - if (typeof value == 'function' && objectData) { + if (value && typeof value == 'function' && objectData) { value = value(objectData) } @@ -87,6 +91,14 @@ const ObjectProperty = ({ difference = difference(objectData) } + if (prefix && typeof prefix == 'function' && objectData) { + prefix = prefix(objectData) + } + + if (suffix && typeof suffix == 'function' && objectData) { + suffix = suffix(objectData) + } + if (!value) { value = getPropertyValue(objectData, name) } @@ -218,6 +230,19 @@ const ObjectProperty = ({ ) } } + case 'variance': { + if (value != null) { + return ( + + ) + } else { + return ( + + n/a + + ) + } + } case 'text': if (value != null && value != '') { return ( @@ -234,6 +259,16 @@ const ObjectProperty = ({ ) } + case 'markdown': + if (value != null && value != '') { + return + } else { + return ( + + n/a + + ) + } case 'email': if (value != null && value != '') { return @@ -265,6 +300,9 @@ const ObjectProperty = ({ ) } } + case 'objectList': { + return + } case 'state': { if (value && value?.type) { switch (objectType) { @@ -346,6 +384,17 @@ const ObjectProperty = ({ ) } } + case 'operation': { + if (value != null) { + return + } else { + return ( + + n/a + + ) + } + } case 'propertyChanges': { return } @@ -555,7 +604,7 @@ const ObjectProperty = ({ ) - case 'gcodefile': + case 'gcodeFile': return ( @@ -603,20 +652,22 @@ const ObjectProperty = ({ ObjectProperty.propTypes = { type: PropTypes.string.isRequired, - value: PropTypes.any, + value: PropTypes.oneOfType([PropTypes.any, PropTypes.func]), isEditing: PropTypes.bool, formItemProps: PropTypes.object, required: PropTypes.bool, name: PropTypes.string, - prefix: PropTypes.string, - suffix: PropTypes.string, + prefix: PropTypes.oneOfType([PropTypes.string, PropTypes.func]), + suffix: PropTypes.oneOfType([PropTypes.string, PropTypes.func]), min: PropTypes.number, max: PropTypes.number, step: PropTypes.number, showLabel: PropTypes.bool, - objectType: PropTypes.string, + objectType: PropTypes.oneOfType([PropTypes.string, PropTypes.func]), readOnly: PropTypes.bool, - disabled: PropTypes.bool + disabled: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]), + difference: PropTypes.oneOfType([PropTypes.any, PropTypes.func]), + objectData: PropTypes.object } export default ObjectProperty