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,20 +43,30 @@ export function useCreateEditFormBlock() {
|
||||
|
||||
const createEditFormBlock = useCallback(
|
||||
({ item }) => {
|
||||
insert(
|
||||
createEditFormBlockUISchema(
|
||||
association
|
||||
? {
|
||||
association,
|
||||
dataSource: item.dataSource,
|
||||
isCurrent: true,
|
||||
}
|
||||
: {
|
||||
collectionName: item.collectionName || item.name,
|
||||
dataSource: item.dataSource,
|
||||
},
|
||||
),
|
||||
);
|
||||
if (!association && item.associationField) {
|
||||
const field = item.associationField;
|
||||
insert(
|
||||
createEditFormBlockUISchema({
|
||||
dataSource: item.dataSource,
|
||||
association: `${field.collectionName}.${field.name}`,
|
||||
}),
|
||||
);
|
||||
} else {
|
||||
insert(
|
||||
createEditFormBlockUISchema(
|
||||
association
|
||||
? {
|
||||
association,
|
||||
dataSource: item.dataSource,
|
||||
isCurrent: true,
|
||||
}
|
||||
: {
|
||||
collectionName: item.collectionName || item.name,
|
||||
dataSource: item.dataSource,
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
[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