Update objectData prop to use combined data for improved rendering.
This commit is contained in:
parent
1e7697f1d5
commit
b288ce327f
@ -1,8 +1,10 @@
|
|||||||
import { Spin, Descriptions, Flex } from 'antd'
|
import { Spin, Descriptions, Flex } from 'antd'
|
||||||
|
import { useState, useEffect } from 'react'
|
||||||
import { LoadingOutlined } from '@ant-design/icons'
|
import { LoadingOutlined } from '@ant-design/icons'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import ObjectProperty from './ObjectProperty'
|
import ObjectProperty from './ObjectProperty'
|
||||||
import { getModelProperties } from '../../../database/ObjectModels'
|
import { getModelProperties } from '../../../database/ObjectModels'
|
||||||
|
import merge from 'lodash/merge'
|
||||||
|
|
||||||
const ObjectInfo = ({
|
const ObjectInfo = ({
|
||||||
loading = false,
|
loading = false,
|
||||||
@ -27,6 +29,12 @@ const ObjectInfo = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const allItems = getModelProperties(type)
|
const allItems = getModelProperties(type)
|
||||||
|
|
||||||
|
const [combinedObjectData, setCombinedObjectData] = useState(objectData)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setCombinedObjectData((prev) => merge({}, prev, objectData))
|
||||||
|
}, [objectData])
|
||||||
|
|
||||||
// If properties array is empty, show all properties
|
// If properties array is empty, show all properties
|
||||||
// Otherwise, filter and order by the properties array
|
// Otherwise, filter and order by the properties array
|
||||||
let items
|
let items
|
||||||
@ -82,7 +90,8 @@ const ObjectInfo = ({
|
|||||||
{...item}
|
{...item}
|
||||||
{...objectPropertyProps}
|
{...objectPropertyProps}
|
||||||
isEditing={isEditing}
|
isEditing={isEditing}
|
||||||
objectData={objectData}
|
objectData={combinedObjectData}
|
||||||
|
showSince={true}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
span: item?.span || undefined
|
span: item?.span || undefined
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user