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) => {
|
||||
const record = useRecord();
|
||||
const parentRecordData = useCollectionParentRecordData();
|
||||
const { collection, isCusomeizeCreate } = props;
|
||||
const { collection, isCusomeizeCreate, parentRecord } = props;
|
||||
const { __collection } = record;
|
||||
const currentCollection = useCollection_deprecated();
|
||||
const { designable } = useDesignable();
|
||||
@ -114,7 +114,12 @@ export const FormBlockProvider = withDynamicSchemaProps((props) => {
|
||||
|
||||
return (
|
||||
<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">
|
||||
<InternalFormBlockProvider {...props} />
|
||||
</FormActiveFieldsProvider>
|
||||
|
@ -43,6 +43,15 @@ export function useCreateEditFormBlock() {
|
||||
|
||||
const createEditFormBlock = useCallback(
|
||||
({ item }) => {
|
||||
if (!association && item.associationField) {
|
||||
const field = item.associationField;
|
||||
insert(
|
||||
createEditFormBlockUISchema({
|
||||
dataSource: item.dataSource,
|
||||
association: `${field.collectionName}.${field.name}`,
|
||||
}),
|
||||
);
|
||||
} else {
|
||||
insert(
|
||||
createEditFormBlockUISchema(
|
||||
association
|
||||
@ -57,6 +66,7 @@ export function useCreateEditFormBlock() {
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
[association, insert],
|
||||
);
|
||||
|
@ -126,7 +126,7 @@ function useRecordBlocks() {
|
||||
if (collection) {
|
||||
return collectionsNeedToDisplay.some((c) => c.name === collection.name);
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
},
|
||||
onlyCurrentDataSource: true,
|
||||
hideSearch: true,
|
||||
|
Loading…
Reference in New Issue
Block a user