@nocobase/flow-engine 2.1.0-beta.45 → 2.1.0-beta.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/data-source/index.js
CHANGED
|
@@ -306,6 +306,14 @@ function getCollectionFieldInterface(interfaceName, ...dataSourceManagers) {
|
|
|
306
306
|
return void 0;
|
|
307
307
|
}
|
|
308
308
|
__name(getCollectionFieldInterface, "getCollectionFieldInterface");
|
|
309
|
+
function shouldTranslateOptionLabel(label) {
|
|
310
|
+
return typeof label === "string" && /\{\{\s*t\s*\(/.test(label);
|
|
311
|
+
}
|
|
312
|
+
__name(shouldTranslateOptionLabel, "shouldTranslateOptionLabel");
|
|
313
|
+
function translateOptionLabel(flowEngine, label, options) {
|
|
314
|
+
return shouldTranslateOptionLabel(label) ? flowEngine.translate(label, options) : label;
|
|
315
|
+
}
|
|
316
|
+
__name(translateOptionLabel, "translateOptionLabel");
|
|
309
317
|
const _DataSource = class _DataSource {
|
|
310
318
|
dataSourceManager;
|
|
311
319
|
collectionManager;
|
|
@@ -948,7 +956,7 @@ const _CollectionField = class _CollectionField {
|
|
|
948
956
|
}
|
|
949
957
|
return {
|
|
950
958
|
...v,
|
|
951
|
-
label:
|
|
959
|
+
label: translateOptionLabel(this.flowEngine, v.label, { ns: "lm-collections" }),
|
|
952
960
|
value: Number(v.value)
|
|
953
961
|
};
|
|
954
962
|
});
|
|
@@ -956,7 +964,7 @@ const _CollectionField = class _CollectionField {
|
|
|
956
964
|
return options.map((v) => {
|
|
957
965
|
return {
|
|
958
966
|
...v,
|
|
959
|
-
label: this.flowEngine
|
|
967
|
+
label: translateOptionLabel(this.flowEngine, v.label, { ns: "lm-collections" })
|
|
960
968
|
};
|
|
961
969
|
});
|
|
962
970
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/flow-engine",
|
|
3
|
-
"version": "2.1.0-beta.
|
|
3
|
+
"version": "2.1.0-beta.47",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A standalone flow engine for NocoBase, managing workflows, models, and actions.",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@formily/antd-v5": "1.x",
|
|
10
10
|
"@formily/reactive": "2.x",
|
|
11
|
-
"@nocobase/sdk": "2.1.0-beta.
|
|
12
|
-
"@nocobase/shared": "2.1.0-beta.
|
|
11
|
+
"@nocobase/sdk": "2.1.0-beta.47",
|
|
12
|
+
"@nocobase/shared": "2.1.0-beta.47",
|
|
13
13
|
"ahooks": "^3.7.2",
|
|
14
14
|
"axios": "^1.7.0",
|
|
15
15
|
"dayjs": "^1.11.9",
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
],
|
|
38
38
|
"author": "NocoBase Team",
|
|
39
39
|
"license": "Apache-2.0",
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "bf8fc3790e3494c901b4d22861c5471a0d27c464"
|
|
41
41
|
}
|
|
@@ -50,7 +50,7 @@ describe('DataSource & Collection APIs', () => {
|
|
|
50
50
|
{ name: 'body', type: 'string', interface: 'text' },
|
|
51
51
|
],
|
|
52
52
|
});
|
|
53
|
-
const bodyField = ds.getCollection('posts')
|
|
53
|
+
const bodyField = ds.getCollection('posts')?.getField('body');
|
|
54
54
|
expect(bodyField?.name).toBe('body');
|
|
55
55
|
|
|
56
56
|
// remove collection
|
|
@@ -109,7 +109,7 @@ describe('DataSource & Collection APIs', () => {
|
|
|
109
109
|
],
|
|
110
110
|
});
|
|
111
111
|
|
|
112
|
-
const rules = ds.getCollection('posts')
|
|
112
|
+
const rules = ds.getCollection('posts')?.getField('title')?.getComponentProps().rules || [];
|
|
113
113
|
|
|
114
114
|
await expect(rules[0].validator({}, '123')).rejects.toBe('单行文本 长度必须为 18 个字符');
|
|
115
115
|
});
|
package/src/data-source/index.ts
CHANGED
|
@@ -336,6 +336,14 @@ export function getCollectionFieldInterface(
|
|
|
336
336
|
return undefined;
|
|
337
337
|
}
|
|
338
338
|
|
|
339
|
+
function shouldTranslateOptionLabel(label: unknown): label is string {
|
|
340
|
+
return typeof label === 'string' && /\{\{\s*t\s*\(/.test(label);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
function translateOptionLabel(flowEngine: FlowEngine, label: unknown, options?: Record<string, any>) {
|
|
344
|
+
return shouldTranslateOptionLabel(label) ? flowEngine.translate(label, options) : label;
|
|
345
|
+
}
|
|
346
|
+
|
|
339
347
|
export class DataSource {
|
|
340
348
|
dataSourceManager: DataSourceManager;
|
|
341
349
|
collectionManager: CollectionManager;
|
|
@@ -1086,7 +1094,7 @@ export class CollectionField {
|
|
|
1086
1094
|
}
|
|
1087
1095
|
return {
|
|
1088
1096
|
...v,
|
|
1089
|
-
label:
|
|
1097
|
+
label: translateOptionLabel(this.flowEngine, v.label, { ns: 'lm-collections' }),
|
|
1090
1098
|
value: Number(v.value),
|
|
1091
1099
|
};
|
|
1092
1100
|
});
|
|
@@ -1094,7 +1102,7 @@ export class CollectionField {
|
|
|
1094
1102
|
return options.map((v) => {
|
|
1095
1103
|
return {
|
|
1096
1104
|
...v,
|
|
1097
|
-
label: this.flowEngine
|
|
1105
|
+
label: translateOptionLabel(this.flowEngine, v.label, { ns: 'lm-collections' }),
|
|
1098
1106
|
};
|
|
1099
1107
|
});
|
|
1100
1108
|
}
|