fix: deep level association field adding error (#2700)
This commit is contained in:
parent
60aeba4a12
commit
b0069ca64a
@ -34,6 +34,7 @@ interface UseResourceProps {
|
||||
resource: any;
|
||||
association?: any;
|
||||
useSourceId?: any;
|
||||
collection?: any;
|
||||
block?: any;
|
||||
}
|
||||
|
||||
@ -48,7 +49,7 @@ export const useAssociation = (props) => {
|
||||
};
|
||||
|
||||
const useResource = (props: UseResourceProps) => {
|
||||
const { block, resource, useSourceId } = props;
|
||||
const { block, collection, resource, useSourceId } = props;
|
||||
const record = useRecord();
|
||||
const api = useAPIClient();
|
||||
const { fieldSchema } = useActionContext();
|
||||
@ -83,8 +84,10 @@ const useResource = (props: UseResourceProps) => {
|
||||
if (sourceId) {
|
||||
return api.resource(resource, sourceId);
|
||||
}
|
||||
|
||||
return api.resource(resource, record[association?.sourceKey || 'id']);
|
||||
if (record[association?.sourceKey || 'id']) {
|
||||
return api.resource(resource, record[association?.sourceKey || 'id']);
|
||||
}
|
||||
return api.resource(collection);
|
||||
};
|
||||
|
||||
const useActionParams = (props) => {
|
||||
@ -271,6 +274,7 @@ export const RenderChildrenWithAssociationFilter: React.FC<any> = (props) => {
|
||||
};
|
||||
|
||||
export const BlockProvider = (props) => {
|
||||
console.log(props);
|
||||
const { collection, association } = props;
|
||||
const resource = useResource(props);
|
||||
const params = { ...props.params };
|
||||
|
Loading…
Reference in New Issue
Block a user