feat: relation field uiSchema (#487)
Co-authored-by: chenos <chenlinxh@gmail.com>
This commit is contained in:
parent
1b45f5366c
commit
a98213e2cd
@ -113,7 +113,7 @@ const useCreateCollectionField = () => {
|
|||||||
|
|
||||||
recursiveChildren(form?.values?.children);
|
recursiveChildren(form?.values?.children);
|
||||||
|
|
||||||
if (form?.values?.interface === 'linkTo' && title) {
|
if (['o2o', 'o2m', 'm2o', 'm2m', 'linkTo'].includes(form?.values?.interface) && title) {
|
||||||
form.setValuesIn('reverseField.uiSchema.title', title);
|
form.setValuesIn('reverseField.uiSchema.title', title);
|
||||||
}
|
}
|
||||||
await run();
|
await run();
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
import { ISchema } from '@formily/react';
|
import { ISchema } from '@formily/react';
|
||||||
import { cloneDeep } from 'lodash';
|
|
||||||
import { recordPickerSelector, recordPickerViewer } from './properties';
|
|
||||||
import { IField } from './types';
|
import { IField } from './types';
|
||||||
|
|
||||||
export const o2m: IField = {
|
export const o2m: IField = {
|
||||||
@ -15,16 +13,14 @@ export const o2m: IField = {
|
|||||||
// name,
|
// name,
|
||||||
uiSchema: {
|
uiSchema: {
|
||||||
// title,
|
// title,
|
||||||
'x-component': 'RecordPicker',
|
'x-component': 'TableField',
|
||||||
// type: 'void',
|
|
||||||
// 'x-component': 'TableField',
|
|
||||||
'x-component-props': {
|
'x-component-props': {
|
||||||
// mode: 'tags',
|
// mode: 'tags',
|
||||||
multiple: true,
|
// multiple: true,
|
||||||
fieldNames: {
|
// fieldNames: {
|
||||||
label: 'id',
|
// label: 'id',
|
||||||
value: 'id',
|
// value: 'id',
|
||||||
},
|
// },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
reverseField: {
|
reverseField: {
|
||||||
@ -45,16 +41,56 @@ export const o2m: IField = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
schemaInitialize(schema: ISchema, { readPretty }) {
|
schemaInitialize(schema: ISchema, { field, readPretty }) {
|
||||||
if (readPretty) {
|
const association = `${field.collectionName}.${field.name}`;
|
||||||
schema['properties'] = {
|
schema['type'] = 'void';
|
||||||
viewer: cloneDeep(recordPickerViewer),
|
schema['x-component'] = 'TableField';
|
||||||
};
|
schema['properties'] = {
|
||||||
} else {
|
block: {
|
||||||
schema['properties'] = {
|
type: 'void',
|
||||||
selector: cloneDeep(recordPickerSelector),
|
'x-decorator': 'TableFieldProvider',
|
||||||
};
|
'x-decorator-props': {
|
||||||
}
|
collection: field.target,
|
||||||
|
association: association,
|
||||||
|
resource: association,
|
||||||
|
action: 'list',
|
||||||
|
params: {
|
||||||
|
paginate: false,
|
||||||
|
},
|
||||||
|
showIndex: true,
|
||||||
|
dragSort: false,
|
||||||
|
},
|
||||||
|
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 }}',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
// if (readPretty) {
|
||||||
|
// schema['properties'] = {
|
||||||
|
// viewer: cloneDeep(recordPickerViewer),
|
||||||
|
// };
|
||||||
|
// } else {
|
||||||
|
// schema['properties'] = {
|
||||||
|
// selector: cloneDeep(recordPickerSelector),
|
||||||
|
// };
|
||||||
|
// }
|
||||||
},
|
},
|
||||||
properties: {
|
properties: {
|
||||||
'uiSchema.title': {
|
'uiSchema.title': {
|
||||||
|
Loading…
Reference in New Issue
Block a user