feat: support edit associated form (#920)
Reviewed-on: daoyoucloud/tachybase#920
This commit is contained in:
parent
330b8b13da
commit
dcd89df482
@ -93,7 +93,7 @@ export const useIsDetailBlock = () => {
|
|||||||
export const FormBlockProvider = withDynamicSchemaProps((props) => {
|
export const FormBlockProvider = withDynamicSchemaProps((props) => {
|
||||||
const record = useRecord();
|
const record = useRecord();
|
||||||
const parentRecordData = useCollectionParentRecordData();
|
const parentRecordData = useCollectionParentRecordData();
|
||||||
const { collection, isCusomeizeCreate } = props;
|
const { collection, isCusomeizeCreate, parentRecord } = props;
|
||||||
const { __collection } = record;
|
const { __collection } = record;
|
||||||
const currentCollection = useCollection_deprecated();
|
const currentCollection = useCollection_deprecated();
|
||||||
const { designable } = useDesignable();
|
const { designable } = useDesignable();
|
||||||
@ -114,7 +114,12 @@ export const FormBlockProvider = withDynamicSchemaProps((props) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<TemplateBlockProvider>
|
<TemplateBlockProvider>
|
||||||
<BlockProvider name={props.name || 'form'} {...props} block={'form'} parentRecord={parentRecordData}>
|
<BlockProvider
|
||||||
|
name={props.name || 'form'}
|
||||||
|
{...props}
|
||||||
|
block={'form'}
|
||||||
|
parentRecord={parentRecord || parentRecordData}
|
||||||
|
>
|
||||||
<FormActiveFieldsProvider name="form">
|
<FormActiveFieldsProvider name="form">
|
||||||
<InternalFormBlockProvider {...props} />
|
<InternalFormBlockProvider {...props} />
|
||||||
</FormActiveFieldsProvider>
|
</FormActiveFieldsProvider>
|
||||||
|
@ -43,20 +43,30 @@ export function useCreateEditFormBlock() {
|
|||||||
|
|
||||||
const createEditFormBlock = useCallback(
|
const createEditFormBlock = useCallback(
|
||||||
({ item }) => {
|
({ item }) => {
|
||||||
insert(
|
if (!association && item.associationField) {
|
||||||
createEditFormBlockUISchema(
|
const field = item.associationField;
|
||||||
association
|
insert(
|
||||||
? {
|
createEditFormBlockUISchema({
|
||||||
association,
|
dataSource: item.dataSource,
|
||||||
dataSource: item.dataSource,
|
association: `${field.collectionName}.${field.name}`,
|
||||||
isCurrent: true,
|
}),
|
||||||
}
|
);
|
||||||
: {
|
} else {
|
||||||
collectionName: item.collectionName || item.name,
|
insert(
|
||||||
dataSource: item.dataSource,
|
createEditFormBlockUISchema(
|
||||||
},
|
association
|
||||||
),
|
? {
|
||||||
);
|
association,
|
||||||
|
dataSource: item.dataSource,
|
||||||
|
isCurrent: true,
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
collectionName: item.collectionName || item.name,
|
||||||
|
dataSource: item.dataSource,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
[association, insert],
|
[association, insert],
|
||||||
);
|
);
|
||||||
|
@ -126,7 +126,7 @@ function useRecordBlocks() {
|
|||||||
if (collection) {
|
if (collection) {
|
||||||
return collectionsNeedToDisplay.some((c) => c.name === collection.name);
|
return collectionsNeedToDisplay.some((c) => c.name === collection.name);
|
||||||
}
|
}
|
||||||
return false;
|
return true;
|
||||||
},
|
},
|
||||||
onlyCurrentDataSource: true,
|
onlyCurrentDataSource: true,
|
||||||
hideSearch: true,
|
hideSearch: true,
|
||||||
|
Loading…
Reference in New Issue
Block a user