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 () => {
|
const handleSubmit = async () => {
|
||||||
try {
|
try {
|
||||||
setSubmitLoading(true)
|
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')
|
messageApi.success('Object created successfully')
|
||||||
return newObject
|
return newObject
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@ -372,10 +372,21 @@ const ObjectForm = forwardRef(
|
|||||||
const startEditing = () => {
|
const startEditing = () => {
|
||||||
setIsEditing(true)
|
setIsEditing(true)
|
||||||
isEditingRef.current = 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({
|
onStateChangeRef.current({
|
||||||
isEditing: true,
|
isEditing: true,
|
||||||
objectData: { ...objectData, _isEditing: isEditingRef.current }
|
objectData: {
|
||||||
|
...objectData,
|
||||||
|
...computedValuesObject,
|
||||||
|
_isEditing: isEditingRef.current
|
||||||
|
}
|
||||||
})
|
})
|
||||||
lockObject(id, type)
|
lockObject(id, type)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user