fix: support attachment showCount set (#801)

Reviewed-on: daoyoucloud/tachybase#801
Co-authored-by: bai.zixv <bai.zixv@foxmail.com>
Co-committed-by: bai.zixv <bai.zixv@foxmail.com>
This commit is contained in:
bai.zixv 2024-04-22 21:26:30 +08:00 committed by sealday
parent eeed385ea1
commit a5f2dea973

View File

@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next';
import { SchemaSettings } from '../../../../application/schema-settings/SchemaSettings'; import { SchemaSettings } from '../../../../application/schema-settings/SchemaSettings';
import { useDesignable } from '../../../../schema-component'; import { useDesignable } from '../../../../schema-component';
import { useIsFieldReadPretty } from '../../../../schema-component/antd/form-item/FormItem.Settings'; import { useIsFieldReadPretty } from '../../../../schema-component/antd/form-item/FormItem.Settings';
import { useColumnSchema } from '../../../../schema-component/antd/table-v2/Table.Column.Decorator';
export const uploadAttachmentComponentFieldSettings = new SchemaSettings({ export const uploadAttachmentComponentFieldSettings = new SchemaSettings({
name: 'fieldSettings:component:Upload.Attachment', name: 'fieldSettings:component:Upload.Attachment',
@ -49,9 +50,10 @@ export const uploadAttachmentComponentFieldSettings = new SchemaSettings({
name: 'showCount', name: 'showCount',
type: 'modal', type: 'modal',
useComponentProps() { useComponentProps() {
const field: any = useField();
const { t } = useTranslation(); const { t } = useTranslation();
const showCountSchema = useFieldSchema(); const { fieldSchema: tableColumnSchema } = useColumnSchema();
const schema = useFieldSchema();
const showCountSchema = tableColumnSchema || schema;
const { dn } = useDesignable(); const { dn } = useDesignable();
return { return {
@ -74,7 +76,6 @@ export const uploadAttachmentComponentFieldSettings = new SchemaSettings({
onSubmit: ({ showCount }) => { onSubmit: ({ showCount }) => {
const props = showCountSchema['x-component-props'] || {}; const props = showCountSchema['x-component-props'] || {};
props.showCount = showCount; props.showCount = showCount;
field.componentProps.showCount = showCount;
const schema = { const schema = {
['x-uid']: showCountSchema['x-uid'], ['x-uid']: showCountSchema['x-uid'],
['x-component-props']: props, ['x-component-props']: props,