refactor: association field support sub-table

This commit is contained in:
katherinehhh 2023-05-11 09:51:28 +08:00
parent e6efc8dc57
commit 7a4943405c
2 changed files with 8 additions and 4 deletions

View File

@ -35,12 +35,12 @@ export const useFieldModeOptions = () => {
return isReadPretty
? [
{ label: t('Title'), value: 'Select' },
// { label: t('Subtable'), value: 'SubTable' },
{ label: t('Subtable'), value: 'SubTable' },
{ label: t('Sub-details'), value: 'Nester' },
]
: [
{ label: t('Record picker'), value: 'Picker' },
// { label: t('Subtable'), value: 'SubTable' },
{ label: t('Subtable'), value: 'SubTable' },
{ label: t('Select'), value: 'Select' },
{ label: t('Subform'), value: 'Nester' },
];

View File

@ -76,6 +76,10 @@ export const findTableColumn = (schema: Schema, key: string, action: string, dee
export const useTableColumnInitializerFields = () => {
const { name, currentFields = [] } = useCollection();
const { getInterface, getCollection } = useCollectionManager();
const fieldSchema = useFieldSchema();
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,
@ -86,7 +90,7 @@ export const useTableColumnInitializerFields = () => {
name: field.name,
'x-collection-field': `${name}.${field.name}`,
'x-component': 'CollectionField',
'x-read-pretty': true,
'x-read-pretty': isReadPretty,
'x-component-props': {},
};
// interfaceConfig?.schemaInitialize?.(schema, { field, readPretty: true, block: 'Table' });
@ -99,7 +103,7 @@ export const useTableColumnInitializerFields = () => {
schemaInitialize: (s) => {
interfaceConfig?.schemaInitialize?.(s, {
field,
readPretty: true,
readPretty: isReadPretty,
block: 'Table',
targetCollection: getCollection(field.target),
});