fix: fixed the configuration field filter (#1742)

* fix: fixed the configuration field filter

* fix: batch update filter automatic number field

* refactor: optimize code

---------

Co-authored-by: Rairn <958414905@qq.com>
This commit is contained in:
Jack 2023-04-26 11:20:58 +08:00 committed by GitHub
parent 00b3c8c257
commit de5260bc2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,6 @@
import { ISchema, Schema, useFieldSchema, useForm } from '@formily/react';
import { uid } from '@formily/shared';
import React, { useContext, useState } from 'react';
import React, { useContext, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { BlockRequestContext, SchemaInitializerItemOptions } from '../';
import { FieldOptions, useCollection, useCollectionManager } from '../collection-manager';
@ -560,7 +560,12 @@ export const useCustomFormItemInitializerFields = (options?: any) => {
const remove = useRemoveGridFormItem();
return currentFields
?.filter((field) => {
return field?.interface && !field?.uiSchema?.['x-read-pretty'] && field.interface !== 'snapshot';
return (
field?.interface &&
!field?.uiSchema?.['x-read-pretty'] &&
field.interface !== 'snapshot' &&
field.type !== 'sequence'
);
})
?.map((field) => {
const interfaceConfig = getInterface(field.interface);
@ -597,11 +602,18 @@ export const useCustomBulkEditFormItemInitializerFields = (options?: any) => {
const form = useForm();
const { readPretty = form.readPretty, block = 'Form' } = options || {};
const remove = useRemoveGridFormItem();
return fields
const filterFields = useMemo(
() =>
fields
?.filter((field) => {
return field?.interface && !field?.uiSchema?.['x-read-pretty'] && field.interface !== 'snapshot';
return (
field?.interface &&
!field?.uiSchema?.['x-read-pretty'] &&
field.interface !== 'snapshot' &&
field.type !== 'sequence'
);
})
?.map((field) => {
.map((field) => {
const interfaceConfig = getInterface(field.interface);
const schema = {
type: 'string',
@ -627,7 +639,11 @@ export const useCustomBulkEditFormItemInitializerFields = (options?: any) => {
},
schema,
} as SchemaInitializerItemOptions;
});
}),
[fields],
);
return filterFields;
};
const findSchema = (schema: Schema, key: string, action: string) => {