refactor: attachment field support size config (#2552)
* refactor: attachment field support size config * style: style improve
This commit is contained in:
parent
7dd7a65a38
commit
291859d6b5
@ -223,6 +223,8 @@ FormItem.Designer = function Designer() {
|
|||||||
const showFieldMode = isAssociationField && fieldModeOptions && !isTableField;
|
const showFieldMode = isAssociationField && fieldModeOptions && !isTableField;
|
||||||
const showModeSelect = showFieldMode && isPickerMode;
|
const showModeSelect = showFieldMode && isPickerMode;
|
||||||
const isDateField = ['datetime', 'createdAt', 'updatedAt'].includes(collectionField?.interface);
|
const isDateField = ['datetime', 'createdAt', 'updatedAt'].includes(collectionField?.interface);
|
||||||
|
const isAttachmentField =
|
||||||
|
['attachment'].includes(collectionField?.interface) || targetCollection?.template === 'file';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<GeneralSchemaDesigner>
|
<GeneralSchemaDesigner>
|
||||||
@ -727,6 +729,33 @@ FormItem.Designer = function Designer() {
|
|||||||
)}
|
)}
|
||||||
{isDateField && <SchemaSettings.DataFormat fieldSchema={fieldSchema} />}
|
{isDateField && <SchemaSettings.DataFormat fieldSchema={fieldSchema} />}
|
||||||
|
|
||||||
|
{isAttachmentField && field.readPretty && (
|
||||||
|
<SchemaSettings.SelectItem
|
||||||
|
key="size"
|
||||||
|
title={t('Size')}
|
||||||
|
options={[
|
||||||
|
{ label: t('Large'), value: 'large' },
|
||||||
|
{ label: t('Default'), value: 'default' },
|
||||||
|
{ label: t('Small'), value: 'small' },
|
||||||
|
]}
|
||||||
|
value={field?.componentProps?.size || 'default'}
|
||||||
|
onChange={(size) => {
|
||||||
|
const schema = {
|
||||||
|
['x-uid']: fieldSchema['x-uid'],
|
||||||
|
};
|
||||||
|
fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
|
||||||
|
fieldSchema['x-component-props']['size'] = size;
|
||||||
|
schema['x-component-props'] = fieldSchema['x-component-props'];
|
||||||
|
field.componentProps = field.componentProps || {};
|
||||||
|
field.componentProps.size = size;
|
||||||
|
dn.emit('patch', {
|
||||||
|
schema,
|
||||||
|
});
|
||||||
|
dn.refresh();
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
{isAssociationField && ['Tag'].includes(fieldMode) && (
|
{isAssociationField && ['Tag'].includes(fieldMode) && (
|
||||||
<SchemaSettings.SelectItem
|
<SchemaSettings.SelectItem
|
||||||
key="title-field"
|
key="title-field"
|
||||||
@ -768,11 +797,6 @@ export function isFileCollection(collection: Collection) {
|
|||||||
return collection?.template === 'file';
|
return collection?.template === 'file';
|
||||||
}
|
}
|
||||||
|
|
||||||
function extractFirstPart(path) {
|
|
||||||
const firstDotIndex = path.indexOf('.');
|
|
||||||
return firstDotIndex !== -1 ? path.slice(0, firstDotIndex) : path;
|
|
||||||
}
|
|
||||||
|
|
||||||
FormItem.FilterFormDesigner = FilterFormDesigner;
|
FormItem.FilterFormDesigner = FilterFormDesigner;
|
||||||
|
|
||||||
export function getFieldDefaultValue(fieldSchema: ISchema, collectionField: CollectionFieldOptions) {
|
export function getFieldDefaultValue(fieldSchema: ISchema, collectionField: CollectionFieldOptions) {
|
||||||
|
@ -20,7 +20,14 @@ export const useStyles = genStyleHook('upload', (token) => {
|
|||||||
padding: '1px !important',
|
padding: '1px !important',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
'&.nb-upload-large': {
|
||||||
|
[`${componentCls}-list-picture-card-container${componentCls}-list-picture-card-container`]: {
|
||||||
|
margin: '0 3px 3px 0 !important',
|
||||||
|
height: '160px !important',
|
||||||
|
width: '160px !important',
|
||||||
|
marginBlock: '0 28px !important',
|
||||||
|
},
|
||||||
|
},
|
||||||
'&.nb-upload': {
|
'&.nb-upload': {
|
||||||
[`${componentCls}-list-item${componentCls}-list-item-list-type-picture-card`]: {
|
[`${componentCls}-list-item${componentCls}-list-item-list-type-picture-card`]: {
|
||||||
padding: '3px !important',
|
padding: '3px !important',
|
||||||
|
Loading…
Reference in New Issue
Block a user