From 1dc4142da2195fb6f09bd691b23948d9d5f9e01d Mon Sep 17 00:00:00 2001 From: chenos Date: Tue, 10 Jan 2023 10:48:50 +0800 Subject: [PATCH] fix: typeError: Cannot read properties of undefined (reading 'find') --- packages/core/client/src/acl/ACLProvider.tsx | 2 +- packages/core/client/src/locale/zh_CN.ts | 2 +- .../src/client/math-formula.tsx | 40 ++++++++++++++----- .../src/server/math-formula-field.ts | 3 +- 4 files changed, 35 insertions(+), 12 deletions(-) diff --git a/packages/core/client/src/acl/ACLProvider.tsx b/packages/core/client/src/acl/ACLProvider.tsx index 20c71c6ff..00e3b5b57 100644 --- a/packages/core/client/src/acl/ACLProvider.tsx +++ b/packages/core/client/src/acl/ACLProvider.tsx @@ -107,7 +107,7 @@ export const useACLRolesCheck = () => { }, getStrategyActionParams: (actionPath: string) => { const actionAlias = getActionAlias(actionPath); - const strategyAction = data?.strategy?.actions.find((action) => { + const strategyAction = data?.strategy?.actions?.find((action) => { const [value] = action.split(':'); return value === actionAlias; }); diff --git a/packages/core/client/src/locale/zh_CN.ts b/packages/core/client/src/locale/zh_CN.ts index 305eacf84..134be6d7d 100644 --- a/packages/core/client/src/locale/zh_CN.ts +++ b/packages/core/client/src/locale/zh_CN.ts @@ -497,7 +497,7 @@ export default { 'General permissions': '通用配置', 'Global action permissions': '全局操作权限', 'General action permissions': '通用操作权限', - "Plugin settings permissions":"插件权限", + "Plugin settings permissions":"插件配置权限", 'Allow to desgin pages':"允许界面配置", "Allow to manage plugins":"允许管理插件", "Allow to configure plugins":"允许管理配置中心", diff --git a/packages/plugins/math-formula-field/src/client/math-formula.tsx b/packages/plugins/math-formula-field/src/client/math-formula.tsx index 743686989..9089e5717 100644 --- a/packages/plugins/math-formula-field/src/client/math-formula.tsx +++ b/packages/plugins/math-formula-field/src/client/math-formula.tsx @@ -25,17 +25,27 @@ export const mathFormula: IField = { }, properties: { ...defaultProps, - expression: { + dataType: { type: 'string', - title: '{{t("Expression")}}', - required: true, - description: '{{mathExpressionDescription}}', - 'x-component': 'MathFormula.Expression', + title: '{{t("Data type")}}', + 'x-component': 'Select', 'x-decorator': 'FormItem', - 'x-component-props': { - supports: ['number', 'percent', 'integer'], - useCurrentFields: '{{ useCurrentFields }}', - }, + default: 'number', + 'x-disabled': '{{ !createOnly }}', + 'x-reactions': [ + { + target: 'uiSchema.x-component-props.step', + fulfill: { + state: { + display: '{{$self.value !== "string" ? "visible" : "none"}}', + }, + }, + }, + ], + enum: [ + { value: 'string', label: '{{t("String")}}' }, + { value: 'number', label: '{{t("Number")}}' }, + ], }, 'uiSchema.x-component-props.step': { type: 'string', @@ -53,6 +63,18 @@ export const mathFormula: IField = { { value: '0.00001', label: '1.00000' }, ], }, + expression: { + type: 'string', + title: '{{t("Expression")}}', + required: true, + description: '{{mathExpressionDescription}}', + 'x-component': 'MathFormula.Expression', + 'x-decorator': 'FormItem', + 'x-component-props': { + supports: ['number', 'percent', 'integer'], + useCurrentFields: '{{ useCurrentFields }}', + }, + }, }, filterable: { operators: operators.number, diff --git a/packages/plugins/math-formula-field/src/server/math-formula-field.ts b/packages/plugins/math-formula-field/src/server/math-formula-field.ts index 1f94936db..aad2a8477 100644 --- a/packages/plugins/math-formula-field/src/server/math-formula-field.ts +++ b/packages/plugins/math-formula-field/src/server/math-formula-field.ts @@ -5,7 +5,8 @@ import { evaluate } from '../utils/evaluate'; export class MathFormulaField extends Field { get dataType() { - return DataTypes.DOUBLE; + const { dataType } = this.options; + return dataType === 'string' ? DataTypes.STRING : DataTypes.DOUBLE; } calculate(expression, scope) {