mirror of
https://github.com/nocobase/nocobase
synced 2024-11-16 06:15:30 +00:00
fix: bug
This commit is contained in:
parent
08ccdb2964
commit
6ac6f050c2
@ -20,17 +20,18 @@ export const CollectionProvider: FC<{
|
|||||||
const collectionName = getCollectionName(name || collection);
|
const collectionName = getCollectionName(name || collection);
|
||||||
const cm = useCollectionManagerV2();
|
const cm = useCollectionManagerV2();
|
||||||
const hasCollection = cm.getCollection(collectionName);
|
const hasCollection = cm.getCollection(collectionName);
|
||||||
if (hasCollection || allowNull)
|
if (hasCollection || (allowNull && !collection))
|
||||||
return (
|
return (
|
||||||
<CollectionProviderV2 allowNull={allowNull} name={collectionName}>
|
<CollectionProviderV2 allowNull={allowNull} name={collectionName}>
|
||||||
{children}
|
{children}
|
||||||
</CollectionProviderV2>
|
</CollectionProviderV2>
|
||||||
);
|
);
|
||||||
if (typeof collection === 'object')
|
if (typeof collection === 'object') {
|
||||||
return (
|
return (
|
||||||
<CollectionManagerProvider collections={[collection]}>
|
<CollectionManagerProvider collections={[collection]}>
|
||||||
<CollectionProviderV2 name={collection.name}>{children}</CollectionProviderV2>
|
<CollectionProviderV2 name={collection.name}>{children}</CollectionProviderV2>
|
||||||
</CollectionManagerProvider>
|
</CollectionManagerProvider>
|
||||||
);
|
);
|
||||||
|
}
|
||||||
return <DeletedPlaceholder type="Collection" name={name} />;
|
return <DeletedPlaceholder type="Collection" name={name} />;
|
||||||
};
|
};
|
||||||
|
@ -4,15 +4,15 @@ import { message } from 'antd';
|
|||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useAPIClient } from '../../../api-client';
|
import { useAPIClient } from '../../../api-client';
|
||||||
import { i18n } from '../../../i18n';
|
import { i18n } from '../../../i18n';
|
||||||
import { CollectionOptions } from '../../types';
|
|
||||||
import { CollectionCategory } from '../components/CollectionCategory';
|
import { CollectionCategory } from '../components/CollectionCategory';
|
||||||
import { CollectionTemplate } from '../components/CollectionTemplate';
|
import { CollectionTemplate } from '../components/CollectionTemplate';
|
||||||
|
import { CollectionOptionsV2 } from '../../../application';
|
||||||
|
|
||||||
const compile = (source) => {
|
const compile = (source) => {
|
||||||
return Schema.compile(source, { t: i18n.t });
|
return Schema.compile(source, { t: i18n.t });
|
||||||
};
|
};
|
||||||
|
|
||||||
export const collection: CollectionOptions = {
|
export const collection: CollectionOptionsV2 = {
|
||||||
name: 'collections',
|
name: 'collections',
|
||||||
filterTargetKey: 'name',
|
filterTargetKey: 'name',
|
||||||
targetKey: 'name',
|
targetKey: 'name',
|
||||||
|
@ -41,6 +41,7 @@ import { InheritanceCollectionMixin } from './mixins/InheritanceCollectionMixin'
|
|||||||
// import { general, expression, sql, tree, view } from './templates';
|
// import { general, expression, sql, tree, view } from './templates';
|
||||||
import { interfaces } from './Configuration/interfaces';
|
import { interfaces } from './Configuration/interfaces';
|
||||||
import { collectionTemplates } from './Configuration/templates';
|
import { collectionTemplates } from './Configuration/templates';
|
||||||
|
import { collection } from './Configuration/schemas/collections';
|
||||||
|
|
||||||
export class CollectionPlugin extends Plugin {
|
export class CollectionPlugin extends Plugin {
|
||||||
async load() {
|
async load() {
|
||||||
@ -114,6 +115,6 @@ export class CollectionPlugin extends Plugin {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return service?.data?.data || [];
|
return [...(service?.data?.data || []), collection];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user