fix: record picker

This commit is contained in:
chenos 2022-04-12 14:39:46 +08:00
parent 271e91b452
commit 8b960c78d1

View File

@ -17,32 +17,33 @@ export const ReadPrettyRecordPicker: React.FC = observer((props: any) => {
const [visible, setVisible] = useState(false); const [visible, setVisible] = useState(false);
const { getField } = useCollection(); const { getField } = useCollection();
const collectionField = getField(fieldSchema.name); const collectionField = getField(fieldSchema.name);
const [record, setRecord] = useState({});
return ( return (
<div> <div>
<BlockAssociationContext.Provider value={`${collectionField.collectionName}.${collectionField.name}`}> <BlockAssociationContext.Provider value={`${collectionField.collectionName}.${collectionField.name}`}>
<CollectionProvider name={collectionField.target}> <CollectionProvider name={collectionField.target}>
<ActionContext.Provider value={{ visible, setVisible, openMode: 'drawer' }}>
<Space size={0} split={<span style={{ marginRight: 4, color: '#aaa' }}>, </span>}> <Space size={0} split={<span style={{ marginRight: 4, color: '#aaa' }}>, </span>}>
{toArr(field.value).map((record, index) => { {toArr(field.value).map((record, index) => {
return ( return (
<span> <span>
<a <a
onClick={() => { onClick={() => {
console.log('setVisible');
setVisible(true); setVisible(true);
setRecord(record);
}} }}
> >
{record?.[fieldNames?.label || 'label']} {record?.[fieldNames?.label || 'label']}
</a> </a>
</span>
);
})}
</Space>
<ActionContext.Provider value={{ visible, setVisible, openMode: 'drawer' }}>
<RecordProvider record={record}> <RecordProvider record={record}>
<FormProvider> <FormProvider>
<RecursionField schema={fieldSchema} onlyRenderProperties /> <RecursionField schema={fieldSchema} onlyRenderProperties />
</FormProvider> </FormProvider>
</RecordProvider> </RecordProvider>
</span>
);
})}
</Space>
</ActionContext.Provider> </ActionContext.Provider>
</CollectionProvider> </CollectionProvider>
</BlockAssociationContext.Provider> </BlockAssociationContext.Provider>