mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 16:34:13 +00:00
fix: template with fields only (#517)
This commit is contained in:
parent
2b3f3bd5c3
commit
929dd9b22e
@ -201,8 +201,12 @@ export const useRecordCollectionDataSourceItems = (componentName, item = null, c
|
||||
const { t } = useTranslation();
|
||||
const collection = useCollection();
|
||||
const { getTemplatesByCollection } = useSchemaTemplateManager();
|
||||
const templates = getTemplatesByCollection(collectionName || collection.name, resourceName || collectionName || collection.name).filter((template) => {
|
||||
const templates = getTemplatesByCollection(collectionName || collection.name)
|
||||
.filter((template) => {
|
||||
return componentName && template.componentName === componentName;
|
||||
})
|
||||
.filter((template) => {
|
||||
return ['FormItem', 'ReadPrettyFormItem'].includes(componentName) || (template.resourceName === resourceName);
|
||||
});
|
||||
if (!templates.length) {
|
||||
return [];
|
||||
@ -226,7 +230,7 @@ export const useRecordCollectionDataSourceItems = (componentName, item = null, c
|
||||
title: t('Duplicate template'),
|
||||
children: templates.map((template) => {
|
||||
const templateName =
|
||||
template?.componentName === 'ReadPrettyFormItem' ? `${template?.name} ${t('(Fields only)')}` : template?.name;
|
||||
['FormItem', 'ReadPrettyFormItem'].includes(template?.componentName) ? `${template?.name} ${t('(Fields only)')}` : template?.name;
|
||||
return {
|
||||
type: 'item',
|
||||
mode: 'copy',
|
||||
@ -244,7 +248,7 @@ export const useRecordCollectionDataSourceItems = (componentName, item = null, c
|
||||
title: t('Reference template'),
|
||||
children: templates.map((template) => {
|
||||
const templateName =
|
||||
template?.componentName === 'ReadPrettyFormItem' ? `${template?.name} ${t('(Fields only)')}` : template?.name;
|
||||
['FormItem', 'ReadPrettyFormItem'].includes(template?.componentName) ? `${template?.name} ${t('(Fields only)')}` : template?.name;
|
||||
return {
|
||||
type: 'item',
|
||||
mode: 'reference',
|
||||
@ -270,8 +274,8 @@ export const useCollectionDataSourceItems = (componentName) => {
|
||||
children: collections
|
||||
?.filter((item) => !item.inherit)
|
||||
?.map((item, index) => {
|
||||
const templates = getTemplatesByCollection(item.name, item.name).filter((template) => {
|
||||
return componentName && template.componentName === componentName;
|
||||
const templates = getTemplatesByCollection(item.name).filter((template) => {
|
||||
return componentName && template.componentName === componentName && (!template.resourceName || template.resourceName === item.name);
|
||||
});
|
||||
if (!templates.length) {
|
||||
return {
|
||||
|
@ -120,7 +120,7 @@ export const useSchemaTemplateManager = () => {
|
||||
return templates?.find((template) => template.key === key);
|
||||
},
|
||||
getTemplatesByCollection(collectionName: string, resourceName: string = null) {
|
||||
const items = templates?.filter?.((template) => (!template.resourceName && template.collectionName === collectionName) || (template.resourceName && template.resourceName === resourceName));
|
||||
const items = templates?.filter?.((template) => (template.collectionName === collectionName));
|
||||
return items || [];
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user