fix: record picker
This commit is contained in:
parent
271e91b452
commit
8b960c78d1
@ -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>
|
||||||
|
Loading…
Reference in New Issue
Block a user