mirror of
https://github.com/nocobase/nocobase
synced 2024-11-16 06:15:30 +00:00
fix: bug
This commit is contained in:
parent
4132659670
commit
5f37f7a523
@ -305,6 +305,8 @@ export class CollectionManagerV2<Mixins = {}> {
|
|||||||
private getInheritData() {
|
private getInheritData() {
|
||||||
return {
|
return {
|
||||||
collections: this.collections,
|
collections: this.collections,
|
||||||
|
collectionFieldGroups: this.collectionFieldGroups,
|
||||||
|
reloadCallbacks: this.reloadCallbacks,
|
||||||
collectionTemplateInstances: this.collectionTemplateInstances,
|
collectionTemplateInstances: this.collectionTemplateInstances,
|
||||||
fieldInterfaceInstances: this.fieldInterfaceInstances,
|
fieldInterfaceInstances: this.fieldInterfaceInstances,
|
||||||
collectionMixins: this.collectionMixins,
|
collectionMixins: this.collectionMixins,
|
||||||
|
@ -55,6 +55,7 @@ export class CollectionPlugin extends Plugin {
|
|||||||
this.addFieldInterfaces();
|
this.addFieldInterfaces();
|
||||||
this.addCollectionTemplates();
|
this.addCollectionTemplates();
|
||||||
this.addFieldInterfaces();
|
this.addFieldInterfaces();
|
||||||
|
this.addFieldGroups();
|
||||||
|
|
||||||
this.collectionManager.setReloadFn(this.reloadCollections.bind(this));
|
this.collectionManager.setReloadFn(this.reloadCollections.bind(this));
|
||||||
}
|
}
|
||||||
|
@ -12,14 +12,13 @@ export const useCollectionManager = () => {
|
|||||||
const [random, setRandom] = useState(uid());
|
const [random, setRandom] = useState(uid());
|
||||||
const interfaces = useMemo(() => cm?.getFieldInterfaces(), [cm, random]);
|
const interfaces = useMemo(() => cm?.getFieldInterfaces(), [cm, random]);
|
||||||
const templates = useMemo(() => cm?.getCollectionTemplates(), [cm, random]);
|
const templates = useMemo(() => cm?.getCollectionTemplates(), [cm, random]);
|
||||||
const collections = useMemo(
|
const getCollections = useCallback(() => {
|
||||||
() =>
|
return cm
|
||||||
cm
|
|
||||||
?.getCollections()
|
?.getCollections()
|
||||||
.filter((item) => !item.isLocal)
|
.filter((item) => !item.isLocal)
|
||||||
.map((item) => item.getOptions()),
|
.map((item) => item.getOptions());
|
||||||
[cm, random],
|
}, [cm]);
|
||||||
);
|
const collections = useMemo(() => getCollections(), [cm, random]);
|
||||||
const { refresh } = useSchemaComponentContext();
|
const { refresh } = useSchemaComponentContext();
|
||||||
const service = useCallback(() => cm?.reload(refresh), [cm]);
|
const service = useCallback(() => cm?.reload(refresh), [cm]);
|
||||||
const updateCollection = cm?.setCollections.bind(cm);
|
const updateCollection = cm?.setCollections.bind(cm);
|
||||||
@ -236,6 +235,7 @@ export const useCollectionManager = () => {
|
|||||||
templates,
|
templates,
|
||||||
getTemplate,
|
getTemplate,
|
||||||
getInterface,
|
getInterface,
|
||||||
|
getCollections,
|
||||||
getParentCollectionFields,
|
getParentCollectionFields,
|
||||||
getInheritCollections,
|
getInheritCollections,
|
||||||
getChildrenCollections,
|
getChildrenCollections,
|
||||||
|
@ -372,7 +372,7 @@ export const GraphDrawPage = React.memo(() => {
|
|||||||
const [collectionData, setCollectionData] = useState<any>([]);
|
const [collectionData, setCollectionData] = useState<any>([]);
|
||||||
const [collectionList, setCollectionList] = useState<any>([]);
|
const [collectionList, setCollectionList] = useState<any>([]);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const { collections } = useCollectionManager();
|
const { collections, getCollections } = useCollectionManager();
|
||||||
const cm = useCollectionManagerV2();
|
const cm = useCollectionManagerV2();
|
||||||
const currentAppInfo = useCurrentAppInfo();
|
const currentAppInfo = useCurrentAppInfo();
|
||||||
const app = useApp();
|
const app = useApp();
|
||||||
@ -412,7 +412,9 @@ export const GraphDrawPage = React.memo(() => {
|
|||||||
refreshPositions();
|
refreshPositions();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const reloadCallback = async (collections) => {
|
const reloadCallback = async () => {
|
||||||
|
const collections = getCollections();
|
||||||
|
if (!targetGraph) return;
|
||||||
targetGraph.collections = collections;
|
targetGraph.collections = collections;
|
||||||
targetGraph.updatePositionAction = updatePositionAction;
|
targetGraph.updatePositionAction = updatePositionAction;
|
||||||
targetGraph.saveGraphPositionAction = saveGraphPositionAction;
|
targetGraph.saveGraphPositionAction = saveGraphPositionAction;
|
||||||
@ -1072,7 +1074,7 @@ export const GraphDrawPage = React.memo(() => {
|
|||||||
setLoading(true);
|
setLoading(true);
|
||||||
refreshPositions()
|
refreshPositions()
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
await reloadCallback(collections);
|
await reloadCallback();
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user