@nocobase/flow-engine 2.0.0-alpha.49 → 2.0.0-alpha.50

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.
Files changed (60) hide show
  1. package/lib/acl/Acl.d.ts +2 -1
  2. package/lib/acl/Acl.js +19 -23
  3. package/lib/flowEngine.js +20 -8
  4. package/lib/locale/de-DE.json +63 -0
  5. package/lib/locale/en-US.json +48 -48
  6. package/lib/locale/es-ES.json +63 -0
  7. package/lib/locale/fr-FR.json +63 -0
  8. package/lib/locale/hu-HU.json +63 -0
  9. package/lib/locale/id-ID.json +63 -0
  10. package/lib/locale/index.d.ts +94 -94
  11. package/lib/locale/it-IT.json +63 -0
  12. package/lib/locale/ja-JP.json +63 -0
  13. package/lib/locale/ko-KR.json +63 -0
  14. package/lib/locale/nl-NL.json +63 -0
  15. package/lib/locale/pt-BR.json +63 -0
  16. package/lib/locale/ru-RU.json +63 -0
  17. package/lib/locale/tr-TR.json +63 -0
  18. package/lib/locale/uk-UA.json +63 -0
  19. package/lib/locale/vi-VN.json +63 -0
  20. package/lib/locale/zh-CN.json +48 -48
  21. package/lib/locale/zh-TW.json +63 -0
  22. package/lib/models/flowModel.d.ts +2 -2
  23. package/lib/resources/multiRecordResource.js +1 -17
  24. package/lib/resources/singleRecordResource.js +1 -17
  25. package/lib/types.d.ts +8 -0
  26. package/lib/utils/serverContextParams.d.ts +3 -0
  27. package/lib/utils/serverContextParams.js +2 -0
  28. package/lib/utils/variablesParams.js +2 -1
  29. package/lib/views/createViewMeta.d.ts +1 -0
  30. package/lib/views/createViewMeta.js +39 -18
  31. package/package.json +4 -4
  32. package/src/__tests__/createViewMeta.popup.test.ts +8 -1
  33. package/src/acl/Acl.tsx +19 -24
  34. package/src/flowEngine.ts +24 -7
  35. package/src/locale/de-DE.json +63 -0
  36. package/src/locale/en-US.json +48 -48
  37. package/src/locale/es-ES.json +63 -0
  38. package/src/locale/fr-FR.json +63 -0
  39. package/src/locale/hu-HU.json +63 -0
  40. package/src/locale/id-ID.json +63 -0
  41. package/src/locale/it-IT.json +63 -0
  42. package/src/locale/ja-JP.json +63 -0
  43. package/src/locale/ko-KR.json +63 -0
  44. package/src/locale/nl-NL.json +63 -0
  45. package/src/locale/pt-BR.json +63 -0
  46. package/src/locale/ru-RU.json +63 -0
  47. package/src/locale/tr-TR.json +63 -0
  48. package/src/locale/uk-UA.json +63 -0
  49. package/src/locale/vi-VN.json +63 -0
  50. package/src/locale/zh-CN.json +48 -48
  51. package/src/locale/zh-TW.json +63 -0
  52. package/src/models/__tests__/flowEngine.resolveUse.test.ts +58 -0
  53. package/src/models/flowModel.tsx +2 -4
  54. package/src/resources/multiRecordResource.ts +1 -20
  55. package/src/resources/singleRecordResource.ts +1 -17
  56. package/src/types.ts +12 -0
  57. package/src/utils/__tests__/variablesParams.test.ts +33 -0
  58. package/src/utils/serverContextParams.ts +5 -0
  59. package/src/utils/variablesParams.ts +2 -1
  60. package/src/views/createViewMeta.ts +27 -5
@@ -150,6 +150,8 @@ export function createPopupMeta(ctx: FlowContext, anchorView?: FlowView): Proper
150
150
  collection: res.collectionName,
151
151
  dataSourceKey: res.dataSourceKey || 'main',
152
152
  filterByTk: res.filterByTk,
153
+ associationName: res.associationName,
154
+ sourceId: res.sourceId,
153
155
  };
154
156
  }
155
157
  }
@@ -175,7 +177,7 @@ export function createPopupMeta(ctx: FlowContext, anchorView?: FlowView): Proper
175
177
  const parent = stack[idx];
176
178
  if (!parent?.viewUid) return undefined;
177
179
 
178
- let model = useCtx.engine?.getModel?.(parent.viewUid) as PopupModelLike;
180
+ let model = useCtx.engine?.getModel(parent.viewUid, true) as PopupModelLike;
179
181
  if (!model) {
180
182
  try {
181
183
  model = (await useCtx.engine.loadModel({ uid: parent.viewUid })) as PopupModelLike;
@@ -188,7 +190,14 @@ export function createPopupMeta(ctx: FlowContext, anchorView?: FlowView): Proper
188
190
  const dataSourceKey = params?.dataSourceKey || 'main';
189
191
  const filterByTk = parent?.filterByTk ?? parent?.sourceId;
190
192
  if (!collection || typeof filterByTk === 'undefined' || filterByTk === null) return undefined;
191
- return { collection, dataSourceKey, filterByTk };
193
+ const ref: RecordRef = {
194
+ collection,
195
+ dataSourceKey,
196
+ filterByTk,
197
+ sourceId: parent?.sourceId,
198
+ associationName: params?.associationName,
199
+ };
200
+ return ref;
192
201
  } catch (e) {
193
202
  (flowCtx?.logger || ctx.logger)?.warn?.({ err: e }, '[FlowEngine] popup.getParentRecordRef failed');
194
203
  return undefined;
@@ -245,6 +254,7 @@ export function createPopupMeta(ctx: FlowContext, anchorView?: FlowView): Proper
245
254
  properties: async () => ({
246
255
  dataSourceKey: { type: 'string', title: t('Data source key') },
247
256
  collectionName: { type: 'string', title: t('Collection name') },
257
+ associationName: { type: 'string', title: t('Association name') },
248
258
  filterByTk: { type: 'string', title: t('filterByTk') },
249
259
  sourceId: { type: 'string', title: t('sourceId') },
250
260
  }),
@@ -276,7 +286,16 @@ export function createPopupMeta(ctx: FlowContext, anchorView?: FlowView): Proper
276
286
  parent?: PopupVariableParams;
277
287
  };
278
288
  const params: PopupVariableParams = {};
279
- if (ref) params.record = ref;
289
+ if (ref) {
290
+ const merged: RecordRef = { ...ref };
291
+ if (!merged.associationName && inputArgs?.associationName) {
292
+ merged.associationName = inputArgs.associationName;
293
+ }
294
+ if (typeof merged.sourceId === 'undefined' && typeof inputArgs?.sourceId !== 'undefined') {
295
+ merged.sourceId = inputArgs?.sourceId;
296
+ }
297
+ params.record = merged;
298
+ }
280
299
 
281
300
  // 构建 parent 链(用于服务端解析 ctx.popup.parent[.parent...].record.*)
282
301
  try {
@@ -348,7 +367,7 @@ export function createPopupMeta(ctx: FlowContext, anchorView?: FlowView): Proper
348
367
  const stack = Array.isArray(nav?.viewStack) ? nav.viewStack : [];
349
368
  const last = stack?.[stack.length - 1];
350
369
  if (last?.viewUid) {
351
- let model = ctx?.engine?.getModel?.(last.viewUid) as PopupModelLike;
370
+ let model = ctx?.engine?.getModel(last.viewUid, true) as PopupModelLike;
352
371
  if (!model) {
353
372
  model = (await ctx.engine.loadModel({ uid: last.viewUid })) as PopupModelLike;
354
373
  }
@@ -388,6 +407,7 @@ export function createPopupMeta(ctx: FlowContext, anchorView?: FlowView): Proper
388
407
  properties: async () => ({
389
408
  dataSourceKey: { type: 'string', title: t('Data source key') },
390
409
  collectionName: { type: 'string', title: t('Collection name') },
410
+ associationName: { type: 'string', title: t('Association name') },
391
411
  filterByTk: { type: 'string', title: t('filterByTk') },
392
412
  sourceId: { type: 'string', title: t('sourceId') },
393
413
  }),
@@ -415,6 +435,7 @@ export function createPopupMeta(ctx: FlowContext, anchorView?: FlowView): Proper
415
435
  interface PopupNodeResource {
416
436
  dataSourceKey: string;
417
437
  collectionName?: string;
438
+ associationName?: string;
418
439
  filterByTk?: any;
419
440
  sourceId?: any;
420
441
  }
@@ -431,7 +452,7 @@ export async function buildPopupRuntime(ctx: FlowContext, view: FlowView): Promi
431
452
  const buildNode = async (idx: number): Promise<PopupNode | undefined> => {
432
453
  if (idx < 0 || !stack[idx]?.viewUid) return undefined;
433
454
  const viewUid = stack[idx].viewUid;
434
- let model = ctx.engine?.getModel?.(viewUid) as PopupModelLike;
455
+ let model = ctx.engine?.getModel(viewUid, true) as PopupModelLike;
435
456
  if (!model) {
436
457
  model = (await ctx.engine?.loadModel({ uid: viewUid })) as PopupModelLike;
437
458
  }
@@ -443,6 +464,7 @@ export async function buildPopupRuntime(ctx: FlowContext, view: FlowView): Promi
443
464
  resource: {
444
465
  dataSourceKey,
445
466
  collectionName,
467
+ associationName: p?.associationName,
446
468
  filterByTk: stack[idx]?.filterByTk,
447
469
  sourceId: stack[idx]?.sourceId,
448
470
  },