refactor: file association field should default to using preview field as title field (#2718)
This commit is contained in:
parent
91721a4e8a
commit
49c2fbf45d
@ -270,12 +270,12 @@ export const useFormItemInitializerFields = (options?: any) => {
|
|||||||
const { readPretty = form.readPretty, block = 'Form' } = options || {};
|
const { readPretty = form.readPretty, block = 'Form' } = options || {};
|
||||||
const { snapshot, fieldSchema } = useActionContext();
|
const { snapshot, fieldSchema } = useActionContext();
|
||||||
const action = fieldSchema?.['x-action'];
|
const action = fieldSchema?.['x-action'];
|
||||||
|
|
||||||
return currentFields
|
return currentFields
|
||||||
?.filter((field) => field?.interface && !field?.isForeignKey && !field?.treeChildren)
|
?.filter((field) => field?.interface && !field?.isForeignKey && !field?.treeChildren)
|
||||||
?.map((field) => {
|
?.map((field) => {
|
||||||
const interfaceConfig = getInterface(field.interface);
|
const interfaceConfig = getInterface(field.interface);
|
||||||
const targetCollection = getCollection(field.target);
|
const targetCollection = getCollection(field.target);
|
||||||
|
const isFileCollection = field?.target && getCollection(field?.target)?.template === 'file';
|
||||||
// const component =
|
// const component =
|
||||||
// field.interface === 'o2m' && targetCollection?.template !== 'file' && !snapshot
|
// field.interface === 'o2m' && targetCollection?.template !== 'file' && !snapshot
|
||||||
// ? 'TableField'
|
// ? 'TableField'
|
||||||
@ -287,7 +287,14 @@ export const useFormItemInitializerFields = (options?: any) => {
|
|||||||
'x-component': 'CollectionField',
|
'x-component': 'CollectionField',
|
||||||
'x-decorator': 'FormItem',
|
'x-decorator': 'FormItem',
|
||||||
'x-collection-field': `${name}.${field.name}`,
|
'x-collection-field': `${name}.${field.name}`,
|
||||||
'x-component-props': {},
|
'x-component-props': isFileCollection
|
||||||
|
? {
|
||||||
|
fieldNames: {
|
||||||
|
label: 'preview',
|
||||||
|
value: 'id',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
: {},
|
||||||
'x-read-pretty': field?.uiSchema?.['x-read-pretty'],
|
'x-read-pretty': field?.uiSchema?.['x-read-pretty'],
|
||||||
};
|
};
|
||||||
// interfaceConfig?.schemaInitialize?.(schema, { field, block: 'Form', readPretty: form.readPretty });
|
// interfaceConfig?.schemaInitialize?.(schema, { field, block: 'Form', readPretty: form.readPretty });
|
||||||
@ -397,14 +404,20 @@ export const useAssociatedFormItemInitializerFields = (options?: any) => {
|
|||||||
)
|
)
|
||||||
?.map((subField) => {
|
?.map((subField) => {
|
||||||
const interfaceConfig = getInterface(subField.interface);
|
const interfaceConfig = getInterface(subField.interface);
|
||||||
|
const isFileCollection = field?.target && getCollection(field?.target)?.template === 'file';
|
||||||
const schema = {
|
const schema = {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
name: `${field.name}.${subField.name}`,
|
name: `${field.name}.${subField.name}`,
|
||||||
'x-designer': 'FormItem.Designer',
|
'x-designer': 'FormItem.Designer',
|
||||||
'x-component': 'CollectionField',
|
'x-component': 'CollectionField',
|
||||||
|
|
||||||
'x-read-pretty': readPretty,
|
'x-read-pretty': readPretty,
|
||||||
'x-component-props': {
|
'x-component-props': {
|
||||||
'pattern-disable': block === 'Form' && readPretty,
|
'pattern-disable': block === 'Form' && readPretty,
|
||||||
|
fieldNames: {
|
||||||
|
label: isFileCollection ? 'preview' : 'id',
|
||||||
|
value: 'id',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
'x-decorator': 'FormItem',
|
'x-decorator': 'FormItem',
|
||||||
'x-collection-field': `${name}.${field.name}.${subField.name}`,
|
'x-collection-field': `${name}.${field.name}.${subField.name}`,
|
||||||
|
Loading…
Reference in New Issue
Block a user