fix(client): select component cannot be opened in sub-table block (#431)

This commit is contained in:
金昶 2022-05-29 11:52:25 +08:00 committed by GitHub
parent 9a64384bc1
commit e51feafe53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 0 deletions

View File

@ -94,6 +94,24 @@ const useCreateCollectionField = () => {
}),
);
}
function recursiveChildren(children = [], prefix = 'children') {
children.forEach((item, index) => {
const itemOptions = item.uiSchema?.enum?.slice() || [];
form.setValuesIn(
`${prefix}[${index}].uiSchema.enum`,
itemOptions.map((option) => {
return {
value: uid(),
...option,
};
}),
);
recursiveChildren(item.children, `${prefix}[${index}].children`);
});
}
recursiveChildren(form?.values?.children);
if (form?.values?.interface === 'linkTo' && title) {
form.setValuesIn('reverseField.uiSchema.title', title);
}

View File

@ -83,6 +83,25 @@ const useUpdateCollectionField = () => {
};
}),
);
function recursiveChildren(children = [], prefix = 'children') {
children.forEach((item, index) => {
const itemOptions = item.uiSchema?.enum?.slice() || [];
form.setValuesIn(
`${prefix}[${index}].uiSchema.enum`,
itemOptions.map((option) => {
return {
value: uid(),
...option,
};
}),
);
recursiveChildren(item.children, `${prefix}[${index}].children`);
});
}
recursiveChildren(form?.values?.children);
await run();
await refreshCM();
},