Enhance ObjectProperty and ObjectChildTable components by introducing parentData prop for improved data handling in nested structures. Update related functions to utilize parentData for better context in calculations and rendering.

This commit is contained in:
Tom Butcher 2026-07-04 20:20:17 +01:00
parent bdb2327aac
commit 092b9ff4e4
2 changed files with 15 additions and 12 deletions

View File

@ -186,6 +186,7 @@ const ObjectChildTable = ({
{...property} {...property}
longId={false} longId={false}
objectData={record} objectData={record}
parentData={objectData}
isEditing={isEditing} isEditing={isEditing}
useFormItem={false} useFormItem={false}
name={undefined} name={undefined}

View File

@ -74,6 +74,7 @@ const ObjectProperty = ({
masterFilter = {}, masterFilter = {},
language = '', language = '',
objectData = null, objectData = null,
parentData = null,
objectType = 'unknown', objectType = 'unknown',
readOnly = false, readOnly = false,
disabled = false, disabled = false,
@ -100,50 +101,51 @@ const ObjectProperty = ({
...rest ...rest
}) => { }) => {
if (value && typeof value == 'function' && objectData) { if (value && typeof value == 'function' && objectData) {
value = value(objectData) value = value(objectData, parentData)
} }
if (max && typeof max == 'function' && objectData) { if (max && typeof max == 'function' && objectData) {
max = max(objectData) max = max(objectData, parentData)
} }
if (min && typeof min == 'function' && objectData) { if (min && typeof min == 'function' && objectData) {
min = min(objectData) min = min(objectData, parentData)
} }
if (objectType && typeof objectType == 'function' && objectData) { if (objectType && typeof objectType == 'function' && objectData) {
objectType = objectType(objectData) objectType = objectType(objectData, parentData)
} }
if (disabled && typeof disabled == 'function' && objectData) { if (disabled && typeof disabled == 'function' && objectData) {
disabled = disabled(objectData) disabled = disabled(objectData, parentData)
} }
if (empty && typeof empty == 'function' && objectData) { if (empty && typeof empty == 'function' && objectData) {
empty = empty(objectData) empty = empty(objectData, parentData)
} }
if (difference && typeof difference == 'function' && objectData) { if (difference && typeof difference == 'function' && objectData) {
difference = difference(objectData) difference = difference(objectData, parentData)
} }
if (prefix && typeof prefix == 'function' && objectData) { if (prefix && typeof prefix == 'function' && objectData) {
prefix = prefix(objectData) prefix = prefix(objectData, parentData)
} }
if (suffix && typeof suffix == 'function' && objectData) { if (suffix && typeof suffix == 'function' && objectData) {
suffix = suffix(objectData) suffix = suffix(objectData, parentData)
} }
if (masterFilter && typeof masterFilter == 'function' && objectData) { if (masterFilter && typeof masterFilter == 'function' && objectData) {
masterFilter = masterFilter(objectData) masterFilter = masterFilter(objectData, parentData)
} }
if (options && typeof options == 'function' && objectData) { if (options && typeof options == 'function' && objectData) {
options = options(objectData) options = options(objectData, parentData)
} }
if (readOnly && typeof readOnly == 'function' && objectData) { if (readOnly && typeof readOnly == 'function' && objectData) {
readOnly = readOnly(objectData) readOnly = readOnly(objectData, parentData)
} }
if (!value) { if (!value) {