Used computed on object save.
This commit is contained in:
parent
3b3d4e3ff0
commit
bbadede777
@ -152,7 +152,10 @@ const NewObjectForm = ({ type, style, defaultValues = {}, children }) => {
|
||||
const handleSubmit = async () => {
|
||||
try {
|
||||
setSubmitLoading(true)
|
||||
const newObject = await createObject(type, objectData)
|
||||
const computedEntries = calculateComputedValues(objectData, model)
|
||||
const computedValuesObject = buildObjectFromEntries(computedEntries)
|
||||
const computedObjectData = merge({}, objectData, computedValuesObject)
|
||||
const newObject = await createObject(type, computedObjectData)
|
||||
messageApi.success('Object created successfully')
|
||||
return newObject
|
||||
} catch (err) {
|
||||
|
||||
@ -372,10 +372,21 @@ const ObjectForm = forwardRef(
|
||||
const startEditing = () => {
|
||||
setIsEditing(true)
|
||||
isEditingRef.current = true
|
||||
setObjectData((prev) => ({ ...prev, _isEditing: isEditingRef.current }))
|
||||
const computedEntries = calculateComputedValues(objectData, model)
|
||||
const computedValuesObject = buildObjectFromEntries(computedEntries)
|
||||
setObjectData((prev) => ({
|
||||
...prev,
|
||||
...computedValuesObject,
|
||||
_isEditing: isEditingRef.current
|
||||
}))
|
||||
console.log('calculatedEntries', computedValuesObject)
|
||||
onStateChangeRef.current({
|
||||
isEditing: true,
|
||||
objectData: { ...objectData, _isEditing: isEditingRef.current }
|
||||
objectData: {
|
||||
...objectData,
|
||||
...computedValuesObject,
|
||||
_isEditing: isEditingRef.current
|
||||
}
|
||||
})
|
||||
lockObject(id, type)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user