fix(Filter-form): avoid infinit loop
This commit is contained in:
parent
4604e45573
commit
a6fc04503d
@ -338,15 +338,28 @@ export const useAssociatedFormItemInitializerFields = (options?: any) => {
|
|||||||
return groups;
|
return groups;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getItem = (field: FieldOptions, schemaName: string, collectionName: string, getCollectionFields) => {
|
const getItem = (
|
||||||
|
field: FieldOptions,
|
||||||
|
schemaName: string,
|
||||||
|
collectionName: string,
|
||||||
|
getCollectionFields,
|
||||||
|
processedCollections: string[],
|
||||||
|
) => {
|
||||||
if (field.interface === 'm2o') {
|
if (field.interface === 'm2o') {
|
||||||
|
if (processedCollections.includes(field.target)) return null;
|
||||||
|
|
||||||
const subFields = getCollectionFields(field.target);
|
const subFields = getCollectionFields(field.target);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: 'subMenu',
|
type: 'subMenu',
|
||||||
title: field.uiSchema?.title,
|
title: field.uiSchema?.title,
|
||||||
children: subFields
|
children: subFields
|
||||||
.map((subField) => getItem(subField, `${schemaName}.${subField.name}`, collectionName, getCollectionFields))
|
.map((subField) =>
|
||||||
|
getItem(subField, `${schemaName}.${subField.name}`, collectionName, getCollectionFields, [
|
||||||
|
...processedCollections,
|
||||||
|
field.target,
|
||||||
|
]),
|
||||||
|
)
|
||||||
.filter(Boolean),
|
.filter(Boolean),
|
||||||
} as SchemaInitializerItemOptions;
|
} as SchemaInitializerItemOptions;
|
||||||
}
|
}
|
||||||
@ -385,7 +398,7 @@ export const useFilterAssociatedFormItemInitializerFields = () => {
|
|||||||
?.filter((field) => {
|
?.filter((field) => {
|
||||||
return interfaces.includes(field.interface);
|
return interfaces.includes(field.interface);
|
||||||
})
|
})
|
||||||
?.map((field) => getItem(field, field.name, name, getCollectionFields));
|
?.map((field) => getItem(field, field.name, name, getCollectionFields, []));
|
||||||
return groups;
|
return groups;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user