From 8530da7c23212a193acc2a4c29e1d206a10dfc23 Mon Sep 17 00:00:00 2001 From: YANG QIA <2013xile@gmail.com> Date: Mon, 15 Jan 2024 23:46:29 +0800 Subject: [PATCH] fix: fix T-2916 (#3393) --- .../src/client/renderer/ChartRendererProvider.tsx | 2 +- .../plugin-data-visualization/src/client/utils.ts | 2 +- .../src/server/actions/query.ts | 9 +++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/plugins/@nocobase/plugin-data-visualization/src/client/renderer/ChartRendererProvider.tsx b/packages/plugins/@nocobase/plugin-data-visualization/src/client/renderer/ChartRendererProvider.tsx index a61c8dcc66..4e522e2f0e 100644 --- a/packages/plugins/@nocobase/plugin-data-visualization/src/client/renderer/ChartRendererProvider.tsx +++ b/packages/plugins/@nocobase/plugin-data-visualization/src/client/renderer/ChartRendererProvider.tsx @@ -115,7 +115,7 @@ export const ChartRendererProvider: React.FC = (props) => { }), { defaultParams: [collection, query], - // Wait until CharrFilterProvider is rendered and check the status of the filter form + // Wait until ChartFilterProvider is rendered and check the status of the filter form // since the filter parameters should be applied if the filter block is enabled ready: ready && (!enabled || !!form), }, diff --git a/packages/plugins/@nocobase/plugin-data-visualization/src/client/utils.ts b/packages/plugins/@nocobase/plugin-data-visualization/src/client/utils.ts index 3e5abb5b62..2e8e842d03 100644 --- a/packages/plugins/@nocobase/plugin-data-visualization/src/client/utils.ts +++ b/packages/plugins/@nocobase/plugin-data-visualization/src/client/utils.ts @@ -111,7 +111,7 @@ export const removeUnparsableFilter = (filter: any) => { const newLogic = {}; for (const key in filter) { const value = removeUnparsableFilter(filter[key]); - if (value && !(typeof value === 'object' && Object.keys(value).length === 0)) { + if (value !== null && value !== undefined && !(typeof value === 'object' && Object.keys(value).length === 0)) { newLogic[key] = value; } } diff --git a/packages/plugins/@nocobase/plugin-data-visualization/src/server/actions/query.ts b/packages/plugins/@nocobase/plugin-data-visualization/src/server/actions/query.ts index fe6e591c6e..42f229128f 100644 --- a/packages/plugins/@nocobase/plugin-data-visualization/src/server/actions/query.ts +++ b/packages/plugins/@nocobase/plugin-data-visualization/src/server/actions/query.ts @@ -51,20 +51,21 @@ export const postProcess = async (ctx: Context, next: Next) => { fieldMap: { [source: string]: { type?: string } }; }; ctx.body = data.map((record) => { - const result = {}; Object.entries(record).forEach(([key, value]) => { + if (!value) { + return; + } const { type } = fieldMap[key] || {}; switch (type) { case 'bigInt': case 'integer': case 'float': case 'double': - value = Number(value); + record[key] = Number(value); break; } - result[key] = value; }); - return result; + return record; }); await next(); };