@nocobase/flow-engine 2.0.0-alpha.5 → 2.0.0-alpha.6
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
|
@@ -446,6 +446,7 @@ const _Collection = class _Collection {
|
|
|
446
446
|
return field.targetCollection.getFieldByPath(otherKeys.join("."));
|
|
447
447
|
}
|
|
448
448
|
getField(fieldName) {
|
|
449
|
+
this.setFields(this.options.fields);
|
|
449
450
|
return this.fields.get(fieldName);
|
|
450
451
|
}
|
|
451
452
|
getFullFieldPath(name) {
|
|
@@ -12,6 +12,7 @@ import { FlowEngineContext } from '../flowContext';
|
|
|
12
12
|
import { DefaultStructure } from '../types';
|
|
13
13
|
import { FlowModel } from './flowModel';
|
|
14
14
|
export declare function FieldPlaceholder(): React.JSX.Element;
|
|
15
|
+
export declare function FieldDeletePlaceholder(): React.JSX.Element;
|
|
15
16
|
export interface FieldSettingsInitParams {
|
|
16
17
|
dataSourceKey: string;
|
|
17
18
|
collectionName: string;
|
|
@@ -26,6 +27,7 @@ export interface BindingOptions {
|
|
|
26
27
|
}
|
|
27
28
|
export declare class CollectionFieldModel<T extends DefaultStructure = DefaultStructure> extends FlowModel<T> {
|
|
28
29
|
private static _bindings;
|
|
30
|
+
fieldDeleted: boolean;
|
|
29
31
|
renderHiddenInConfig(): React.ReactNode | undefined;
|
|
30
32
|
get title(): any;
|
|
31
33
|
onInit(options: any): void;
|
|
@@ -40,11 +40,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
40
40
|
var CollectionFieldModel_exports = {};
|
|
41
41
|
__export(CollectionFieldModel_exports, {
|
|
42
42
|
CollectionFieldModel: () => CollectionFieldModel,
|
|
43
|
+
FieldDeletePlaceholder: () => FieldDeletePlaceholder,
|
|
43
44
|
FieldPlaceholder: () => FieldPlaceholder
|
|
44
45
|
});
|
|
45
46
|
module.exports = __toCommonJS(CollectionFieldModel_exports);
|
|
46
47
|
var import_antd = require("antd");
|
|
47
48
|
var import_react = __toESM(require("react"));
|
|
49
|
+
var import_react_i18next = require("react-i18next");
|
|
50
|
+
var import_hooks = require("../hooks");
|
|
48
51
|
var import_utils = require("../utils");
|
|
49
52
|
var import_flowModel = require("./flowModel");
|
|
50
53
|
function FieldPlaceholder() {
|
|
@@ -62,9 +65,40 @@ function FieldPlaceholder() {
|
|
|
62
65
|
));
|
|
63
66
|
}
|
|
64
67
|
__name(FieldPlaceholder, "FieldPlaceholder");
|
|
68
|
+
function FieldDeletePlaceholder() {
|
|
69
|
+
const { t } = (0, import_react_i18next.useTranslation)();
|
|
70
|
+
const model = (0, import_hooks.useFlowModel)();
|
|
71
|
+
const blockModel = model.context.blockModel;
|
|
72
|
+
const dataSource = blockModel.collection.dataSource;
|
|
73
|
+
const collection = blockModel.collection;
|
|
74
|
+
const name = model.fieldPath;
|
|
75
|
+
const nameValue = (0, import_react.useMemo)(() => {
|
|
76
|
+
const dataSourcePrefix = `${t(dataSource.displayName || dataSource.key)} > `;
|
|
77
|
+
const collectionPrefix = collection ? `${t(collection.title) || collection.name || collection.tableName} > ` : "";
|
|
78
|
+
return `${dataSourcePrefix}${collectionPrefix}${name}`;
|
|
79
|
+
}, []);
|
|
80
|
+
return /* @__PURE__ */ import_react.default.createElement(import_antd.Form.Item, null, /* @__PURE__ */ import_react.default.createElement(
|
|
81
|
+
"div",
|
|
82
|
+
{
|
|
83
|
+
style: {
|
|
84
|
+
color: "rgba(0,0,0,0.45)"
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
t(`The {{type}} "{{name}}" may have been deleted. Please remove this {{blockType}}.`, {
|
|
88
|
+
type: t("Field"),
|
|
89
|
+
name: nameValue,
|
|
90
|
+
blockType: t("Field")
|
|
91
|
+
}).replaceAll(">", ">")
|
|
92
|
+
));
|
|
93
|
+
}
|
|
94
|
+
__name(FieldDeletePlaceholder, "FieldDeletePlaceholder");
|
|
65
95
|
const defaultWhen = /* @__PURE__ */ __name(() => true, "defaultWhen");
|
|
66
96
|
const _CollectionFieldModel = class _CollectionFieldModel extends import_flowModel.FlowModel {
|
|
97
|
+
fieldDeleted = false;
|
|
67
98
|
renderHiddenInConfig() {
|
|
99
|
+
if (this.fieldDeleted) {
|
|
100
|
+
return /* @__PURE__ */ import_react.default.createElement(FieldDeletePlaceholder, null);
|
|
101
|
+
}
|
|
68
102
|
return /* @__PURE__ */ import_react.default.createElement(FieldPlaceholder, null);
|
|
69
103
|
}
|
|
70
104
|
get title() {
|
|
@@ -107,6 +141,9 @@ const _CollectionFieldModel = class _CollectionFieldModel extends import_flowMod
|
|
|
107
141
|
}
|
|
108
142
|
}
|
|
109
143
|
static getBindingsByField(ctx, collectionField) {
|
|
144
|
+
if (!collectionField) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
110
147
|
const interfaceName = collectionField.interface;
|
|
111
148
|
if (!this.bindings.has(interfaceName)) {
|
|
112
149
|
return [];
|
|
@@ -238,5 +275,6 @@ CollectionFieldModel.registerFlow({
|
|
|
238
275
|
// Annotate the CommonJS export names for ESM import in node:
|
|
239
276
|
0 && (module.exports = {
|
|
240
277
|
CollectionFieldModel,
|
|
278
|
+
FieldDeletePlaceholder,
|
|
241
279
|
FieldPlaceholder
|
|
242
280
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/flow-engine",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.6",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A standalone flow engine for NocoBase, managing workflows, models, and actions.",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
],
|
|
34
34
|
"author": "NocoBase Team",
|
|
35
35
|
"license": "AGPL-3.0",
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "276a65c0656bbace2df7593be0f53c96b7b0725b"
|
|
37
37
|
}
|
package/src/data-source/index.ts
CHANGED
|
@@ -9,9 +9,11 @@
|
|
|
9
9
|
|
|
10
10
|
import { Card, Form } from 'antd';
|
|
11
11
|
import _ from 'lodash';
|
|
12
|
-
import React from 'react';
|
|
12
|
+
import React, { useMemo } from 'react';
|
|
13
|
+
import { useTranslation } from 'react-i18next';
|
|
13
14
|
import { CollectionField } from '../data-source';
|
|
14
15
|
import { FlowEngineContext } from '../flowContext';
|
|
16
|
+
import { useFlowModel } from '../hooks';
|
|
15
17
|
import { DefaultStructure } from '../types';
|
|
16
18
|
import { escapeT } from '../utils';
|
|
17
19
|
import { FlowModel } from './flowModel';
|
|
@@ -33,6 +35,34 @@ export function FieldPlaceholder() {
|
|
|
33
35
|
);
|
|
34
36
|
}
|
|
35
37
|
|
|
38
|
+
export function FieldDeletePlaceholder() {
|
|
39
|
+
const { t } = useTranslation();
|
|
40
|
+
const model: any = useFlowModel();
|
|
41
|
+
const blockModel = model.context.blockModel;
|
|
42
|
+
const dataSource = blockModel.collection.dataSource;
|
|
43
|
+
const collection = blockModel.collection;
|
|
44
|
+
const name = model.fieldPath;
|
|
45
|
+
const nameValue = useMemo(() => {
|
|
46
|
+
const dataSourcePrefix = `${t(dataSource.displayName || dataSource.key)} > `;
|
|
47
|
+
const collectionPrefix = collection ? `${t(collection.title) || collection.name || collection.tableName} > ` : '';
|
|
48
|
+
return `${dataSourcePrefix}${collectionPrefix}${name}`;
|
|
49
|
+
}, []);
|
|
50
|
+
return (
|
|
51
|
+
<Form.Item>
|
|
52
|
+
<div
|
|
53
|
+
style={{
|
|
54
|
+
color: 'rgba(0,0,0,0.45)',
|
|
55
|
+
}}
|
|
56
|
+
>
|
|
57
|
+
{t(`The {{type}} "{{name}}" may have been deleted. Please remove this {{blockType}}.`, {
|
|
58
|
+
type: t('Field'),
|
|
59
|
+
name: nameValue,
|
|
60
|
+
blockType: t('Field'),
|
|
61
|
+
}).replaceAll('>', '>')}
|
|
62
|
+
</div>
|
|
63
|
+
</Form.Item>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
36
66
|
export interface FieldSettingsInitParams {
|
|
37
67
|
dataSourceKey: string;
|
|
38
68
|
collectionName: string;
|
|
@@ -51,8 +81,12 @@ const defaultWhen = () => true;
|
|
|
51
81
|
|
|
52
82
|
export class CollectionFieldModel<T extends DefaultStructure = DefaultStructure> extends FlowModel<T> {
|
|
53
83
|
private static _bindings = new Map();
|
|
84
|
+
fieldDeleted = false;
|
|
54
85
|
|
|
55
86
|
renderHiddenInConfig(): React.ReactNode | undefined {
|
|
87
|
+
if (this.fieldDeleted) {
|
|
88
|
+
return <FieldDeletePlaceholder />;
|
|
89
|
+
}
|
|
56
90
|
return <FieldPlaceholder />;
|
|
57
91
|
}
|
|
58
92
|
|
|
@@ -103,6 +137,9 @@ export class CollectionFieldModel<T extends DefaultStructure = DefaultStructure>
|
|
|
103
137
|
}
|
|
104
138
|
|
|
105
139
|
static getBindingsByField(ctx: FlowEngineContext, collectionField: CollectionField): BindingOptions[] {
|
|
140
|
+
if (!collectionField) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
106
143
|
const interfaceName = collectionField.interface;
|
|
107
144
|
|
|
108
145
|
// Check if the interface exists in the map
|