From 95e1cd390b0bce8a66e366e179e77a729805f296 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A2=AB=E9=9B=A8=E6=B0=B4=E8=BF=87=E6=BB=A4=E7=9A=84?= =?UTF-8?q?=E7=A9=BA=E6=B0=94-Rain?= <958414905@qq.com> Date: Sun, 20 Aug 2023 12:08:07 +0800 Subject: [PATCH] chore: remove Default value option for sequence field (#2488) * chore: remove Default value option for sequence field * chore: remove console.log --- .../antd/form-item/FormItem.tsx | 3 +- .../src/schema-settings/SchemaSettings.tsx | 30 ++++++++++++------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/packages/core/client/src/schema-component/antd/form-item/FormItem.tsx b/packages/core/client/src/schema-component/antd/form-item/FormItem.tsx index 75fac30cb..a481f007a 100644 --- a/packages/core/client/src/schema-component/antd/form-item/FormItem.tsx +++ b/packages/core/client/src/schema-component/antd/form-item/FormItem.tsx @@ -1,5 +1,5 @@ import { css, cx } from '@emotion/css'; -import { ArrayCollapse, ArrayItems, FormLayout, FormItem as Item } from '@formily/antd-v5'; +import { ArrayCollapse, FormLayout, FormItem as Item } from '@formily/antd-v5'; import { Field } from '@formily/core'; import { ISchema, observer, useField, useFieldSchema } from '@formily/react'; import { Select } from 'antd'; @@ -70,6 +70,7 @@ export const FormItem: any = observer( const variablesCtx = useVariablesCtx(); const { getCollectionJoinField } = useCollectionManager(); const collectionField = getCollectionJoinField(schema['x-collection-field']); + useEffect(() => { if (ctx?.block === 'form') { ctx.field.data = ctx.field.data || {}; diff --git a/packages/core/client/src/schema-settings/SchemaSettings.tsx b/packages/core/client/src/schema-settings/SchemaSettings.tsx index eef1603d5..8b8df1eaa 100644 --- a/packages/core/client/src/schema-settings/SchemaSettings.tsx +++ b/packages/core/client/src/schema-settings/SchemaSettings.tsx @@ -1,6 +1,6 @@ import { css } from '@emotion/css'; import { ArrayCollapse, ArrayItems, FormItem, FormLayout, Input } from '@formily/antd-v5'; -import { createForm, Field, GeneralField } from '@formily/core'; +import { Field, GeneralField, createForm } from '@formily/core'; import { ISchema, Schema, SchemaOptionsContext, useField, useFieldSchema, useForm } from '@formily/react'; import { uid } from '@formily/shared'; import { error } from '@nocobase/utils/client'; @@ -21,33 +21,34 @@ import { } from 'antd'; import _, { cloneDeep } from 'lodash'; import React, { - createContext, ReactNode, + createContext, useCallback, useContext, useMemo, - useState, // @ts-ignore useTransition as useReactTransition, + useState, } from 'react'; import { createPortal } from 'react-dom'; import { useTranslation } from 'react-i18next'; import { - ActionContextProvider, APIClientProvider, + ActionContextProvider, CollectionFieldOptions, CollectionManagerContext, CollectionProvider, - createDesignable, Designable, - findFormBlock, FormDialog, FormProvider, RemoteSchemaComponent, SchemaComponent, SchemaComponentContext, SchemaComponentOptions, + createDesignable, + findFormBlock, useAPIClient, + useActionContext, useBlockRequestContext, useCollection, useCollectionManager, @@ -57,7 +58,6 @@ import { useGlobalTheme, useLinkageCollectionFilterOptions, useSortFields, - useActionContext, } from '..'; import { useTableBlockContext } from '../block-provider'; import { findFilterTargets, updateFilterTargets } from '../block-provider/hooks'; @@ -1678,9 +1678,19 @@ SchemaSettings.SortingRule = function SortRuleConfigure(props) { // 是否显示默认值配置项 export const isShowDefaultValue = (collectionField: CollectionFieldOptions, getInterface) => { return ( - !['o2o', 'oho', 'obo', 'o2m', 'attachment', 'expression', 'point', 'lineString', 'circle', 'polygon'].includes( - collectionField?.interface, - ) && !isSystemField(collectionField, getInterface) + ![ + 'o2o', + 'oho', + 'obo', + 'o2m', + 'attachment', + 'expression', + 'point', + 'lineString', + 'circle', + 'polygon', + 'sequence', + ].includes(collectionField?.interface) && !isSystemField(collectionField, getInterface) ); };