fix: subtable appends

This commit is contained in:
katherinehhh 2023-05-09 22:49:59 +08:00
parent dffef4f44b
commit acb47252aa
2 changed files with 5 additions and 3 deletions

View File

@ -1057,7 +1057,7 @@ export const useAssociationNames = (collection) => {
let kk = buf.concat();
return getNesterAppends(s, kk);
} else {
return getAssociationAppends(s, buf);
return s['x-component'] !== 'TableV2' && getAssociationAppends(s, buf);
}
}
}, arr);
@ -1067,7 +1067,7 @@ export const useAssociationNames = (collection) => {
function flattenHelper(list, prefix) {
for (let i = 0; i < list.length; i++) {
if (Array.isArray(list[i])) {
flattenHelper(list[i], `${prefix}.${list[i][0]}`);
`${prefix}` !== `${list[i][0]}` && flattenHelper(list[i], `${prefix}.${list[i][0]}`);
} else {
const str = prefix.replaceAll(`${list[i]}`, '').replace('..', '.').trim();
!list.includes(str) && flattenedList.push(`${str}${list[i]}`);
@ -1086,6 +1086,7 @@ export const useAssociationNames = (collection) => {
}, data);
return data.filter((g) => g.length);
};
console.log(formSchema.toJSON());
const data = getAssociationAppends(formSchema);
const associations = data.filter((g) => g.length);
const appends = flattenNestedList(associations);

View File

@ -117,6 +117,7 @@ FormItem.Designer = function Designer() {
: getCollectionFields(collectionField?.targetCollection) ?? [];
const fieldModeOptions = useFieldModeOptions();
const isAssociationField = ['belongsTo', 'hasOne', 'hasMany', 'belongsToMany'].includes(collectionField?.type);
const isTableField = fieldSchema['x-component'] === 'TableField';
const isFileField = isFileCollection(targetCollection);
const initialValue = {
title: field.title === originalTitle ? undefined : field.title,
@ -658,7 +659,7 @@ FormItem.Designer = function Designer() {
}}
/>
)}
{isAssociationField && fieldModeOptions && (
{isAssociationField && fieldModeOptions && !isTableField && (
<SchemaSettings.SelectItem
key="field-mode"
title={t('Field mode')}