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}>
<Space size={0} split={<span style={{ marginRight: 4, color: '#aaa' }}>, </span>}>
{toArr(field.value).map((record, index) => {
return (
<span>
<a
onClick={() => {
setVisible(true);
setRecord(record);
}}
>
{record?.[fieldNames?.label || 'label']}
</a>
</span>
);
})}
</Space>
<ActionContext.Provider value={{ visible, setVisible, openMode: 'drawer' }}> <ActionContext.Provider value={{ visible, setVisible, openMode: 'drawer' }}>
<Space size={0} split={<span style={{ marginRight: 4, color: '#aaa' }}>, </span>}> <RecordProvider record={record}>
{toArr(field.value).map((record, index) => { <FormProvider>
return ( <RecursionField schema={fieldSchema} onlyRenderProperties />
<span> </FormProvider>
<a </RecordProvider>
onClick={() => {
console.log('setVisible');
setVisible(true);
}}
>
{record?.[fieldNames?.label || 'label']}
</a>
<RecordProvider record={record}>
<FormProvider>
<RecursionField schema={fieldSchema} onlyRenderProperties />
</FormProvider>
</RecordProvider>
</span>
);
})}
</Space>
</ActionContext.Provider> </ActionContext.Provider>
</CollectionProvider> </CollectionProvider>
</BlockAssociationContext.Provider> </BlockAssociationContext.Provider>