From f5f74382f81331aa4e927244b41ecfa0aaaed8e6 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: Fri, 20 Oct 2023 14:16:29 +0800 Subject: [PATCH] fix(variable): make all fields of currentForm and currentObject variable optional (#2878) --- .../VariableInput/hooks/useFormVariable.ts | 17 +++++++++-------- .../VariableInput/hooks/useIterationVariable.ts | 17 +++++++++-------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/packages/core/client/src/schema-settings/VariableInput/hooks/useFormVariable.ts b/packages/core/client/src/schema-settings/VariableInput/hooks/useFormVariable.ts index 001827473..6809bb486 100644 --- a/packages/core/client/src/schema-settings/VariableInput/hooks/useFormVariable.ts +++ b/packages/core/client/src/schema-settings/VariableInput/hooks/useFormVariable.ts @@ -1,6 +1,5 @@ import { Schema } from '@formily/json-schema'; import { useTranslation } from 'react-i18next'; -import { useFormActiveFields } from '../../../block-provider'; import { CollectionFieldOptions } from '../../../collection-manager'; import { useBaseVariable } from './useBaseVariable'; @@ -19,7 +18,7 @@ interface Props { * @returns */ export const useFormVariable = ({ collectionName, collectionField, schema, noDisabled, targetFieldSchema }: Props) => { - const { getActiveFieldsName } = useFormActiveFields() || {}; + // const { getActiveFieldsName } = useFormActiveFields() || {}; const { t } = useTranslation(); const result = useBaseVariable({ collectionField, @@ -31,13 +30,15 @@ export const useFormVariable = ({ collectionName, collectionField, schema, noDis collectionName: collectionName, noDisabled, returnFields: (fields, option) => { - const activeFieldsName = getActiveFieldsName?.('form') || []; + // fix https://nocobase.height.app/T-2277 + return fields; + // const activeFieldsName = getActiveFieldsName?.('form') || []; - return option.depth === 0 - ? fields.filter((field) => { - return activeFieldsName.includes(field.name); - }) - : fields; + // return option.depth === 0 + // ? fields.filter((field) => { + // return activeFieldsName.includes(field.name); + // }) + // : fields; }, }); diff --git a/packages/core/client/src/schema-settings/VariableInput/hooks/useIterationVariable.ts b/packages/core/client/src/schema-settings/VariableInput/hooks/useIterationVariable.ts index 0cfe4f432..10b1cec4f 100644 --- a/packages/core/client/src/schema-settings/VariableInput/hooks/useIterationVariable.ts +++ b/packages/core/client/src/schema-settings/VariableInput/hooks/useIterationVariable.ts @@ -1,6 +1,5 @@ import { Schema } from '@formily/json-schema'; import { useTranslation } from 'react-i18next'; -import { useFormActiveFields } from '../../../block-provider'; import { CollectionFieldOptions } from '../../../collection-manager'; import { useBaseVariable } from './useBaseVariable'; @@ -23,7 +22,7 @@ export const useIterationVariable = ({ /** 消费变量值的字段 */ targetFieldSchema?: Schema; }) => { - const { getActiveFieldsName } = useFormActiveFields() || {}; + // const { getActiveFieldsName } = useFormActiveFields() || {}; const { t } = useTranslation(); const result = useBaseVariable({ collectionField, @@ -35,13 +34,15 @@ export const useIterationVariable = ({ collectionName: currentCollection, noDisabled, returnFields: (fields, option) => { - const activeFieldsName = getActiveFieldsName?.('nester') || []; + // fix https://nocobase.height.app/T-2277 + return fields; + // const activeFieldsName = getActiveFieldsName?.('nester') || []; - return option.depth === 0 - ? fields.filter((field) => { - return activeFieldsName?.includes(field.name); - }) - : fields; + // return option.depth === 0 + // ? fields.filter((field) => { + // return activeFieldsName?.includes(field.name); + // }) + // : fields; }, });