fix(save-record): differentiate between creation and updating based on record.isNew (#3620)
This commit is contained in:
parent
4716c13d81
commit
5ca1827e7e
@ -11,6 +11,7 @@ import { useReactToPrint } from 'react-to-print';
|
|||||||
import {
|
import {
|
||||||
AssociationFilter,
|
AssociationFilter,
|
||||||
useCollectionManager,
|
useCollectionManager,
|
||||||
|
useCollectionRecord,
|
||||||
useDataSourceHeaders,
|
useDataSourceHeaders,
|
||||||
useFormActiveFields,
|
useFormActiveFields,
|
||||||
useFormBlockContext,
|
useFormBlockContext,
|
||||||
@ -180,6 +181,8 @@ export function useCollectValuesToSubmit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const useCreateActionProps = () => {
|
export const useCreateActionProps = () => {
|
||||||
|
const filterByTk = useFilterByTk();
|
||||||
|
const record = useCollectionRecord();
|
||||||
const form = useForm();
|
const form = useForm();
|
||||||
const { field, resource, __parent } = useBlockRequestContext();
|
const { field, resource, __parent } = useBlockRequestContext();
|
||||||
const { setVisible } = useActionContext();
|
const { setVisible } = useActionContext();
|
||||||
@ -191,7 +194,7 @@ export const useCreateActionProps = () => {
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { updateAssociationValues } = useFormBlockContext();
|
const { updateAssociationValues } = useFormBlockContext();
|
||||||
const collectValues = useCollectValuesToSubmit();
|
const collectValues = useCollectValuesToSubmit();
|
||||||
const action = actionField.componentProps.saveMode || 'create';
|
const action = record.isNew ? 'create' : 'update';
|
||||||
const filterKeys = actionField.componentProps.filterKeys?.checked || [];
|
const filterKeys = actionField.componentProps.filterKeys?.checked || [];
|
||||||
return {
|
return {
|
||||||
async onClick() {
|
async onClick() {
|
||||||
@ -207,6 +210,7 @@ export const useCreateActionProps = () => {
|
|||||||
const data = await resource[action]({
|
const data = await resource[action]({
|
||||||
values,
|
values,
|
||||||
filterKeys: filterKeys,
|
filterKeys: filterKeys,
|
||||||
|
filterByTk,
|
||||||
// TODO(refactor): should change to inject by plugin
|
// TODO(refactor): should change to inject by plugin
|
||||||
triggerWorkflows: triggerWorkflows?.length
|
triggerWorkflows: triggerWorkflows?.length
|
||||||
? triggerWorkflows.map((row) => [row.workflowKey, row.context].filter(Boolean).join('!')).join(',')
|
? triggerWorkflows.map((row) => [row.workflowKey, row.context].filter(Boolean).join('!')).join(',')
|
||||||
|
Loading…
Reference in New Issue
Block a user