{
- if (e.key === 'Enter') {
- e.preventDefault();
- }
- }}
- onBlur={onBlur}
- onInput={onInput}
- className={cx('ant-input', { 'ant-input-disabled': disabled }, css`
- overflow: auto;
- white-space: nowrap;
- .ant-tag{
- display: inline;
- line-height: 19px;
- margin: 0 .5em;
- padding: 2px 7px;
- border-radius: 10px;
- }
- `)}
- ref={inputRef as any}
- contentEditable={!disabled}
- dangerouslySetInnerHTML={{ __html: html }}
- />
-
-
-
-
-
-
+
);
};
diff --git a/packages/plugins/formula-field/src/client/index.tsx b/packages/plugins/formula-field/src/client/index.tsx
index 2164cc9be..71a8cda04 100644
--- a/packages/plugins/formula-field/src/client/index.tsx
+++ b/packages/plugins/formula-field/src/client/index.tsx
@@ -5,7 +5,7 @@ import { css } from '@emotion/css';
import { CollectionManagerContext, registerField, SchemaComponentOptions } from '@nocobase/client';
import evaluators, { Evaluator } from '@nocobase/evaluators/client';
-import Formula from './formula';
+import { Formula } from './formula';
import field from './field';
import { NAMESPACE } from './locale';
import { Registry } from '@nocobase/utils/client';
@@ -36,6 +36,8 @@ function renderExpressionDescription(key: string) {
: null
}
+export { Formula } from './formula';
+
export default React.memo((props) => {
const ctx = useContext(CollectionManagerContext);
return (
diff --git a/packages/plugins/formula-field/src/client/locale/zh-CN.ts b/packages/plugins/formula-field/src/client/locale/zh-CN.ts
index ac8fc1b31..25d9e60f9 100644
--- a/packages/plugins/formula-field/src/client/locale/zh-CN.ts
+++ b/packages/plugins/formula-field/src/client/locale/zh-CN.ts
@@ -3,5 +3,6 @@ export default {
'Formula engine': '公式引擎',
'Expression': '表达式',
'Expression syntax error': '表达式语法错误',
- 'Syntax references': '语法参考'
+ 'Syntax references': '语法参考',
+ 'Compute a value based on the other fields': '基于其他字段进行计算'
}
diff --git a/packages/plugins/formula-field/src/server/__tests__/formula-field.test.ts b/packages/plugins/formula-field/src/server/__tests__/formula-field.test.ts
index 6005713a0..f816494d5 100644
--- a/packages/plugins/formula-field/src/server/__tests__/formula-field.test.ts
+++ b/packages/plugins/formula-field/src/server/__tests__/formula-field.test.ts
@@ -89,6 +89,25 @@ describe('formula field', () => {
expect(test.get('sum')).toEqual(3.22);
});
+
+ it('scope with number key', async () => {
+ const expression = '{{a.1}}+1';
+ const Test = db.collection({
+ name: 'tests',
+ fields: [
+ { type: 'json', name: 'a' },
+ { name: 'sum', type: 'formula', expression, engine: 'math.js' },
+ ],
+ });
+
+ await db.sync();
+
+ const test = await Test.model.create
({
+ a: { '1': 1 },
+ });
+
+ expect(test.get('sum')).toEqual(2);
+ });
});
describe('formula.js', () => {
diff --git a/packages/plugins/workflow/package.json b/packages/plugins/workflow/package.json
index 858d7e4de..3b1542f9a 100644
--- a/packages/plugins/workflow/package.json
+++ b/packages/plugins/workflow/package.json
@@ -9,6 +9,7 @@
"@nocobase/actions": "0.9.0-alpha.2",
"@nocobase/client": "0.9.0-alpha.2",
"@nocobase/database": "0.9.0-alpha.2",
+ "@nocobase/evaluators": "0.9.0-alpha.2",
"@nocobase/resourcer": "0.9.0-alpha.2",
"@nocobase/server": "0.9.0-alpha.2",
"@nocobase/utils": "0.9.0-alpha.2",
@@ -16,9 +17,7 @@
"axios": "^0.27.2",
"classnames": "^2.3.1",
"cron-parser": "4.4.0",
- "@formulajs/formulajs": "4.2.0",
"json-templates": "^4.2.0",
- "mathjs": "^10.6.0",
"moment": "^2.29.2",
"react-js-cron": "^1.4.0"
},
diff --git a/packages/plugins/workflow/src/client/components/CollectionFieldset.tsx b/packages/plugins/workflow/src/client/components/CollectionFieldset.tsx
index 604677c58..5d4dc0436 100644
--- a/packages/plugins/workflow/src/client/components/CollectionFieldset.tsx
+++ b/packages/plugins/workflow/src/client/components/CollectionFieldset.tsx
@@ -5,8 +5,7 @@ import { PlusOutlined, CloseCircleOutlined } from '@ant-design/icons';
import { useTranslation } from "react-i18next";
import { css } from "@emotion/css";
-import { CollectionField, CollectionProvider, SchemaComponent, useCollectionManager, useCompile } from "@nocobase/client";
-import { VariableInput } from "./VariableInput";
+import { CollectionField, CollectionProvider, SchemaComponent, Variable, useCollectionManager, useCompile } from "@nocobase/client";
import { lang } from "../locale";
import { useWorkflowVariableOptions } from "../variable";
@@ -40,7 +39,8 @@ export default observer(({ value, disabled, onChange }: any) => {
.filter(field => (
!field.hidden
&& (field.uiSchema ? !field.uiSchema['x-read-pretty'] : false)
- // && (!['linkTo', 'hasMany', 'hasOne', 'belongsToMany'].includes(field.type))
+ // TODO: should use some field option but not type to control this
+ && (!['formula'].includes(field.type))
));
const unassignedFields = fields.filter(field => !(field.name in value));
@@ -77,7 +77,7 @@ export default observer(({ value, disabled, onChange }: any) => {
display: flex;
}
`}>
- {
@@ -94,7 +94,7 @@ export default observer(({ value, disabled, onChange }: any) => {
}
}}
/>
-
+
{!mergedDisabled
? (