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