diff --git a/packages/core/client/src/collection-manager/interfaces/linkTo.ts b/packages/core/client/src/collection-manager/interfaces/linkTo.ts index 7421245f15..e0701d74e3 100644 --- a/packages/core/client/src/collection-manager/interfaces/linkTo.ts +++ b/packages/core/client/src/collection-manager/interfaces/linkTo.ts @@ -47,50 +47,13 @@ export const linkTo: IField = { }, availableTypes: ['belongsToMany'], schemaInitialize(schema: ISchema, { readPretty, block, targetCollection }) { - return; if (targetCollection?.titleField && schema['x-component-props']) { schema['x-component-props'].fieldNames = schema['x-component-props'].fieldNames || { value: 'id' }; schema['x-component-props'].fieldNames.label = targetCollection.titleField; } - - if (targetCollection?.template === 'file') { - const fieldNames = schema['x-component-props']['fieldNames'] || { label: 'preview', value: 'id' }; - fieldNames.label = 'preview'; - schema['x-component-props']['fieldNames'] = fieldNames; - schema['x-component-props'].quickUpload = true; - schema['x-component-props'].selectFile = true; - } - - if (block === 'Form') { - if (schema['x-component'] === 'AssociationSelect') { - Object.assign(schema, { - type: 'string', - 'x-designer': 'AssociationSelect.Designer', - }); - } else { - schema.type = 'string'; - schema['properties'] = { - viewer: cloneDeep(recordPickerViewer), - selector: cloneDeep(recordPickerSelector), - }; - } - return schema; - } else { - if (readPretty) { - schema['properties'] = { - viewer: cloneDeep(recordPickerViewer), - }; - } else { - schema['properties'] = { - selector: cloneDeep(recordPickerSelector), - }; - } - } - if (['Table', 'Kanban'].includes(block)) { schema['x-component-props'] = schema['x-component-props'] || {}; schema['x-component-props']['ellipsis'] = true; - // 预览文件时需要的参数 schema['x-component-props']['size'] = 'small'; } diff --git a/packages/core/client/src/collection-manager/interfaces/m2m.tsx b/packages/core/client/src/collection-manager/interfaces/m2m.tsx index afefe09256..1998730ec8 100644 --- a/packages/core/client/src/collection-manager/interfaces/m2m.tsx +++ b/packages/core/client/src/collection-manager/interfaces/m2m.tsx @@ -54,48 +54,13 @@ export const m2m: IField = { availableTypes: ['belongsToMany'], schemaInitialize(schema: ISchema, { readPretty, block, targetCollection }) { schema['type'] = 'array'; - return; if (targetCollection?.titleField && schema['x-component-props']) { schema['x-component-props'].fieldNames = schema['x-component-props'].fieldNames || { value: 'id' }; schema['x-component-props'].fieldNames.label = targetCollection.titleField; } - - if (targetCollection?.template === 'file') { - const fieldNames = schema['x-component-props']['fieldNames'] || { label: 'preview', value: 'id' }; - fieldNames.label = 'preview'; - schema['x-component-props']['fieldNames'] = fieldNames; - schema['x-component-props'].quickUpload = true; - schema['x-component-props'].selectFile = true; - } - - if (block === 'Form') { - if (schema['x-component'] === 'AssociationSelect') { - Object.assign(schema, { - type: 'string', - 'x-designer': 'AssociationSelect.Designer', - }); - } else { - schema.type = 'string'; - schema['properties'] = { - viewer: cloneDeep(recordPickerViewer), - selector: cloneDeep(recordPickerSelector), - }; - } - return schema; - } - if (readPretty) { - schema['properties'] = { - viewer: cloneDeep(recordPickerViewer), - }; - } else { - schema['properties'] = { - selector: cloneDeep(recordPickerSelector), - }; - } if (['Table', 'Kanban'].includes(block)) { schema['x-component-props'] = schema['x-component-props'] || {}; schema['x-component-props']['ellipsis'] = true; - // 预览文件时需要的参数 schema['x-component-props']['size'] = 'small'; } diff --git a/packages/core/client/src/collection-manager/interfaces/m2o.tsx b/packages/core/client/src/collection-manager/interfaces/m2o.tsx index e4cb1a9113..69c28a5a0a 100644 --- a/packages/core/client/src/collection-manager/interfaces/m2o.tsx +++ b/packages/core/client/src/collection-manager/interfaces/m2o.tsx @@ -53,48 +53,13 @@ export const m2o: IField = { availableTypes: ['belongsTo'], schemaInitialize(schema: ISchema, { block, readPretty, targetCollection }) { schema['type'] = 'object'; - return; if (targetCollection?.titleField && schema['x-component-props']) { schema['x-component-props'].fieldNames = schema['x-component-props'].fieldNames || { value: 'id' }; schema['x-component-props'].fieldNames.label = targetCollection.titleField; } - - if (targetCollection?.template === 'file') { - const fieldNames = schema['x-component-props']['fieldNames'] || { label: 'preview', value: 'id' }; - fieldNames.label = 'preview'; - schema['x-component-props']['fieldNames'] = fieldNames; - schema['x-component-props'].quickUpload = true; - schema['x-component-props'].selectFile = true; - } - - if (block === 'Form') { - if (schema['x-component'] === 'AssociationSelect') { - Object.assign(schema, { - type: 'string', - 'x-designer': 'AssociationSelect.Designer', - }); - } else { - schema.type = 'string'; - schema['properties'] = { - viewer: cloneDeep(recordPickerViewer), - selector: cloneDeep(recordPickerSelector), - }; - } - return schema; - } - if (readPretty) { - schema['properties'] = { - viewer: cloneDeep(recordPickerViewer), - }; - } else { - schema['properties'] = { - selector: cloneDeep(recordPickerSelector), - }; - } if (['Table', 'Kanban'].includes(block)) { schema['x-component-props'] = schema['x-component-props'] || {}; schema['x-component-props']['ellipsis'] = true; - // 预览文件时需要的参数 schema['x-component-props']['size'] = 'small'; } diff --git a/packages/core/client/src/collection-manager/interfaces/o2m.tsx b/packages/core/client/src/collection-manager/interfaces/o2m.tsx index 43f9c1f7af..4267cca521 100644 --- a/packages/core/client/src/collection-manager/interfaces/o2m.tsx +++ b/packages/core/client/src/collection-manager/interfaces/o2m.tsx @@ -53,83 +53,13 @@ export const o2m: IField = { availableTypes: ['hasMany'], schemaInitialize(schema: ISchema, { field, block, readPretty, targetCollection }) { schema['type'] = 'array'; - return; if (targetCollection?.titleField && schema['x-component-props']) { schema['x-component-props'].fieldNames = schema['x-component-props'].fieldNames || { value: 'id' }; schema['x-component-props'].fieldNames.label = targetCollection.titleField; } - - if (block === 'Form') { - if (schema['x-component'] === 'TableField') { - const association = `${field.collectionName}.${field.name}`; - schema['type'] = 'void'; - schema['properties'] = { - block: { - type: 'void', - 'x-decorator': 'TableFieldProvider', - 'x-acl-action': `${association}:list`, - 'x-decorator-props': { - collection: field.target, - association: association, - resource: association, - action: 'list', - params: { - paginate: false, - }, - showIndex: true, - dragSort: false, - fieldName: field.name, - }, - properties: { - actions: { - type: 'void', - 'x-initializer': 'SubTableActionInitializers', - 'x-component': 'TableField.ActionBar', - 'x-component-props': {}, - }, - [field.name]: { - type: 'array', - 'x-initializer': 'TableColumnInitializers', - 'x-component': 'TableV2', - 'x-component-props': { - rowSelection: { - type: 'checkbox', - }, - useProps: '{{ useTableFieldProps }}', - }, - }, - }, - }, - }; - } else if (schema['x-component'] === 'AssociationSelect') { - Object.assign(schema, { - type: 'string', - 'x-designer': 'AssociationSelect.Designer', - }); - } else { - schema.type = 'string'; - schema['properties'] = { - viewer: cloneDeep(recordPickerViewer), - selector: cloneDeep(recordPickerSelector), - }; - } - return schema; - } - - if (readPretty) { - schema['properties'] = { - viewer: cloneDeep(recordPickerViewer), - }; - } else { - schema['properties'] = { - selector: cloneDeep(recordPickerSelector), - }; - } - if (['Table', 'Kanban'].includes(block)) { schema['x-component-props'] = schema['x-component-props'] || {}; schema['x-component-props']['ellipsis'] = true; - // 预览文件时需要的参数 schema['x-component-props']['size'] = 'small'; } diff --git a/packages/core/client/src/collection-manager/interfaces/o2o.tsx b/packages/core/client/src/collection-manager/interfaces/o2o.tsx index 3de1c73d7a..f72aa926e6 100644 --- a/packages/core/client/src/collection-manager/interfaces/o2o.tsx +++ b/packages/core/client/src/collection-manager/interfaces/o2o.tsx @@ -9,72 +9,6 @@ import { } from './properties'; import { IField } from './types'; -const internalSchameInitialize = (schema: ISchema, { field, block, readPretty, action }) => { - if (block === 'Form') { - if (schema['x-component'] === 'FormField') { - const association = `${field.collectionName}.${field.name}`; - schema.type = 'void'; - schema.properties = { - block: { - type: 'void', - 'x-decorator': 'FormFieldProvider', - 'x-decorator-props': { - collection: field.target, - association: association, - resource: association, - action: action, - fieldName: field.name, - readPretty, - }, - 'x-component': 'CardItem', - 'x-component-props': { - bordered: true, - }, - properties: { - [field.name]: { - type: 'object', - 'x-component': 'FormV2', - 'x-component-props': { - useProps: '{{ useFormFieldProps }}', - }, - properties: { - __form_grid: { - type: 'void', - 'x-component': 'Grid', - 'x-initializer': 'FormItemInitializers', - properties: {}, - }, - }, - }, - }, - }, - }; - } else if (schema['x-component'] === 'AssociationSelect') { - Object.assign(schema, { - type: 'string', - 'x-designer': 'AssociationSelect.Designer', - }); - } else { - schema.type = 'string'; - schema['properties'] = { - viewer: cloneDeep(recordPickerViewer), - selector: cloneDeep(recordPickerSelector), - }; - } - return schema; - } - schema.type = 'string'; - if (readPretty) { - schema['properties'] = { - viewer: cloneDeep(recordPickerViewer), - }; - } else { - schema['properties'] = { - selector: cloneDeep(recordPickerSelector), - }; - } -}; - export const o2o: IField = { name: 'o2o', type: 'object', @@ -119,8 +53,6 @@ export const o2o: IField = { }, availableTypes: ['hasOne'], schemaInitialize(schema: ISchema, { field, block, readPretty, action }) { - return; - internalSchameInitialize(schema, { field, block, readPretty, action }); if (['Table', 'Kanban'].includes(block)) { schema['x-component-props'] = schema['x-component-props'] || {}; schema['x-component-props']['ellipsis'] = true; @@ -300,8 +232,6 @@ export const oho: IField = { }, schemaInitialize(schema: ISchema, { field, block, readPretty, action }) { schema['type'] = 'object'; - return; - internalSchameInitialize(schema, { field, block, readPretty, action }); if (['Table', 'Kanban'].includes(block)) { schema['x-component-props'] = schema['x-component-props'] || {}; schema['x-component-props']['ellipsis'] = true; @@ -472,12 +402,9 @@ export const obo: IField = { }, schemaInitialize(schema: ISchema, { field, block, readPretty, action, targetCollection }) { schema['type'] = 'object'; - return; - internalSchameInitialize(schema, { field, block, readPretty, action }); if (['Table', 'Kanban'].includes(block)) { schema['x-component-props'] = schema['x-component-props'] || {}; schema['x-component-props']['ellipsis'] = true; - // 预览文件时需要的参数 schema['x-component-props']['size'] = 'small'; } @@ -486,14 +413,6 @@ export const obo: IField = { schema['x-component-props'].fieldNames = schema['x-component-props'].fieldNames || { value: 'id' }; schema['x-component-props'].fieldNames.label = targetCollection.titleField; } - - if (targetCollection?.template === 'file') { - const fieldNames = schema['x-component-props']['fieldNames'] || { label: 'preview', value: 'id' }; - fieldNames.label = 'preview'; - schema['x-component-props']['fieldNames'] = fieldNames; - schema['x-component-props'].quickUpload = true; - schema['x-component-props'].selectFile = true; - } }, properties: { 'uiSchema.title': { diff --git a/packages/core/client/src/schema-component/antd/association-field/FileManager.tsx b/packages/core/client/src/schema-component/antd/association-field/FileManager.tsx index e9cff386c0..6acc13919c 100644 --- a/packages/core/client/src/schema-component/antd/association-field/FileManager.tsx +++ b/packages/core/client/src/schema-component/antd/association-field/FileManager.tsx @@ -65,6 +65,7 @@ const InternalFileManager = (props) => { const [selectedRows, setSelectedRows] = useState([]); const insertSelector = useInsertSchema('Selector'); const fieldNames = useFieldNames(props); + console.log(fieldNames) const field: any = useField(); const [options, setOptions] = useState([]); const { getField } = useCollection(); @@ -179,6 +180,7 @@ const FileManageReadPretty = connect((props) => { const field: any = useField(); const { getField } = useCollection(); const collectionField = getField(field.props.name); + console.log(props) return collectionField ? : null; }); diff --git a/packages/core/client/src/schema-component/antd/association-field/ReadPretty.tsx b/packages/core/client/src/schema-component/antd/association-field/ReadPretty.tsx index 542d47121d..387d85c1d2 100644 --- a/packages/core/client/src/schema-component/antd/association-field/ReadPretty.tsx +++ b/packages/core/client/src/schema-component/antd/association-field/ReadPretty.tsx @@ -16,6 +16,7 @@ export const ReadPretty = (props) => { const collectionField = getField(field.props.name); const isFileCollection = getCollection(collectionField?.target).template === 'file'; const [currentMode, setCurrentMode] = useState(props.mode || isFileCollection ? 'FileManager' : 'Select'); + console.log(props) useEffect(() => { props.mode && setCurrentMode(props.mode); }, [props.mode]);