fix: can't set default value when turn on the form field required (#1887)

* fix: can't set default value when turn on the form field required

* fix: can't set default value when turn on the association select field required
This commit is contained in:
black 2023-05-22 17:22:01 +08:00 committed by GitHub
parent 110b00bc01
commit db349ccb68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 6 deletions

View File

@ -160,6 +160,8 @@ AssociationSelect.Designer = function Designer() {
readOnlyMode = 'read-pretty';
}
const fieldSchemaWithoutRequired = _.omit(fieldSchema,'required')
return (
<GeneralSchemaDesigner>
<GeneralSchemaItems />
@ -299,10 +301,10 @@ AssociationSelect.Designer = function Designer() {
title: t('Set default value'),
properties: {
default: {
...(fieldSchema || {}),
...(fieldSchemaWithoutRequired || {}),
'x-decorator': 'FormItem',
'x-component-props': {
...fieldSchema['x-component-props'],
...fieldSchemaWithoutRequired['x-component-props'],
component: collectionField?.target ? 'AssociationSelect' : undefined,
service: {
resource: collectionField?.target,
@ -812,7 +814,7 @@ AssociationSelect.FilterDesigner = function FilterDesigner() {
title: t('Set default value'),
properties: {
default: {
...collectionField?.uiSchema,
..._.omit(collectionField?.uiSchema, 'required'),
name: 'default',
title: t('Default value'),
'x-decorator': 'FormItem',

View File

@ -172,6 +172,8 @@ FormItem.Designer = function Designer() {
};
});
const fieldSchemaWithoutRequired = _.omit(fieldSchema,'required')
return (
<GeneralSchemaDesigner>
<GeneralSchemaItems />
@ -352,7 +354,7 @@ FormItem.Designer = function Designer() {
properties: {
default: isInvariable(interfaceConfig)
? {
...(fieldSchema || {}),
...(fieldSchemaWithoutRequired || {}),
'x-decorator': 'FormItem',
'x-component-props': {
...fieldSchema['x-component-props'],
@ -375,7 +377,7 @@ FormItem.Designer = function Designer() {
'x-disabled': false,
}
: {
...(fieldSchema || {}),
...(fieldSchemaWithoutRequired || {}),
'x-decorator': 'FormItem',
'x-component': 'VariableInput',
'x-component-props': {
@ -384,7 +386,7 @@ FormItem.Designer = function Designer() {
schema: collectionField?.uiSchema,
className: defaultInputStyle,
renderSchemaComponent: function Com(props) {
const s = _.cloneDeep(fieldSchema) || ({} as Schema);
const s = _.cloneDeep(fieldSchemaWithoutRequired) || ({} as Schema);
s.title = '';
s['x-read-pretty'] = false;
s['x-disabled'] = false;