fix(sub-table): inherited fields cannot be edited in a subtable (#2106)

* fix: inherit filed cant not edit in sub-table

* fix: inherit filed cant not edit in sub-table
This commit is contained in:
katherinehhh 2023-06-25 08:54:11 +08:00 committed by GitHub
parent e3b84e855c
commit 2bbba7b7fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -93,6 +93,7 @@ export const useTableColumnInitializerFields = () => {
const isSubTable = fieldSchema['x-component'] === 'AssociationField.SubTable';
const form = useForm();
const isReadPretty = isSubTable ? form.readPretty : true;
return currentFields
.filter(
(field) => field?.interface && field?.interface !== 'subTable' && !field?.isForeignKey && !field?.treeChildren,
@ -203,6 +204,10 @@ export const useAssociatedTableColumnInitializerFields = () => {
export const useInheritsTableColumnInitializerFields = () => {
const { name } = useCollection();
const { getInterface, getInheritCollections, getCollection, getParentCollectionFields } = useCollectionManager();
const fieldSchema = useFieldSchema();
const isSubTable = fieldSchema['x-component'] === 'AssociationField.SubTable';
const form = useForm();
const isReadPretty = isSubTable ? form.readPretty : true;
const inherits = getInheritCollections(name);
return inherits?.map((v) => {
const fields = getParentCollectionFields(v, name);
@ -214,12 +219,30 @@ export const useInheritsTableColumnInitializerFields = () => {
})
.map((k) => {
const interfaceConfig = getInterface(k.interface);
const isFileCollection = k?.target && getCollection(k?.target)?.template === 'file';
const schema = {
name: `${k.name}`,
'x-component': 'CollectionField',
'x-read-pretty': true,
'x-read-pretty': isReadPretty || k.uiSchema?.['x-read-pretty'],
'x-collection-field': `${name}.${k.name}`,
'x-component-props': {},
'x-component-props': isFileCollection
? {
fieldNames: {
label: 'preview',
value: 'id',
},
}
: {},
'x-decorator': isSubTable
? quickEditField.includes(k.interface) || isFileCollection
? 'QuickEdit'
: 'FormItem'
: null,
'x-decorator-props': {
labelStyle: {
display: 'none',
},
},
};
return {
type: 'item',