From e7cb99ea47b03b7c093f175a559b6c1e49b9a65e Mon Sep 17 00:00:00 2001 From: Katherine Date: Sun, 17 Nov 2024 13:51:06 +0800 Subject: [PATCH] fix: field assignment to support variable value as 0 (#5663) * fix: associationFieldMobile * fix: bug --- .../client/src/block-provider/hooks/index.ts | 3 +-- .../client/pages/dynamic-page/MobilePage.tsx | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/packages/core/client/src/block-provider/hooks/index.ts b/packages/core/client/src/block-provider/hooks/index.ts index f06e3f72b8..14641d1093 100644 --- a/packages/core/client/src/block-provider/hooks/index.ts +++ b/packages/core/client/src/block-provider/hooks/index.ts @@ -156,7 +156,6 @@ export function useCollectValuesToSubmit() { const waitList = Object.keys(originalAssignedValues).map(async (key) => { const value = originalAssignedValues[key]; const collectionField = getField(key); - if (process.env.NODE_ENV !== 'production') { if (!collectionField) { throw new Error(`field "${key}" not found in collection "${name}"`); @@ -165,7 +164,7 @@ export function useCollectValuesToSubmit() { if (isVariable(value)) { const { value: parsedValue } = (await variables?.parseVariable(value, localVariables)) || {}; - if (parsedValue) { + if (parsedValue !== null && parsedValue !== undefined) { assignedValues[key] = transformVariableValue(parsedValue, { targetCollectionField: collectionField }); } } else if (value != null && value !== '') { diff --git a/packages/plugins/@nocobase/plugin-mobile/src/client/pages/dynamic-page/MobilePage.tsx b/packages/plugins/@nocobase/plugin-mobile/src/client/pages/dynamic-page/MobilePage.tsx index 0a26980056..cf62fea74c 100644 --- a/packages/plugins/@nocobase/plugin-mobile/src/client/pages/dynamic-page/MobilePage.tsx +++ b/packages/plugins/@nocobase/plugin-mobile/src/client/pages/dynamic-page/MobilePage.tsx @@ -14,6 +14,19 @@ import { Button as MobileButton, Dialog as MobileDialog } from 'antd-mobile'; import { MobilePicker } from './components/MobilePicker'; import { MobileDateTimePicker } from './components/MobileDatePicker'; +const AssociationFieldMobile = (props) => { + return ; +}; + +AssociationFieldMobile.SubTable = AssociationField.SubTable; +AssociationFieldMobile.Nester = AssociationField.Nester; +AssociationFieldMobile.AddNewer = AssociationField.Container; +AssociationFieldMobile.Selector = AssociationField.Container; +AssociationFieldMobile.Viewer = AssociationField.Container; +AssociationFieldMobile.InternalSelect = AssociationField.InternalSelect; +AssociationFieldMobile.ReadPretty = AssociationField.ReadPretty; +AssociationFieldMobile.FileSelector = AssociationField.FileSelector; + const mobileComponents = { Button: MobileButton, Select: (props) => { @@ -34,9 +47,7 @@ const mobileComponents = { }, UnixTimestamp: MobileDateTimePicker, Modal: MobileDialog, - AssociationField: (props) => { - return ; - }, + AssociationField: AssociationFieldMobile, }; export const MobilePage = () => {