fix: source collections not updated during synchronization in view collection (#2480)
This commit is contained in:
parent
1977e00414
commit
2ea97541c6
@ -30,6 +30,7 @@ const PreviewCom = (props) => {
|
|||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [dataSource, setDataSource] = useState([]);
|
const [dataSource, setDataSource] = useState([]);
|
||||||
const [sourceFields, setSourceFields] = useState([]);
|
const [sourceFields, setSourceFields] = useState([]);
|
||||||
|
const [sourceCollections, setSourceCollections] = useState(sources);
|
||||||
const field: any = useField();
|
const field: any = useField();
|
||||||
const form = useForm();
|
const form = useForm();
|
||||||
const { getCollection, getInterface, getCollectionFields, getInheritCollections, getParentCollectionFields } =
|
const { getCollection, getInterface, getCollectionFields, getInheritCollections, getParentCollectionFields } =
|
||||||
@ -38,7 +39,7 @@ const PreviewCom = (props) => {
|
|||||||
const initOptions = getOptions().filter((v) => !['relation', 'systemInfo'].includes(v.key));
|
const initOptions = getOptions().filter((v) => !['relation', 'systemInfo'].includes(v.key));
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const data = [];
|
const data = [];
|
||||||
sources.forEach((item) => {
|
sourceCollections.forEach((item) => {
|
||||||
const collection = getCollection(item);
|
const collection = getCollection(item);
|
||||||
const inherits = getInheritCollections(item);
|
const inherits = getInheritCollections(item);
|
||||||
const result = inherits.map((v) => {
|
const result = inherits.map((v) => {
|
||||||
@ -70,8 +71,7 @@ const PreviewCom = (props) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
setSourceFields(data);
|
setSourceFields(data);
|
||||||
}, [sources, databaseView]);
|
}, [sourceCollections, databaseView]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (databaseView) {
|
if (databaseView) {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
@ -92,6 +92,7 @@ const PreviewCom = (props) => {
|
|||||||
field.value = fieldsData;
|
field.value = fieldsData;
|
||||||
setDataSource(fieldsData);
|
setDataSource(fieldsData);
|
||||||
form.setValuesIn('sources', data.data?.sources);
|
form.setValuesIn('sources', data.data?.sources);
|
||||||
|
setSourceCollections(data.data?.sources);
|
||||||
}
|
}
|
||||||
}).catch;
|
}).catch;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user