fix: association field in assign field should set title field as collection field config (#2839)
This commit is contained in:
parent
a693f1c79e
commit
6a7e7b3594
@ -47,7 +47,8 @@ export const m2m: IField = {
|
|||||||
availableTypes: ['belongsToMany'],
|
availableTypes: ['belongsToMany'],
|
||||||
schemaInitialize(schema: ISchema, { readPretty, block, targetCollection }) {
|
schemaInitialize(schema: ISchema, { readPretty, block, targetCollection }) {
|
||||||
// schema['type'] = 'array';
|
// schema['type'] = 'array';
|
||||||
if (targetCollection?.titleField && schema['x-component-props']) {
|
if (targetCollection?.titleField) {
|
||||||
|
schema['x-component-props'] = schema['x-component-props'] || {};
|
||||||
schema['x-component-props'].fieldNames = schema['x-component-props'].fieldNames || { value: 'id' };
|
schema['x-component-props'].fieldNames = schema['x-component-props'].fieldNames || { value: 'id' };
|
||||||
schema['x-component-props'].fieldNames.label = targetCollection.titleField;
|
schema['x-component-props'].fieldNames.label = targetCollection.titleField;
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,8 @@ export const m2o: IField = {
|
|||||||
availableTypes: ['belongsTo'],
|
availableTypes: ['belongsTo'],
|
||||||
schemaInitialize(schema: ISchema, { block, readPretty, targetCollection }) {
|
schemaInitialize(schema: ISchema, { block, readPretty, targetCollection }) {
|
||||||
// schema['type'] = 'object';
|
// schema['type'] = 'object';
|
||||||
if (targetCollection?.titleField && schema['x-component-props']) {
|
if (targetCollection?.titleField) {
|
||||||
|
schema['x-component-props'] = schema['x-component-props'] || {};
|
||||||
schema['x-component-props'].fieldNames = schema['x-component-props'].fieldNames || { value: 'id' };
|
schema['x-component-props'].fieldNames = schema['x-component-props'].fieldNames || { value: 'id' };
|
||||||
schema['x-component-props'].fieldNames.label = targetCollection.titleField;
|
schema['x-component-props'].fieldNames.label = targetCollection.titleField;
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,8 @@ export const o2m: IField = {
|
|||||||
availableTypes: ['hasMany'],
|
availableTypes: ['hasMany'],
|
||||||
schemaInitialize(schema: ISchema, { field, block, readPretty, targetCollection }) {
|
schemaInitialize(schema: ISchema, { field, block, readPretty, targetCollection }) {
|
||||||
// schema['type'] = 'array';
|
// schema['type'] = 'array';
|
||||||
if (targetCollection?.titleField && schema['x-component-props']) {
|
if (targetCollection?.titleField) {
|
||||||
|
schema['x-component-props'] = schema['x-component-props'] || {};
|
||||||
schema['x-component-props'].fieldNames = schema['x-component-props'].fieldNames || { value: 'id' };
|
schema['x-component-props'].fieldNames = schema['x-component-props'].fieldNames || { value: 'id' };
|
||||||
schema['x-component-props'].fieldNames.label = targetCollection.titleField;
|
schema['x-component-props'].fieldNames.label = targetCollection.titleField;
|
||||||
}
|
}
|
||||||
|
@ -400,7 +400,8 @@ export const obo: IField = {
|
|||||||
schema['x-component-props']['size'] = 'small';
|
schema['x-component-props']['size'] = 'small';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (targetCollection?.titleField && schema['x-component-props']) {
|
if (targetCollection?.titleField) {
|
||||||
|
schema['x-component-props'] = schema['x-component-props'] || {};
|
||||||
schema['x-component-props'].fieldNames = schema['x-component-props'].fieldNames || { value: 'id' };
|
schema['x-component-props'].fieldNames = schema['x-component-props'].fieldNames || { value: 'id' };
|
||||||
schema['x-component-props'].fieldNames.label = targetCollection.titleField;
|
schema['x-component-props'].fieldNames.label = targetCollection.titleField;
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,7 @@ const InternalAssociationSelect = observer((props: AssociationSelectProps) => {
|
|||||||
const { objectValue = true } = props;
|
const { objectValue = true } = props;
|
||||||
const field: any = useField();
|
const field: any = useField();
|
||||||
const fieldSchema = useFieldSchema();
|
const fieldSchema = useFieldSchema();
|
||||||
|
console.log(fieldSchema);
|
||||||
const service = useServiceOptions(props);
|
const service = useServiceOptions(props);
|
||||||
const { options: collectionField } = useAssociationFieldContext();
|
const { options: collectionField } = useAssociationFieldContext();
|
||||||
const initValue = isVariable(props.value) ? undefined : props.value;
|
const initValue = isVariable(props.value) ? undefined : props.value;
|
||||||
|
@ -50,6 +50,7 @@ export function useAssociationFieldContext<F extends GeneralField>() {
|
|||||||
|
|
||||||
export default function useServiceOptions(props) {
|
export default function useServiceOptions(props) {
|
||||||
const { action = 'list', service, fieldNames } = props;
|
const { action = 'list', service, fieldNames } = props;
|
||||||
|
console.log(fieldNames);
|
||||||
const params = service?.params || {};
|
const params = service?.params || {};
|
||||||
const fieldSchema = useFieldSchema();
|
const fieldSchema = useFieldSchema();
|
||||||
const field = useField();
|
const field = useField();
|
||||||
|
@ -134,7 +134,7 @@ export const AssignedField = (props: AssignedFieldProps) => {
|
|||||||
},
|
},
|
||||||
[JSON.stringify(_.omit(props, 'value'))],
|
[JSON.stringify(_.omit(props, 'value'))],
|
||||||
);
|
);
|
||||||
|
console.log(fieldSchema, collectionField);
|
||||||
return (
|
return (
|
||||||
<VariableInput
|
<VariableInput
|
||||||
form={form}
|
form={form}
|
||||||
|
Loading…
Reference in New Issue
Block a user