fix: file collection field should default to preview as the title field

This commit is contained in:
katherinehhh 2023-06-15 21:56:21 +08:00
parent 6a8f998665
commit 7cce10c310

View File

@ -82,12 +82,20 @@ export const useTableColumnInitializerFields = () => {
) )
.map((field) => { .map((field) => {
const interfaceConfig = getInterface(field.interface); const interfaceConfig = getInterface(field.interface);
const isFileCollection = field?.target && getCollection(field?.target)?.template === 'file';
const schema = { const schema = {
name: field.name, name: field.name,
'x-collection-field': `${name}.${field.name}`, 'x-collection-field': `${name}.${field.name}`,
'x-component': 'CollectionField', 'x-component': 'CollectionField',
'x-read-pretty': true, 'x-read-pretty': true,
'x-component-props': {}, 'x-component-props': isFileCollection
? {
fieldNames: {
label: 'preview',
value: 'id',
},
}
: {},
}; };
// interfaceConfig?.schemaInitialize?.(schema, { field, readPretty: true, block: 'Table' }); // interfaceConfig?.schemaInitialize?.(schema, { field, readPretty: true, block: 'Table' });
return { return {