@nocobase/flow-engine 2.0.0-alpha.54 → 2.0.0-alpha.56
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/components/settings/wrappers/component/SelectWithTitle.d.ts +1 -0
- package/lib/components/settings/wrappers/component/SelectWithTitle.js +2 -1
- package/lib/flowContext.js +1 -0
- package/lib/flowEngine.js +4 -3
- package/package.json +4 -4
- package/src/__tests__/flowModel.openView.navigation.test.ts +1 -0
- package/src/__tests__/viewScopedFlowEngine.test.ts +12 -0
- package/src/components/settings/wrappers/component/SelectWithTitle.tsx +2 -0
- package/src/flowContext.ts +1 -0
- package/src/flowEngine.ts +5 -3
|
@@ -14,5 +14,6 @@ export interface SelectWithTitleProps {
|
|
|
14
14
|
fieldNames?: any;
|
|
15
15
|
itemKey?: string;
|
|
16
16
|
onChange?: (...args: any[]) => void;
|
|
17
|
+
dropdownRender?: any;
|
|
17
18
|
}
|
|
18
19
|
export declare function SelectWithTitle({ title, getDefaultValue, onChange, options, fieldNames, itemKey, ...others }: SelectWithTitleProps): React.JSX.Element;
|
|
@@ -123,7 +123,8 @@ function SelectWithTitle({
|
|
|
123
123
|
style: { textAlign: "right", minWidth: 100 },
|
|
124
124
|
onMouseEnter: () => {
|
|
125
125
|
clearTimeout(timerRef.current);
|
|
126
|
-
}
|
|
126
|
+
},
|
|
127
|
+
dropdownRender: (menu) => others.dropdownRender ? others.dropdownRender(menu, setOpen, handleChange) : menu
|
|
127
128
|
}
|
|
128
129
|
)
|
|
129
130
|
);
|
package/lib/flowContext.js
CHANGED
|
@@ -1091,6 +1091,7 @@ const _FlowModelContext = class _FlowModelContext extends BaseFlowModelContext {
|
|
|
1091
1091
|
await model2.save();
|
|
1092
1092
|
}
|
|
1093
1093
|
}
|
|
1094
|
+
model2.setParent(this.model);
|
|
1094
1095
|
const viewUid = (opts == null ? void 0 : opts.routeViewUid) ?? (opts == null ? void 0 : opts.viewUid) ?? (((_d = (_c = model2.stepParams) == null ? void 0 : _c.popupSettings) == null ? void 0 : _d.openView) ? model2.uid : this.model.uid);
|
|
1095
1096
|
const parentView = this.view;
|
|
1096
1097
|
const pendingType = (opts == null ? void 0 : opts.isMobileLayout) ? "embed" : (opts == null ? void 0 : opts.mode) || "drawer";
|
package/lib/flowEngine.js
CHANGED
|
@@ -391,8 +391,9 @@ const _FlowEngine = class _FlowEngine {
|
|
|
391
391
|
* @returns {T} Created model instance
|
|
392
392
|
*/
|
|
393
393
|
createModel(options, extra) {
|
|
394
|
+
var _a;
|
|
394
395
|
const { parentId, uid, use: modelClassName, subModels } = options;
|
|
395
|
-
const parentModel = parentId ? this.
|
|
396
|
+
const parentModel = parentId ? this.getModel(parentId) || ((_a = this.previousEngine) == null ? void 0 : _a.getModel(parentId)) : void 0;
|
|
396
397
|
const ModelClass = this._resolveModelClass(
|
|
397
398
|
typeof modelClassName === "string" ? this.getModelClass(modelClassName) : modelClassName,
|
|
398
399
|
options,
|
|
@@ -411,8 +412,8 @@ const _FlowEngine = class _FlowEngine {
|
|
|
411
412
|
if (extra == null ? void 0 : extra.delegate) {
|
|
412
413
|
modelInstance.context.addDelegate(extra.delegate);
|
|
413
414
|
}
|
|
414
|
-
if (
|
|
415
|
-
modelInstance.setParent(
|
|
415
|
+
if (parentModel) {
|
|
416
|
+
modelInstance.setParent(parentModel);
|
|
416
417
|
if ((extra == null ? void 0 : extra.delegateToParent) === false) {
|
|
417
418
|
modelInstance.removeParentDelegate();
|
|
418
419
|
}
|
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.56",
|
|
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.0.0-alpha.
|
|
12
|
-
"@nocobase/shared": "2.0.0-alpha.
|
|
11
|
+
"@nocobase/sdk": "2.0.0-alpha.56",
|
|
12
|
+
"@nocobase/shared": "2.0.0-alpha.56",
|
|
13
13
|
"ahooks": "^3.7.2",
|
|
14
14
|
"dayjs": "^1.11.9",
|
|
15
15
|
"dompurify": "^3.0.2",
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
],
|
|
37
37
|
"author": "NocoBase Team",
|
|
38
38
|
"license": "AGPL-3.0",
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "a26a7c3422ea8089e0f04c89c9d32ff25bc09a0c"
|
|
40
40
|
}
|
|
@@ -25,6 +25,7 @@ describe('FlowModelContext.openView - navigation enforcement', () => {
|
|
|
25
25
|
},
|
|
26
26
|
getStepParams: vi.fn(() => undefined),
|
|
27
27
|
setStepParams: vi.fn(),
|
|
28
|
+
setParent: vi.fn(),
|
|
28
29
|
save: vi.fn(async () => undefined),
|
|
29
30
|
dispatchEvent: vi.fn(async (_event: string, _params?: any) => undefined),
|
|
30
31
|
};
|
|
@@ -59,6 +59,18 @@ describe('ViewScopedFlowEngine', () => {
|
|
|
59
59
|
expect(child.getModel(uid)).toBe(cm);
|
|
60
60
|
});
|
|
61
61
|
|
|
62
|
+
it('mounts parent model from previous engine when creating models in scoped engine', () => {
|
|
63
|
+
const parent = new FlowEngine();
|
|
64
|
+
const scoped = createViewScopedEngine(parent);
|
|
65
|
+
|
|
66
|
+
const parentModel = parent.createModel({ use: 'FlowModel', uid: 'parent-uid' });
|
|
67
|
+
|
|
68
|
+
const childModel = scoped.createModel({ use: 'FlowModel', uid: 'child-uid', parentId: parentModel.uid });
|
|
69
|
+
|
|
70
|
+
expect(childModel.parent).toBe(parentModel);
|
|
71
|
+
expect(childModel.parent?.uid).toBe('parent-uid');
|
|
72
|
+
});
|
|
73
|
+
|
|
62
74
|
it('isolates beforeRender event cache across engines with identical model uid', async () => {
|
|
63
75
|
const parent = new FlowEngine();
|
|
64
76
|
const child = createViewScopedEngine(parent);
|
|
@@ -18,6 +18,7 @@ export interface SelectWithTitleProps {
|
|
|
18
18
|
fieldNames?: any;
|
|
19
19
|
itemKey?: string;
|
|
20
20
|
onChange?: (...args: any[]) => void;
|
|
21
|
+
dropdownRender?: any;
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
export function SelectWithTitle({
|
|
@@ -102,6 +103,7 @@ export function SelectWithTitle({
|
|
|
102
103
|
onMouseEnter={() => {
|
|
103
104
|
clearTimeout(timerRef.current);
|
|
104
105
|
}}
|
|
106
|
+
dropdownRender={(menu) => (others.dropdownRender ? others.dropdownRender(menu, setOpen, handleChange) : menu)}
|
|
105
107
|
/>
|
|
106
108
|
</div>
|
|
107
109
|
);
|
package/src/flowContext.ts
CHANGED
|
@@ -1445,6 +1445,7 @@ export class FlowModelContext extends BaseFlowModelContext {
|
|
|
1445
1445
|
}
|
|
1446
1446
|
}
|
|
1447
1447
|
|
|
1448
|
+
model.setParent(this.model);
|
|
1448
1449
|
// 路由层级的 viewUid:优先使用 routeViewUid(仅用于路由展示);
|
|
1449
1450
|
// 否则回退到 opts.viewUid;再否则沿用原有规则(若子模型具备弹窗配置则使用子模型 uid,否则使用发起者 uid)。
|
|
1450
1451
|
const viewUid =
|
package/src/flowEngine.ts
CHANGED
|
@@ -460,7 +460,9 @@ export class FlowEngine {
|
|
|
460
460
|
extra?: { delegateToParent?: boolean; delegate?: FlowContext },
|
|
461
461
|
): T {
|
|
462
462
|
const { parentId, uid, use: modelClassName, subModels } = options;
|
|
463
|
-
const parentModel = parentId
|
|
463
|
+
const parentModel = parentId
|
|
464
|
+
? ((this.getModel(parentId) || this.previousEngine?.getModel(parentId)) as FlowModel | undefined)
|
|
465
|
+
: undefined;
|
|
464
466
|
const ModelClass = this._resolveModelClass(
|
|
465
467
|
typeof modelClassName === 'string' ? this.getModelClass(modelClassName) : modelClassName,
|
|
466
468
|
options,
|
|
@@ -484,8 +486,8 @@ export class FlowEngine {
|
|
|
484
486
|
modelInstance.context.addDelegate(extra.delegate);
|
|
485
487
|
}
|
|
486
488
|
|
|
487
|
-
if (
|
|
488
|
-
modelInstance.setParent(
|
|
489
|
+
if (parentModel) {
|
|
490
|
+
modelInstance.setParent(parentModel);
|
|
489
491
|
if (extra?.delegateToParent === false) {
|
|
490
492
|
modelInstance.removeParentDelegate();
|
|
491
493
|
}
|