@nocobase/plugin-flow-engine 2.1.0-beta.24 → 2.1.0-beta.26

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 (30) hide show
  1. package/dist/ai/ai-employees/nathan/index.js +1 -0
  2. package/dist/externalVersion.js +10 -10
  3. package/dist/node_modules/ses/package.json +1 -1
  4. package/dist/node_modules/zod/package.json +1 -1
  5. package/dist/server/flow-surfaces/blueprint/compile-blocks.d.ts +2 -1
  6. package/dist/server/flow-surfaces/blueprint/compile-blocks.js +134 -14
  7. package/dist/server/flow-surfaces/blueprint/compile-plan.d.ts +2 -1
  8. package/dist/server/flow-surfaces/blueprint/compile-plan.js +8 -8
  9. package/dist/server/flow-surfaces/blueprint/normalize-document.js +5 -14
  10. package/dist/server/flow-surfaces/blueprint/private-utils.d.ts +0 -1
  11. package/dist/server/flow-surfaces/blueprint/private-utils.js +0 -3
  12. package/dist/server/flow-surfaces/blueprint/public-types.d.ts +1 -0
  13. package/dist/server/flow-surfaces/builder.d.ts +1 -0
  14. package/dist/server/flow-surfaces/builder.js +167 -53
  15. package/dist/server/flow-surfaces/catalog.js +58 -3
  16. package/dist/server/flow-surfaces/configure-options.js +4 -0
  17. package/dist/server/flow-surfaces/default-block-actions.js +11 -10
  18. package/dist/server/flow-surfaces/hidden-popup-calendar.d.ts +86 -0
  19. package/dist/server/flow-surfaces/hidden-popup-calendar.js +554 -0
  20. package/dist/server/flow-surfaces/hidden-popup-contract.d.ts +116 -0
  21. package/dist/server/flow-surfaces/hidden-popup-contract.js +611 -0
  22. package/dist/server/flow-surfaces/hidden-popup-kanban.d.ts +62 -0
  23. package/dist/server/flow-surfaces/hidden-popup-kanban.js +651 -0
  24. package/dist/server/flow-surfaces/placement.js +1 -0
  25. package/dist/server/flow-surfaces/public-compatibility.d.ts +12 -0
  26. package/dist/server/flow-surfaces/public-compatibility.js +24 -2
  27. package/dist/server/flow-surfaces/service.d.ts +54 -10
  28. package/dist/server/flow-surfaces/service.js +1355 -765
  29. package/dist/swagger/flow-surfaces.js +6 -6
  30. package/package.json +2 -2
@@ -56,7 +56,6 @@ var import_reference_guards = require("./reference-guards");
56
56
  var import_key_registry = require("./planning/key-registry");
57
57
  var import_blueprint = require("./blueprint");
58
58
  var import_compile_blocks = require("./blueprint/compile-blocks");
59
- var import_private_utils = require("./blueprint/private-utils");
60
59
  var import_default_block_actions = require("./default-block-actions");
61
60
  var import_public_data_surface_default_filter = require("./public-data-surface-default-filter");
62
61
  var import_runtime = require("./planning/runtime");
@@ -94,6 +93,9 @@ var import_service_utils = require("./service-utils");
94
93
  var import_field_type_resolver = require("./field-type-resolver");
95
94
  var import_template_compatibility = require("./template-compatibility");
96
95
  var import_template_service_utils = require("./template-service-utils");
96
+ var import_hidden_popup_contract = require("./hidden-popup-contract");
97
+ var import_hidden_popup_calendar = require("./hidden-popup-calendar");
98
+ var import_hidden_popup_kanban = require("./hidden-popup-kanban");
97
99
  const FORM_BLOCK_USES = /* @__PURE__ */ new Set(["FormBlockModel", "CreateFormModel", "EditFormModel", ...import_approval.APPROVAL_FORM_BLOCK_USES]);
98
100
  const AUTO_SUBMIT_FORM_BLOCK_USES = /* @__PURE__ */ new Set(["CreateFormModel", "EditFormModel"]);
99
101
  const FLOW_SURFACE_DEFAULT_ACTION_SETTINGS_KEYS = /* @__PURE__ */ new Set(["filter"]);
@@ -122,12 +124,6 @@ const DEFAULT_CALENDAR_DATE_TIME_FIELD_TYPES = [
122
124
  ];
123
125
  const CALENDAR_DEFAULT_VIEWS = /* @__PURE__ */ new Set(["month", "week", "day"]);
124
126
  const CALENDAR_WEEK_STARTS = /* @__PURE__ */ new Set([0, 1]);
125
- const CALENDAR_POPUP_ACTION_KEYS = ["quickCreateAction", "eventViewAction"];
126
- const KANBAN_POPUP_ACTION_UID_SUFFIX_BY_KEY = {
127
- quickCreateAction: "-quick-create-action",
128
- cardViewAction: "-card-view-action"
129
- };
130
- const KANBAN_POPUP_ACTION_KEYS = Object.keys(KANBAN_POPUP_ACTION_UID_SUFFIX_BY_KEY);
131
127
  const CANONICAL_BLOCK_HEADER_USES = /* @__PURE__ */ new Set([
132
128
  "TableBlockModel",
133
129
  "CalendarBlockModel",
@@ -169,6 +165,7 @@ const FILTER_TARGET_BLOCK_USES = /* @__PURE__ */ new Set([
169
165
  ]);
170
166
  const TREE_CONNECT_TARGET_BLOCK_USES = new Set(FILTER_TARGET_BLOCK_USES);
171
167
  const EDITABLE_FIELD_WRAPPER_USES = /* @__PURE__ */ new Set(["FormItemModel", "FilterFormItemModel", "PatternFormItemModel"]);
168
+ const REQUIRED_COLLECTION_FIELD_FORM_WRAPPER_USES = /* @__PURE__ */ new Set(["FormItemModel", "PatternFormItemModel"]);
172
169
  const DISPLAY_FIELD_WRAPPER_USES = /* @__PURE__ */ new Set([
173
170
  "DetailsItemModel",
174
171
  "TableColumnModel",
@@ -392,6 +389,14 @@ const FILTER_FORM_BLOCK_LAYOUT_STEP_PARAM_MIRRORS = [
392
389
  { domain: "props", key: "labelWidth", stepParamsPath: ["formFilterBlockModelSettings", "layout", "labelWidth"] },
393
390
  { domain: "props", key: "labelWrap", stepParamsPath: ["formFilterBlockModelSettings", "layout", "labelWrap"] }
394
391
  ];
392
+ const UPDATE_SETTINGS_POPUP_STEP_PARAM_REPLACE_PATHS_BY_USE = {
393
+ CalendarBlockModel: [
394
+ ["calendarSettings", "quickCreatePopupSettings"],
395
+ ["calendarSettings", "eventPopupSettings"]
396
+ ],
397
+ KanbanBlockModel: [["kanbanSettings", "popup"]],
398
+ KanbanCardItemModel: [["cardSettings", "popup"]]
399
+ };
395
400
  const DIVIDER_ITEM_STEP_PARAM_MIRRORS = [
396
401
  { domain: "props", key: "label", stepParamsPath: ["markdownItemSetting", "title", "label"] },
397
402
  { domain: "props", key: "orientation", stepParamsPath: ["markdownItemSetting", "title", "orientation"] },
@@ -531,6 +536,17 @@ class FlowSurfacesService {
531
536
  syncApprovalRuntimeConfigForSurfaceRoot: (root, transaction) => this.approvalRuntimeConfigService.syncApprovalRuntimeConfigForSurfaceRoot(root, transaction)
532
537
  });
533
538
  }
539
+ get hiddenPopupRuntime() {
540
+ return {
541
+ repository: this.repository,
542
+ buildPopupOpenViewWithTemplate: (input) => this.buildPopupOpenViewWithTemplate(input),
543
+ clearFlowTemplateUsagesForNodeTree: (uid2, transaction) => this.clearFlowTemplateUsagesForNodeTree(uid2, transaction),
544
+ ensurePopupHostDefaultContent: (input) => this.ensurePopupHostDefaultContent(input),
545
+ reconcilePopupOpenViewTransition: (uid2, currentOpenView, nextOpenView, transaction) => this.reconcilePopupOpenViewTransition(uid2, currentOpenView, nextOpenView, transaction),
546
+ removeNodeTreeWithBindings: (uid2, transaction) => this.removeNodeTreeWithBindings(uid2, transaction),
547
+ syncFlowTemplateUsagesForNodeTree: (uid2, transaction) => this.syncFlowTemplateUsagesForNodeTree(uid2, transaction)
548
+ };
549
+ }
534
550
  async setFlowModelNodeAsyncFlag(uid2, asyncFlag, transaction) {
535
551
  var _a, _b;
536
552
  const sequelize = (_a = this.db) == null ? void 0 : _a.sequelize;
@@ -1403,11 +1419,24 @@ class FlowSurfacesService {
1403
1419
  filterByTk,
1404
1420
  associationName,
1405
1421
  sourceId,
1422
+ sourceIdInferred: !(0, import_service_helpers.hasConfiguredFlowContextValue)(openView == null ? void 0 : openView.sourceId) && (0, import_service_helpers.hasConfiguredFlowContextValue)(sourceId) && this.isSameConfiguredFlowContextValue(sourceId, "{{ctx.view.inputArgs.sourceId}}"),
1406
1423
  hasCurrentRecord,
1407
1424
  hasAssociationContext,
1408
1425
  scene
1409
1426
  };
1410
1427
  }
1428
+ resolvePopupCurrentRecordResourceFilterByTk(popupProfile, options = {}) {
1429
+ if (!(popupProfile == null ? void 0 : popupProfile.currentCollection)) {
1430
+ return popupProfile == null ? void 0 : popupProfile.filterByTk;
1431
+ }
1432
+ if (popupProfile.popupKind !== "associationPopup") {
1433
+ return popupProfile.filterByTk;
1434
+ }
1435
+ if (options.usePopupInputArgsWhenSourceIdInferred && popupProfile.sourceIdInferred && popupProfile.popupHostUse && POPUP_ACTION_USES.has(popupProfile.popupHostUse)) {
1436
+ return "{{ctx.view.inputArgs.filterByTk}}";
1437
+ }
1438
+ return `{{ctx.record.${this.getCollectionFilterTargetKey(popupProfile.currentCollection)}}}`;
1439
+ }
1411
1440
  resolvePopupAssociationFields(popupProfile, blockUse) {
1412
1441
  var _a;
1413
1442
  if (!popupProfile.currentCollection || !popupProfile.hasCurrentRecord) {
@@ -1647,7 +1676,9 @@ class FlowSurfacesService {
1647
1676
  return (0, import_service_utils.buildDefinedPayload)({
1648
1677
  dataSourceKey: input.popupProfile.dataSourceKey || "main",
1649
1678
  collectionName: input.popupProfile.collectionName,
1650
- filterByTk: input.popupProfile.filterByTk,
1679
+ filterByTk: this.resolvePopupCurrentRecordResourceFilterByTk(input.popupProfile, {
1680
+ usePopupInputArgsWhenSourceIdInferred: true
1681
+ }),
1651
1682
  ...preserveAssociationContext ? {
1652
1683
  associationName: input.popupProfile.associationName,
1653
1684
  sourceId: input.popupProfile.sourceId
@@ -2484,19 +2515,6 @@ class FlowSurfacesService {
2484
2515
  `flowSurfaces applyBlueprint navigation.group.title '${groupTitle}' matches ${matchedRoutes.length} existing menu groups; pass navigation.group.routeId explicitly`
2485
2516
  );
2486
2517
  }
2487
- const reusedMetadataFields = import_private_utils.APPLY_BLUEPRINT_CREATE_MENU_GROUP_METADATA_KEYS.filter(
2488
- (key) => {
2489
- var _a2, _b;
2490
- return !import_lodash.default.isUndefined((_b = (_a2 = document.navigation) == null ? void 0 : _a2.group) == null ? void 0 : _b[key]);
2491
- }
2492
- );
2493
- if (reusedMetadataFields.length) {
2494
- (0, import_errors.throwBadRequest)(
2495
- `flowSurfaces applyBlueprint navigation.group.title '${groupTitle}' matched an existing menu group; do not also pass ${reusedMetadataFields.map((key) => `navigation.group.${key}`).join(
2496
- ", "
2497
- )} when reusing by title. Same-title reuse is title-only. Keep only navigation.group.title or use navigation.group.routeId for exact targeting, and call flowSurfaces:updateMenu separately if existing group metadata must change`
2498
- );
2499
- }
2500
2518
  const routeId = this.readRouteField(matchedRoutes[0], "id");
2501
2519
  if (import_lodash.default.isNil(routeId) || routeId === "") {
2502
2520
  (0, import_errors.throwBadRequest)(
@@ -2524,7 +2542,8 @@ class FlowSurfacesService {
2524
2542
  );
2525
2543
  }
2526
2544
  return (0, import_blueprint.compileFlowSurfaceApplyBlueprintRequest)(document, {
2527
- replaceTarget
2545
+ replaceTarget,
2546
+ getCollection: (dataSourceKey, collectionName) => this.getCollection(dataSourceKey || "main", collectionName || "")
2528
2547
  });
2529
2548
  }
2530
2549
  async applyBlueprint(values, options = {}) {
@@ -2891,34 +2910,41 @@ class FlowSurfacesService {
2891
2910
  })
2892
2911
  );
2893
2912
  }
2894
- async assertPopupTemplateCompatibility(actionName, hostUid, template, transaction) {
2913
+ async assertPopupTemplateCompatibility(actionName, hostUid, template, options = {}) {
2895
2914
  const normalizedHostUid = String(hostUid || "").trim();
2896
2915
  if (!normalizedHostUid) {
2897
2916
  return;
2898
2917
  }
2899
2918
  const hostNode = await this.repository.findModelById(normalizedHostUid, {
2900
- transaction,
2919
+ transaction: options.transaction,
2901
2920
  includeAsyncNode: true
2902
2921
  });
2903
2922
  if (!(hostNode == null ? void 0 : hostNode.uid)) {
2904
2923
  return;
2905
2924
  }
2906
- const popupProfile = await this.resolvePopupBlockProfile(normalizedHostUid, null, hostNode, transaction).catch(
2907
- () => null
2908
- );
2925
+ const popupProfile = await this.resolvePopupBlockProfile(
2926
+ normalizedHostUid,
2927
+ null,
2928
+ hostNode,
2929
+ options.transaction
2930
+ ).catch(() => null);
2909
2931
  if (!(popupProfile == null ? void 0 : popupProfile.isPopupSurface)) {
2910
2932
  return;
2911
2933
  }
2912
- const disabledReason = await this.getPopupTemplateDisabledReason(template, {
2913
- target: { uid: normalizedHostUid },
2914
- resolved: {
2915
- uid: normalizedHostUid,
2934
+ const disabledReason = await this.getPopupTemplateDisabledReason(
2935
+ template,
2936
+ {
2916
2937
  target: { uid: normalizedHostUid },
2917
- kind: "node"
2938
+ resolved: {
2939
+ uid: normalizedHostUid,
2940
+ target: { uid: normalizedHostUid },
2941
+ kind: "node"
2942
+ },
2943
+ node: hostNode,
2944
+ popupProfile
2918
2945
  },
2919
- node: hostNode,
2920
- popupProfile
2921
- });
2946
+ options.popupActionContext
2947
+ );
2922
2948
  if (!disabledReason) {
2923
2949
  return;
2924
2950
  }
@@ -3045,7 +3071,7 @@ class FlowSurfacesService {
3045
3071
  "FLOW_SURFACE_TEMPLATE_POPUP_SOURCE_UNSUPPORTED"
3046
3072
  );
3047
3073
  }
3048
- if (popupTemplateUid && !this.isEditableDefaultActionPopupTemplateReference(node, openView)) {
3074
+ if (this.isPopupTemplateReferenceOpenViewState(openView) && !this.isEditableDefaultActionPopupTemplateReference(node, openView)) {
3049
3075
  (0, import_errors.throwBadRequest)(
3050
3076
  `flowSurfaces ${actionName} target '${node.uid}' already uses a popup template; convert it to copy first`,
3051
3077
  "FLOW_SURFACE_TEMPLATE_SOURCE_ALREADY_TEMPLATED"
@@ -3121,6 +3147,67 @@ class FlowSurfacesService {
3121
3147
  buildPopupTemplateReferenceOpenView(template, templateTargetUid) {
3122
3148
  return this.buildPopupTemplateOpenView(template, "reference", templateTargetUid);
3123
3149
  }
3150
+ shouldHydrateDetachedPopupTemplateBlockResourceContext(blockNode, context) {
3151
+ if (!this.isCollectionBlockUse(blockNode == null ? void 0 : blockNode.use) || !context.associationName || !context.sourceId) {
3152
+ return false;
3153
+ }
3154
+ const init = import_lodash.default.get(blockNode, ["stepParams", "resourceSettings", "init"]) || {};
3155
+ const popupDataSourceKey = context.dataSourceKey || "main";
3156
+ const blockDataSourceKey = init.dataSourceKey || "main";
3157
+ if (!context.collectionName || blockDataSourceKey !== popupDataSourceKey || init.collectionName !== context.collectionName) {
3158
+ return false;
3159
+ }
3160
+ const blockAssociationName = String(init.associationName || "").trim();
3161
+ if (blockAssociationName && blockAssociationName !== context.associationName) {
3162
+ return false;
3163
+ }
3164
+ if ((0, import_service_helpers.hasConfiguredFlowContextValue)(init.sourceId) && !this.isSameConfiguredFlowContextValue(init.sourceId, context.sourceId)) {
3165
+ return false;
3166
+ }
3167
+ return blockAssociationName !== context.associationName || !this.isSameConfiguredFlowContextValue(init.sourceId, context.sourceId);
3168
+ }
3169
+ collectDetachedPopupTemplateBlockResourceContextPatches(node, context, patches = []) {
3170
+ if (!node || typeof node !== "object") {
3171
+ return patches;
3172
+ }
3173
+ if (node.uid && this.shouldHydrateDetachedPopupTemplateBlockResourceContext(node, context)) {
3174
+ const nextStepParams = import_lodash.default.cloneDeep(node.stepParams || {});
3175
+ const currentInit = import_lodash.default.get(nextStepParams, ["resourceSettings", "init"]) || {};
3176
+ import_lodash.default.set(
3177
+ nextStepParams,
3178
+ ["resourceSettings", "init"],
3179
+ (0, import_service_utils.buildDefinedPayload)({
3180
+ ...currentInit,
3181
+ dataSourceKey: context.dataSourceKey || currentInit.dataSourceKey || "main",
3182
+ collectionName: context.collectionName || currentInit.collectionName,
3183
+ associationName: context.associationName,
3184
+ sourceId: context.sourceId
3185
+ })
3186
+ );
3187
+ patches.push({
3188
+ uid: node.uid,
3189
+ stepParams: nextStepParams
3190
+ });
3191
+ }
3192
+ for (const value of Object.values(node.subModels || {})) {
3193
+ for (const child of import_lodash.default.castArray(value)) {
3194
+ this.collectDetachedPopupTemplateBlockResourceContextPatches(child, context, patches);
3195
+ }
3196
+ }
3197
+ return patches;
3198
+ }
3199
+ async hydrateDetachedPopupTemplateBlockResourceContext(detachedTarget, context, transaction) {
3200
+ const patches = this.collectDetachedPopupTemplateBlockResourceContextPatches(detachedTarget, context);
3201
+ for (const patch of patches) {
3202
+ await this.repository.patch(
3203
+ {
3204
+ uid: patch.uid,
3205
+ stepParams: patch.stepParams
3206
+ },
3207
+ { transaction }
3208
+ );
3209
+ }
3210
+ }
3124
3211
  async hydrateDetachedPopupTemplateSourceContext(templateTargetUid, inferred, transaction) {
3125
3212
  if (inferred.templateType !== "popup") {
3126
3213
  return;
@@ -3137,32 +3224,32 @@ class FlowSurfacesService {
3137
3224
  return;
3138
3225
  }
3139
3226
  const resolvedOpenViewStep = (0, import_template_service_utils.findFlowTemplateOpenViewStep)(detachedTarget) || inferred.openViewStep;
3140
- if (!resolvedOpenViewStep) {
3141
- return;
3142
- }
3143
- const nextStepParams = import_lodash.default.cloneDeep(detachedTarget.stepParams || {});
3144
- const currentGroup = import_lodash.default.isPlainObject(nextStepParams[resolvedOpenViewStep.flowKey]) ? import_lodash.default.cloneDeep(nextStepParams[resolvedOpenViewStep.flowKey]) : {};
3145
- const currentOpenView = import_lodash.default.isPlainObject(currentGroup[resolvedOpenViewStep.stepKey]) ? import_lodash.default.omit((0, import_template_service_utils.stripTemplateInternalOpenViewFields)(currentGroup[resolvedOpenViewStep.stepKey]) || {}, ["uid"]) : {};
3146
- const nextOpenView = (0, import_service_utils.buildDefinedPayload)({
3147
- ...currentOpenView,
3148
- dataSourceKey: inferred.dataSourceKey || currentOpenView.dataSourceKey,
3149
- collectionName: inferred.collectionName || currentOpenView.collectionName,
3150
- associationName: inferred.associationName || currentOpenView.associationName,
3151
- filterByTk: inferred.filterByTk || currentOpenView.filterByTk,
3152
- sourceId: inferred.sourceId || currentOpenView.sourceId
3153
- });
3154
- if (import_lodash.default.isEqual(nextOpenView, currentOpenView)) {
3155
- return;
3227
+ if (resolvedOpenViewStep) {
3228
+ const nextStepParams = import_lodash.default.cloneDeep(detachedTarget.stepParams || {});
3229
+ const currentGroup = import_lodash.default.isPlainObject(nextStepParams[resolvedOpenViewStep.flowKey]) ? import_lodash.default.cloneDeep(nextStepParams[resolvedOpenViewStep.flowKey]) : {};
3230
+ const currentOpenView = import_lodash.default.isPlainObject(currentGroup[resolvedOpenViewStep.stepKey]) ? import_lodash.default.omit((0, import_template_service_utils.stripTemplateInternalOpenViewFields)(currentGroup[resolvedOpenViewStep.stepKey]) || {}, ["uid"]) : {};
3231
+ const nextOpenView = (0, import_service_utils.buildDefinedPayload)({
3232
+ ...currentOpenView,
3233
+ dataSourceKey: inferred.dataSourceKey || currentOpenView.dataSourceKey,
3234
+ collectionName: inferred.collectionName || currentOpenView.collectionName,
3235
+ associationName: inferred.associationName || currentOpenView.associationName,
3236
+ filterByTk: inferred.filterByTk || currentOpenView.filterByTk,
3237
+ sourceId: inferred.sourceId || currentOpenView.sourceId
3238
+ });
3239
+ if (!import_lodash.default.isEqual(nextOpenView, currentOpenView)) {
3240
+ currentGroup[resolvedOpenViewStep.stepKey] = nextOpenView;
3241
+ nextStepParams[resolvedOpenViewStep.flowKey] = currentGroup;
3242
+ await this.repository.patch(
3243
+ {
3244
+ uid: detachedTarget.uid,
3245
+ stepParams: nextStepParams
3246
+ },
3247
+ { transaction }
3248
+ );
3249
+ detachedTarget.stepParams = nextStepParams;
3250
+ }
3156
3251
  }
3157
- currentGroup[resolvedOpenViewStep.stepKey] = nextOpenView;
3158
- nextStepParams[resolvedOpenViewStep.flowKey] = currentGroup;
3159
- await this.repository.patch(
3160
- {
3161
- uid: detachedTarget.uid,
3162
- stepParams: nextStepParams
3163
- },
3164
- { transaction }
3165
- );
3252
+ await this.hydrateDetachedPopupTemplateBlockResourceContext(detachedTarget, inferred, transaction);
3166
3253
  }
3167
3254
  async clearFlowTemplateUsagesByModelUids(modelUids, transaction) {
3168
3255
  const usageRepo = this.getFlowTemplateUsageRepositorySafe();
@@ -3379,7 +3466,7 @@ class FlowSurfacesService {
3379
3466
  }
3380
3467
  const nextStepParams = import_lodash.default.cloneDeep(sourceNode.stepParams || {});
3381
3468
  const currentGroup = import_lodash.default.isPlainObject(nextStepParams[openViewStep.flowKey]) ? import_lodash.default.cloneDeep(nextStepParams[openViewStep.flowKey]) : {};
3382
- currentGroup[openViewStep.stepKey] = {
3469
+ let nextOpenView = {
3383
3470
  ...import_lodash.default.omit(openViewStep.openView || {}, [
3384
3471
  "popupTemplateUid",
3385
3472
  "popupTemplateMode",
@@ -3389,6 +3476,10 @@ class FlowSurfacesService {
3389
3476
  ]),
3390
3477
  ...this.buildPopupTemplateReferenceOpenView(template, templateTargetUid)
3391
3478
  };
3479
+ if (String(sourceNode.use || "").trim() === "AddChildActionModel") {
3480
+ nextOpenView = await this.normalizeAddChildOpenViewForAction(sourceNode, nextOpenView, transaction);
3481
+ }
3482
+ currentGroup[openViewStep.stepKey] = nextOpenView;
3392
3483
  nextStepParams[openViewStep.flowKey] = currentGroup;
3393
3484
  await this.cleanupLocalPopupSurfaceForHost(sourceNode.uid, transaction, sourceNode);
3394
3485
  await this.repository.patch(
@@ -3591,7 +3682,7 @@ class FlowSurfacesService {
3591
3682
  };
3592
3683
  }
3593
3684
  const openViewStep = (0, import_template_service_utils.findFlowTemplateOpenViewStep)(node);
3594
- const popupTemplateUid = String(((_a = openViewStep == null ? void 0 : openViewStep.openView) == null ? void 0 : _a.popupTemplateUid) || "").trim();
3685
+ const popupTemplateUid = this.isPopupTemplateReferenceOpenViewState(openViewStep == null ? void 0 : openViewStep.openView) ? String(((_a = openViewStep == null ? void 0 : openViewStep.openView) == null ? void 0 : _a.popupTemplateUid) || "").trim() : "";
3595
3686
  if (popupTemplateUid) {
3596
3687
  const template = await this.getFlowTemplateOrThrow(actionName, popupTemplateUid, {
3597
3688
  transaction,
@@ -3680,6 +3771,13 @@ class FlowSurfacesService {
3680
3771
  ]),
3681
3772
  ...this.buildPopupTemplateOpenView(resolved.template, "copy", popupUid)
3682
3773
  };
3774
+ if (String(node.use || "").trim() === "AddChildActionModel") {
3775
+ currentGroup[resolved.openViewStep.stepKey] = await this.normalizeAddChildOpenViewForAction(
3776
+ node,
3777
+ currentGroup[resolved.openViewStep.stepKey],
3778
+ options.transaction
3779
+ );
3780
+ }
3683
3781
  nextStepParams[resolved.openViewStep.flowKey] = currentGroup;
3684
3782
  await this.cleanupLocalPopupSurfaceForHost(node.uid, options.transaction, node);
3685
3783
  await this.repository.patch(
@@ -3883,19 +3981,52 @@ class FlowSurfacesService {
3883
3981
  });
3884
3982
  const result = await (0, import_compose_runtime.executeComposeRuntime)(plan, {
3885
3983
  removeExistingItem: async (uid2) => this.removeNodeTreeWithBindings(uid2, options.transaction),
3886
- createBlock: async (payload) => this.addBlock(payload, {
3887
- ...options,
3888
- deferAutoLayout: true,
3889
- enabledPackages,
3890
- skipDefaultBlockActions: true
3891
- }),
3984
+ createBlock: async (payload, spec) => {
3985
+ const calendarPopupSettings = spec.type === "calendar" && spec.settings ? import_lodash.default.pick(spec.settings, [
3986
+ "quickCreatePopup",
3987
+ "eventPopup",
3988
+ "quickCreatePopupSettings",
3989
+ "eventPopupSettings"
3990
+ ]) : {};
3991
+ const kanbanPopupSettings = spec.type === "kanban" && spec.settings ? import_lodash.default.pick(spec.settings, [
3992
+ "groupField",
3993
+ "groupOptions",
3994
+ "groupTitleField",
3995
+ "groupColorField",
3996
+ "styleVariant",
3997
+ "dragEnabled",
3998
+ "dragSortBy",
3999
+ "quickCreateEnabled",
4000
+ "enableCardClick",
4001
+ "quickCreatePopup",
4002
+ "cardPopup",
4003
+ "quickCreatePopupSettings",
4004
+ "cardPopupSettings"
4005
+ ]) : {};
4006
+ const hiddenPopupSettings = {
4007
+ ...calendarPopupSettings,
4008
+ ...kanbanPopupSettings
4009
+ };
4010
+ return this.addBlock(
4011
+ {
4012
+ ...payload,
4013
+ ...Object.keys(hiddenPopupSettings).length ? { settings: hiddenPopupSettings } : {}
4014
+ },
4015
+ {
4016
+ ...options,
4017
+ deferAutoLayout: true,
4018
+ enabledPackages,
4019
+ skipDefaultBlockActions: true
4020
+ }
4021
+ );
4022
+ },
3892
4023
  applyNodeSettings: async (actionName, targetUid, settings) => {
3893
4024
  if (!targetUid) {
3894
4025
  return;
3895
4026
  }
3896
4027
  await this.applyInlineNodeSettings(actionName, targetUid, settings, options);
3897
4028
  },
3898
- resolveBlockSettings: (settings, state) => this.resolveComposeBlockSettings(settings, state.keyMap),
4029
+ resolveBlockSettings: (settings, state, block) => this.resolveComposeBlockSettings(settings, state.keyMap, block),
3899
4030
  createField: async (payload) => this.addField(payload, {
3900
4031
  ...options,
3901
4032
  popupTemplateAliasSession
@@ -4978,7 +5109,7 @@ class FlowSurfacesService {
4978
5109
  };
4979
5110
  }
4980
5111
  async addBlock(values, options = {}) {
4981
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
5112
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
4982
5113
  const templateRef = import_lodash.default.isUndefined(values == null ? void 0 : values.template) ? void 0 : this.normalizeFlowTemplateReference("addBlock", values.template, {
4983
5114
  allowUsage: true,
4984
5115
  expectedType: "block"
@@ -5010,12 +5141,16 @@ class FlowSurfacesService {
5010
5141
  const enabledPackages = await this.resolveEnabledPluginPackages(options);
5011
5142
  const hasInlineFields = Object.prototype.hasOwnProperty.call(values || {}, "fields") || Object.prototype.hasOwnProperty.call(values || {}, "fieldsLayout");
5012
5143
  let resolvedTarget = await this.locator.resolve(target, options);
5013
- let targetNode = await this.loadResolvedNode(resolvedTarget, options.transaction);
5144
+ let targetNode = await this.loadResolvedNode(resolvedTarget, options.transaction, {
5145
+ ensureManagedPopupTemplateTargets: true
5146
+ });
5014
5147
  const targetOpenView = this.resolvePopupHostOpenView(targetNode);
5015
5148
  if (this.isPopupFieldHostUse(targetNode == null ? void 0 : targetNode.use) && !targetOpenView) {
5016
5149
  await this.ensureLocalFieldPopupSurface("addBlock", target.uid, options, { popup: {} });
5017
5150
  resolvedTarget = await this.locator.resolve(target, options);
5018
- targetNode = await this.loadResolvedNode(resolvedTarget, options.transaction);
5151
+ targetNode = await this.loadResolvedNode(resolvedTarget, options.transaction, {
5152
+ ensureManagedPopupTemplateTargets: true
5153
+ });
5019
5154
  }
5020
5155
  const popupProfile = await this.resolvePopupBlockProfile(
5021
5156
  target.uid,
@@ -5073,11 +5208,13 @@ class FlowSurfacesService {
5073
5208
  const blockProps = catalogItem.use === "CalendarBlockModel" ? this.buildCalendarInitialBlockProps({
5074
5209
  actionName: "addBlock",
5075
5210
  resourceInit: effectiveResourceInit,
5076
- props: values.props
5211
+ props: values.props,
5212
+ settings: inlineSettings
5077
5213
  }) : catalogItem.use === "KanbanBlockModel" ? this.buildKanbanInitialBlockProps({
5078
5214
  actionName: "addBlock",
5079
5215
  resourceInit: effectiveResourceInit,
5080
- props: values.props
5216
+ props: values.props,
5217
+ settings: inlineSettings
5081
5218
  }) : values.props;
5082
5219
  const initialGrid = options.deferAutoLayout ? null : await this.repository.findModelById(parentUid, {
5083
5220
  transaction: options.transaction,
@@ -5087,10 +5224,42 @@ class FlowSurfacesService {
5087
5224
  use: catalogItem.use,
5088
5225
  containerUse: parentNode == null ? void 0 : parentNode.use,
5089
5226
  resourceInit: effectiveResourceInit,
5227
+ enableDefaultSorting: this.shouldEnableCreatedAtDefaultSorting(effectiveResourceInit),
5090
5228
  props: blockProps,
5091
5229
  decoratorProps: values.decoratorProps,
5092
- stepParams: values.stepParams
5093
- });
5230
+ stepParams: catalogItem.use === "CalendarBlockModel" ? this.buildCalendarInitialStepParams({
5231
+ stepParams: values.stepParams,
5232
+ props: values.props,
5233
+ settings: inlineSettings
5234
+ }) : catalogItem.use === "KanbanBlockModel" ? this.buildKanbanInitialStepParams({
5235
+ stepParams: values.stepParams,
5236
+ props: values.props,
5237
+ settings: inlineSettings
5238
+ }) : values.stepParams
5239
+ });
5240
+ if (catalogItem.use === "KanbanBlockModel") {
5241
+ const itemNode2 = (0, import_service_utils.getSingleNodeSubModel)((_a = tree.subModels) == null ? void 0 : _a.item);
5242
+ if (itemNode2) {
5243
+ const itemProps = this.buildKanbanInitialItemProps({
5244
+ props: values.props,
5245
+ settings: inlineSettings
5246
+ });
5247
+ const itemStepParams = this.buildKanbanInitialItemStepParams({
5248
+ stepParams: itemNode2.stepParams,
5249
+ props: values.props,
5250
+ settings: inlineSettings
5251
+ });
5252
+ if (Object.keys(itemProps).length) {
5253
+ itemNode2.props = {
5254
+ ...itemNode2.props || {},
5255
+ ...itemProps
5256
+ };
5257
+ }
5258
+ if (Object.keys(itemStepParams).length) {
5259
+ itemNode2.stepParams = itemStepParams;
5260
+ }
5261
+ }
5262
+ }
5094
5263
  this.contractGuard.validateNodeTreeAgainstContract(tree);
5095
5264
  const created = await this.repository.upsertModel(
5096
5265
  {
@@ -5101,13 +5270,13 @@ class FlowSurfacesService {
5101
5270
  },
5102
5271
  { transaction: options.transaction }
5103
5272
  );
5104
- const gridNode = (0, import_service_utils.getSingleNodeSubModel)((_a = tree.subModels) == null ? void 0 : _a.grid);
5105
- const itemNode = (0, import_service_utils.getSingleNodeSubModel)((_b = tree.subModels) == null ? void 0 : _b.item);
5106
- const itemGridNode = (0, import_service_utils.getSingleNodeSubModel)((_c = itemNode == null ? void 0 : itemNode.subModels) == null ? void 0 : _c.grid);
5107
- const columnNodes = (0, import_service_utils.getNodeSubModelList)((_d = tree.subModels) == null ? void 0 : _d.columns);
5273
+ const gridNode = (0, import_service_utils.getSingleNodeSubModel)((_b = tree.subModels) == null ? void 0 : _b.grid);
5274
+ const itemNode = (0, import_service_utils.getSingleNodeSubModel)((_c = tree.subModels) == null ? void 0 : _c.item);
5275
+ const itemGridNode = (0, import_service_utils.getSingleNodeSubModel)((_d = itemNode == null ? void 0 : itemNode.subModels) == null ? void 0 : _d.grid);
5276
+ const columnNodes = (0, import_service_utils.getNodeSubModelList)((_e = tree.subModels) == null ? void 0 : _e.columns);
5108
5277
  const blockGridUid = (gridNode == null ? void 0 : gridNode.uid) || (itemGridNode == null ? void 0 : itemGridNode.uid);
5109
5278
  const popupGridUid = popupSurface == null ? void 0 : popupSurface.gridUid;
5110
- const actionsColumnUid = catalogItem.use === "TableBlockModel" ? await this.ensureTableActionsColumn(created, options.transaction) : (_e = columnNodes.find((item) => item.use === "TableActionsColumnModel")) == null ? void 0 : _e.uid;
5279
+ const actionsColumnUid = catalogItem.use === "TableBlockModel" ? await this.ensureTableActionsColumn(created, options.transaction) : (_f = columnNodes.find((item) => item.use === "TableActionsColumnModel")) == null ? void 0 : _f.uid;
5111
5280
  const result = {
5112
5281
  uid: created,
5113
5282
  parentUid,
@@ -5125,8 +5294,52 @@ class FlowSurfacesService {
5125
5294
  popupGridUid: popupSurface.gridUid
5126
5295
  } : {}
5127
5296
  };
5128
- await this.applyInlineNodeSettings("addBlock", created, inlineSettings, options);
5129
- if ((_f = inlineFields == null ? void 0 : inlineFields.fields) == null ? void 0 : _f.length) {
5297
+ const ensureInitialBlockPopupHosts = async () => {
5298
+ if (catalogItem.use === "CalendarBlockModel") {
5299
+ const calendarNode = await this.repository.findModelById(created, {
5300
+ transaction: options.transaction,
5301
+ includeAsyncNode: true
5302
+ });
5303
+ if (calendarNode == null ? void 0 : calendarNode.uid) {
5304
+ await this.ensureCalendarBlockPopupHosts(calendarNode, options.transaction, {
5305
+ quickCreateAction: this.resolveCalendarInitialPopupOverride(
5306
+ inlineSettings,
5307
+ "quickCreatePopup",
5308
+ "quickCreatePopupSettings"
5309
+ ),
5310
+ eventViewAction: this.resolveCalendarInitialPopupOverride(
5311
+ inlineSettings,
5312
+ "eventPopup",
5313
+ "eventPopupSettings"
5314
+ )
5315
+ });
5316
+ }
5317
+ }
5318
+ if (catalogItem.use === "KanbanBlockModel") {
5319
+ const kanbanNode = await this.repository.findModelById(created, {
5320
+ transaction: options.transaction,
5321
+ includeAsyncNode: true
5322
+ });
5323
+ if (kanbanNode == null ? void 0 : kanbanNode.uid) {
5324
+ await this.ensureKanbanBlockPopupHosts(kanbanNode, options.transaction, {
5325
+ quickCreateAction: this.resolveKanbanInitialPopupOverride(
5326
+ inlineSettings,
5327
+ "quickCreatePopup",
5328
+ "quickCreatePopupSettings"
5329
+ ),
5330
+ cardViewAction: this.resolveKanbanInitialPopupOverride(inlineSettings, "cardPopup", "cardPopupSettings")
5331
+ });
5332
+ }
5333
+ }
5334
+ };
5335
+ await ensureInitialBlockPopupHosts();
5336
+ const inlineSettingsForConfigure = catalogItem.use === "CalendarBlockModel" ? this.omitHiddenPopupSettingsForConfigure(
5337
+ this.normalizeCalendarInlineSettingsForConfigure(inlineSettings),
5338
+ "calendar"
5339
+ ) : catalogItem.use === "KanbanBlockModel" ? this.omitHiddenPopupSettingsForConfigure(inlineSettings, "kanban") : inlineSettings;
5340
+ await this.applyInlineNodeSettings("addBlock", created, inlineSettingsForConfigure, options);
5341
+ await ensureInitialBlockPopupHosts();
5342
+ if ((_g = inlineFields == null ? void 0 : inlineFields.fields) == null ? void 0 : _g.length) {
5130
5343
  const fieldTargetUid = this.resolveComposeFieldContainerUid(inlineFields, result);
5131
5344
  const createdByKey = {};
5132
5345
  for (const fieldSpec of inlineFields.fields) {
@@ -5174,7 +5387,7 @@ class FlowSurfacesService {
5174
5387
  includeAsyncNode: true
5175
5388
  });
5176
5389
  const layoutItems = import_lodash.default.castArray(
5177
- ((_i = (_h = (_g = layoutHost == null ? void 0 : layoutHost.subModels) == null ? void 0 : _g.grid) == null ? void 0 : _h.subModels) == null ? void 0 : _i.items) || ((_j = layoutHost == null ? void 0 : layoutHost.subModels) == null ? void 0 : _j.items) || []
5390
+ ((_j = (_i = (_h = layoutHost == null ? void 0 : layoutHost.subModels) == null ? void 0 : _h.grid) == null ? void 0 : _i.subModels) == null ? void 0 : _j.items) || ((_k = layoutHost == null ? void 0 : layoutHost.subModels) == null ? void 0 : _k.items) || []
5178
5391
  );
5179
5392
  const layoutPayload = this.buildComposeLayoutPayload({
5180
5393
  layout: inlineFields.fieldsLayout,
@@ -5366,6 +5579,7 @@ class FlowSurfacesService {
5366
5579
  collectionName: resolvedField.collectionName,
5367
5580
  fieldPath: resolvedField.fieldPath,
5368
5581
  associationPathName: resolvedField.associationPathName,
5582
+ ...(0, import_service_utils.hasOwnDefined)(values, "titleField") ? { explicitTitleField: values.titleField } : {},
5369
5583
  bindingChange: true,
5370
5584
  hasExistingTitleField: false,
5371
5585
  enabledPackages
@@ -5489,6 +5703,10 @@ class FlowSurfacesService {
5489
5703
  boundFieldCapability.fieldUse,
5490
5704
  values.fieldProps || {}
5491
5705
  );
5706
+ const requiredFieldWrapperDefaults = this.buildRequiredCollectionFieldFormWrapperDefaults({
5707
+ wrapperUse: boundFieldCapability.wrapperUse,
5708
+ field: resolvedField.field
5709
+ });
5492
5710
  const tree = (0, import_builder.buildFieldTree)({
5493
5711
  wrapperUse: boundFieldCapability.wrapperUse,
5494
5712
  fieldUse: boundFieldCapability.fieldUse,
@@ -5501,6 +5719,7 @@ class FlowSurfacesService {
5501
5719
  {},
5502
5720
  defaultFieldState.wrapperProps || {},
5503
5721
  wrapperShouldPersistTitleField ? { titleField: defaultTitleField } : {},
5722
+ requiredFieldWrapperDefaults.props,
5504
5723
  values.wrapperProps || {}
5505
5724
  ),
5506
5725
  fieldProps: import_lodash.default.merge(
@@ -5511,6 +5730,18 @@ class FlowSurfacesService {
5511
5730
  )
5512
5731
  });
5513
5732
  this.contractGuard.validateNodeTreeAgainstContract(tree.model);
5733
+ if (wrapperShouldPersistTitleField && boundFieldCapability.wrapperUse === "TableColumnModel") {
5734
+ tree.model.stepParams = import_lodash.default.merge({}, tree.model.stepParams || {}, {
5735
+ tableColumnSettings: {
5736
+ fieldNames: {
5737
+ label: defaultTitleField
5738
+ }
5739
+ }
5740
+ });
5741
+ }
5742
+ if (requiredFieldWrapperDefaults.stepParams) {
5743
+ tree.model.stepParams = import_lodash.default.merge({}, tree.model.stepParams || {}, requiredFieldWrapperDefaults.stepParams);
5744
+ }
5514
5745
  await this.repository.upsertModel(
5515
5746
  {
5516
5747
  parentId: container.parentUid,
@@ -5700,10 +5931,11 @@ class FlowSurfacesService {
5700
5931
  });
5701
5932
  const materializedContainer = await this.materializeRecordActionContainer(container, options.transaction);
5702
5933
  const resourceContext = container.ownerUid ? await this.locator.resolveCollectionContext(container.ownerUid, options.transaction).catch(() => null) : null;
5934
+ const resourceInit = this.isAddChildCatalogItem(actionCatalogItem) ? await this.resolveAddChildResourceInitForOwnerNode(container.ownerNode, options.transaction) : values.resourceInit || (resourceContext == null ? void 0 : resourceContext.resourceInit);
5703
5935
  const action = (0, import_builder.buildActionTree)({
5704
5936
  use: actionCatalogItem.use,
5705
5937
  containerUse: container.containerUse,
5706
- resourceInit: values.resourceInit || (resourceContext == null ? void 0 : resourceContext.resourceInit),
5938
+ resourceInit,
5707
5939
  props: values.props,
5708
5940
  decoratorProps: values.decoratorProps,
5709
5941
  stepParams: values.stepParams,
@@ -5995,7 +6227,8 @@ class FlowSurfacesService {
5995
6227
  const availableAliases = new Set(popupTemplateAliasSession ? popupTemplateAliasSession.keys() : []);
5996
6228
  document.tabs.forEach((tab, tabIndex) => {
5997
6229
  const composeValues = (0, import_compile_blocks.compileTabComposeValues)(tab, document, tabIndex, {
5998
- mode: document.mode === "replace" ? "replace" : "append"
6230
+ mode: document.mode === "replace" ? "replace" : "append",
6231
+ getCollection: (dataSourceKey, collectionName) => this.getCollection(dataSourceKey || "main", collectionName || "")
5999
6232
  });
6000
6233
  this.validatePopupTemplateAliasesInBlocks(
6001
6234
  import_lodash.default.castArray(composeValues.blocks || []),
@@ -6013,6 +6246,21 @@ class FlowSurfacesService {
6013
6246
  }
6014
6247
  return settings;
6015
6248
  }
6249
+ shouldEnableCreatedAtDefaultSorting(resourceInit) {
6250
+ const collectionName = String((resourceInit == null ? void 0 : resourceInit.collectionName) || "").trim();
6251
+ if (!collectionName) {
6252
+ return false;
6253
+ }
6254
+ const dataSourceKey = String((resourceInit == null ? void 0 : resourceInit.dataSourceKey) || "main").trim() || "main";
6255
+ const collection = this.getCollection(dataSourceKey, collectionName);
6256
+ return !!(0, import_service_helpers.resolveFieldFromCollection)(collection, "createdAt");
6257
+ }
6258
+ normalizeBlockSortingInput(value, context) {
6259
+ return (0, import_public_compatibility.normalizeFlowSurfaceDefaultSorting)(value, context);
6260
+ }
6261
+ normalizeMapSortingInput(value, context) {
6262
+ return (0, import_public_compatibility.normalizeFlowSurfaceEmptySortingAsDefault)(value, context);
6263
+ }
6016
6264
  normalizeInlinePopup(actionName, popup) {
6017
6265
  if (import_lodash.default.isUndefined(popup)) {
6018
6266
  return void 0;
@@ -6171,8 +6419,33 @@ class FlowSurfacesService {
6171
6419
  shouldAutoSaveDefaultActionPopupTemplate(popup) {
6172
6420
  return (popup == null ? void 0 : popup[import_default_block_actions.FLOW_SURFACE_INTERNAL_AUTO_SAVE_DEFAULT_POPUP_TEMPLATE_KEY]) === true;
6173
6421
  }
6422
+ resolveDefaultActionPopupSemanticUse(use) {
6423
+ const normalizedUse = String(use || "").trim();
6424
+ if (normalizedUse === "AddChildActionModel") {
6425
+ return "AddNewActionModel";
6426
+ }
6427
+ if (normalizedUse === "CalendarQuickCreateActionModel") {
6428
+ return "AddNewActionModel";
6429
+ }
6430
+ if (normalizedUse === "CalendarEventViewActionModel") {
6431
+ return "ViewActionModel";
6432
+ }
6433
+ if (normalizedUse === "KanbanQuickCreateActionModel") {
6434
+ return "AddNewActionModel";
6435
+ }
6436
+ if (normalizedUse === "KanbanCardViewActionModel") {
6437
+ return "ViewActionModel";
6438
+ }
6439
+ return normalizedUse || void 0;
6440
+ }
6441
+ getDefaultActionPopupConfigForNode(actionNode) {
6442
+ return (0, import_default_action_popup.getFlowSurfaceDefaultActionPopupConfigByUse)(this.resolveDefaultActionPopupSemanticUse(actionNode == null ? void 0 : actionNode.use));
6443
+ }
6444
+ isDefaultActionPopupUseForNode(actionNode) {
6445
+ return !!this.getDefaultActionPopupConfigForNode(actionNode);
6446
+ }
6174
6447
  shouldImplicitlyTemplateDefaultActionPopup(actionNode, popup) {
6175
- if (!(0, import_default_action_popup.isFlowSurfaceDefaultActionPopupUse)(actionNode == null ? void 0 : actionNode.use)) {
6448
+ if (!this.isDefaultActionPopupUseForNode(actionNode)) {
6176
6449
  return false;
6177
6450
  }
6178
6451
  if (import_lodash.default.isPlainObject(popup == null ? void 0 : popup.template) || !import_lodash.default.isUndefined(popup == null ? void 0 : popup.saveAsTemplate)) {
@@ -6204,7 +6477,7 @@ class FlowSurfacesService {
6204
6477
  transaction,
6205
6478
  includeAsyncNode: true
6206
6479
  });
6207
- const actionConfig = (0, import_default_action_popup.getFlowSurfaceDefaultActionPopupConfigByUse)(actionNode == null ? void 0 : actionNode.use);
6480
+ const actionConfig = this.getDefaultActionPopupConfigForNode(actionNode);
6208
6481
  const popupProfile = (actionNode == null ? void 0 : actionNode.uid) ? await this.resolvePopupBlockProfile(actionNode.uid, null, actionNode, transaction).catch(() => null) : null;
6209
6482
  const popupType = actionConfig == null ? void 0 : actionConfig.type;
6210
6483
  const collectionLabel = String(
@@ -6253,10 +6526,13 @@ class FlowSurfacesService {
6253
6526
  if (explicitTitle) {
6254
6527
  return explicitTitle;
6255
6528
  }
6256
- if (!(0, import_default_action_popup.isFlowSurfaceDefaultActionPopupUse)(actionNode == null ? void 0 : actionNode.use)) {
6529
+ if (!this.isDefaultActionPopupUseForNode(actionNode)) {
6257
6530
  return void 0;
6258
6531
  }
6259
- return (0, import_default_action_popup.resolveFlowSurfaceDefaultActionPopupTabTitle)(actionNode == null ? void 0 : actionNode.use, this.getActionButtonTitle(actionNode));
6532
+ return (0, import_default_action_popup.resolveFlowSurfaceDefaultActionPopupTabTitle)(
6533
+ this.resolveDefaultActionPopupSemanticUse(actionNode == null ? void 0 : actionNode.use),
6534
+ this.getActionButtonTitle(actionNode)
6535
+ );
6260
6536
  }
6261
6537
  buildInlinePopupTemplateOpenView(popup, fallbackTitle) {
6262
6538
  const normalizedTitle = this.normalizeOptionalPopupTitle(popup == null ? void 0 : popup.title) || this.normalizeOptionalPopupTitle(fallbackTitle);
@@ -6359,13 +6635,16 @@ class FlowSurfacesService {
6359
6635
  return ["-updatedAt", "-createdAt", "uid"];
6360
6636
  }
6361
6637
  getPopupTryTemplateExpectedAssociationName(targetContext) {
6362
- var _a, _b, _c;
6363
- if ((_a = targetContext == null ? void 0 : targetContext.popupProfile) == null ? void 0 : _a.isPopupSurface) {
6638
+ var _a, _b, _c, _d, _e;
6639
+ if (String(((_a = targetContext == null ? void 0 : targetContext.node) == null ? void 0 : _a.use) || "").trim() === "AddChildActionModel") {
6640
+ return String(((_b = this.resolvePopupHostOpenView(targetContext.node)) == null ? void 0 : _b.associationName) || "").trim() || void 0;
6641
+ }
6642
+ if ((_c = targetContext == null ? void 0 : targetContext.popupProfile) == null ? void 0 : _c.isPopupSurface) {
6364
6643
  return String(targetContext.popupProfile.associationName || "").trim() || void 0;
6365
6644
  }
6366
- return String(((_c = (_b = targetContext == null ? void 0 : targetContext.resourceContext) == null ? void 0 : _b.resourceInit) == null ? void 0 : _c.associationName) || "").trim() || void 0;
6645
+ return String(((_e = (_d = targetContext == null ? void 0 : targetContext.resourceContext) == null ? void 0 : _d.resourceInit) == null ? void 0 : _e.associationName) || "").trim() || void 0;
6367
6646
  }
6368
- getPopupTryTemplatePriority(template, expectedAssociationName) {
6647
+ getPopupTryTemplatePriority(template, expectedAssociationName, options = {}) {
6369
6648
  const templateAssociationName = String(template.associationName || "").trim() || void 0;
6370
6649
  if (!expectedAssociationName) {
6371
6650
  return templateAssociationName ? null : 0;
@@ -6373,11 +6652,18 @@ class FlowSurfacesService {
6373
6652
  if (templateAssociationName === expectedAssociationName) {
6374
6653
  return 0;
6375
6654
  }
6655
+ if (options.requireExactAssociationName) {
6656
+ return null;
6657
+ }
6376
6658
  if (!templateAssociationName) {
6377
6659
  return 1;
6378
6660
  }
6379
6661
  return null;
6380
6662
  }
6663
+ shouldRequireExactPopupTryTemplateAssociation(targetContext) {
6664
+ var _a;
6665
+ return String(((_a = targetContext == null ? void 0 : targetContext.node) == null ? void 0 : _a.use) || "").trim() === "AddChildActionModel" && !!this.getPopupTryTemplateExpectedAssociationName(targetContext);
6666
+ }
6381
6667
  getRequestedPopupDefaultType(popup) {
6382
6668
  const normalized = String((popup == null ? void 0 : popup.defaultType) || "").trim();
6383
6669
  if (normalized === "view" || normalized === "edit") {
@@ -6398,7 +6684,21 @@ class FlowSurfacesService {
6398
6684
  if (this.isPopupFieldHostUse(targetUse)) {
6399
6685
  return ["view", "generic"];
6400
6686
  }
6401
- const actionConfig = (0, import_default_action_popup.getFlowSurfaceDefaultActionPopupConfigByUse)(targetUse);
6687
+ if (targetUse === "CalendarQuickCreateActionModel") {
6688
+ return ["addNew"];
6689
+ }
6690
+ if (targetUse === "CalendarEventViewActionModel") {
6691
+ return ["view", "generic"];
6692
+ }
6693
+ if (targetUse === "KanbanQuickCreateActionModel") {
6694
+ return ["addNew"];
6695
+ }
6696
+ if (targetUse === "KanbanCardViewActionModel") {
6697
+ return ["view", "generic"];
6698
+ }
6699
+ const actionConfig = (0, import_default_action_popup.getFlowSurfaceDefaultActionPopupConfigByUse)(
6700
+ this.resolveDefaultActionPopupSemanticUse(targetUse)
6701
+ );
6402
6702
  if (actionConfig) {
6403
6703
  return actionConfig.type === "view" ? ["view", "generic"] : [actionConfig.type];
6404
6704
  }
@@ -6470,9 +6770,12 @@ class FlowSurfacesService {
6470
6770
  targetContext,
6471
6771
  options.popupActionContext
6472
6772
  );
6773
+ const requireExactAssociationName = this.shouldRequireExactPopupTryTemplateAssociation(targetContext);
6473
6774
  for (const priority of [0, 1]) {
6474
6775
  for (const template of annotatedTemplates) {
6475
- if (template.available !== true || this.getPopupTryTemplatePriority(template, expectedAssociationName) !== priority) {
6776
+ if (template.available !== true || this.getPopupTryTemplatePriority(template, expectedAssociationName, {
6777
+ requireExactAssociationName
6778
+ }) !== priority) {
6476
6779
  continue;
6477
6780
  }
6478
6781
  if (await this.popupTemplateMatchesDefaultType(template, popup, {
@@ -6542,7 +6845,8 @@ class FlowSurfacesService {
6542
6845
  ...popupTemplateHasSourceId && template.sourceId ? { sourceId: template.sourceId } : {},
6543
6846
  popupTemplateHasFilterByTk,
6544
6847
  popupTemplateHasSourceId,
6545
- popupTemplateMode: mode
6848
+ popupTemplateMode: mode,
6849
+ popupTemplateUid: template.uid
6546
6850
  });
6547
6851
  if (mode === "copy") {
6548
6852
  return {
@@ -6550,16 +6854,21 @@ class FlowSurfacesService {
6550
6854
  popupTemplateContext: true
6551
6855
  };
6552
6856
  }
6553
- return {
6554
- ...base,
6555
- popupTemplateUid: template.uid
6556
- };
6857
+ return base;
6557
6858
  }
6558
6859
  isReferencedPopupTemplateOpenView(openView, hostUid) {
6559
- return !!this.resolveExternalPopupHostUid(hostUid, openView) && !!String((openView == null ? void 0 : openView.popupTemplateUid) || "").trim() && !(openView == null ? void 0 : openView.popupTemplateContext);
6860
+ return !!this.resolveExternalPopupHostUid(hostUid, openView) && this.isPopupTemplateReferenceOpenViewState(openView);
6861
+ }
6862
+ isPopupTemplateReferenceOpenViewState(openView) {
6863
+ const popupTemplateUid = String((openView == null ? void 0 : openView.popupTemplateUid) || "").trim();
6864
+ if (!popupTemplateUid || (openView == null ? void 0 : openView.popupTemplateContext)) {
6865
+ return false;
6866
+ }
6867
+ const popupTemplateMode = String((openView == null ? void 0 : openView.popupTemplateMode) || "reference").trim() || "reference";
6868
+ return popupTemplateMode !== "copy";
6560
6869
  }
6561
6870
  isEditableDefaultActionPopupTemplateReference(hostNode, openView) {
6562
- return (0, import_default_action_popup.isFlowSurfaceDefaultActionPopupUse)(hostNode == null ? void 0 : hostNode.use) && this.isReferencedPopupTemplateOpenView(openView, hostNode == null ? void 0 : hostNode.uid);
6871
+ return this.isDefaultActionPopupUseForNode(hostNode) && this.isReferencedPopupTemplateOpenView(openView, hostNode == null ? void 0 : hostNode.uid);
6563
6872
  }
6564
6873
  resolveExternalPopupHostUid(hostUid, openView) {
6565
6874
  const normalizedHostUid = String(hostUid || "").trim();
@@ -6641,12 +6950,10 @@ class FlowSurfacesService {
6641
6950
  transaction: options.transaction,
6642
6951
  expectedType: "popup"
6643
6952
  });
6644
- await this.assertPopupTemplateCompatibility(
6645
- actionName,
6646
- options.popupTemplateHostUid,
6647
- template,
6648
- options.transaction
6649
- );
6953
+ await this.assertPopupTemplateCompatibility(actionName, options.popupTemplateHostUid, template, {
6954
+ transaction: options.transaction,
6955
+ popupActionContext: options.popupActionContext
6956
+ });
6650
6957
  const resolvedUid = templateRef.mode === "copy" ? String(
6651
6958
  ((_a = await this.duplicateDetachedFlowModelTree(actionName, template.targetUid, options.transaction)) == null ? void 0 : _a.uid) || ""
6652
6959
  ) : template.targetUid;
@@ -6659,12 +6966,15 @@ class FlowSurfacesService {
6659
6966
  if (templateRef.mode === "copy") {
6660
6967
  await this.ensurePopupSurface(resolvedUid, options.transaction);
6661
6968
  }
6662
- const nextTemplateOpenView = this.buildPopupTemplateOpenView(template, templateRef.mode, resolvedUid);
6969
+ let nextTemplateOpenView = this.buildPopupTemplateOpenView(template, templateRef.mode, resolvedUid);
6663
6970
  Object.keys(normalizedOpenView).forEach((key) => {
6664
6971
  if (key === "template" || key === "popupTemplateUid" || key === "popupTemplateMode" || key === "popupTemplateContext" || key === "popupTemplateHasFilterByTk" || key === "popupTemplateHasSourceId") {
6665
6972
  delete normalizedOpenView[key];
6666
6973
  }
6667
6974
  });
6975
+ if (String(options.popupTemplateHostUse || "").trim() === "AddChildActionModel") {
6976
+ nextTemplateOpenView = import_lodash.default.omit(nextTemplateOpenView, ["sourceId"]);
6977
+ }
6668
6978
  Object.assign(normalizedOpenView, nextTemplateOpenView);
6669
6979
  }
6670
6980
  if (!import_lodash.default.isUndefined(normalizedOpenView.uid)) {
@@ -6672,8 +6982,11 @@ class FlowSurfacesService {
6672
6982
  if (!normalizedUid) {
6673
6983
  (0, import_errors.throwBadRequest)(`flowSurfaces ${actionName} openView.uid cannot be empty`);
6674
6984
  }
6985
+ const normalizedHostUid = String(options.popupTemplateHostUid || "").trim();
6675
6986
  normalizedOpenView.uid = normalizedUid;
6676
- await this.assertOpenViewUidTarget(actionName, normalizedUid, options);
6987
+ if (normalizedUid !== normalizedHostUid) {
6988
+ await this.assertOpenViewUidTarget(actionName, normalizedUid, options);
6989
+ }
6677
6990
  }
6678
6991
  if (!import_lodash.default.isUndefined(normalizedOpenView.mode)) {
6679
6992
  const rawMode = String(normalizedOpenView.mode || "").trim();
@@ -6863,14 +7176,28 @@ class FlowSurfacesService {
6863
7176
  (0, import_service_utils.rethrowInlineConfigurationError)(error, `flowSurfaces ${actionName} settings invalid`);
6864
7177
  }
6865
7178
  }
6866
- resolveComposeBlockSettings(settings, keyMap) {
6867
- if (!import_lodash.default.isPlainObject(settings == null ? void 0 : settings.connectFields) || !Array.isArray(settings.connectFields.targets)) {
6868
- return settings;
6869
- }
6870
- const nextSettings = import_lodash.default.cloneDeep(settings);
6871
- nextSettings.connectFields = {
6872
- ...nextSettings.connectFields,
6873
- targets: import_lodash.default.castArray(nextSettings.connectFields.targets).map((target) => {
7179
+ resolveComposeBlockSettings(settings, keyMap, block) {
7180
+ var _a, _b;
7181
+ let nextSettings = settings;
7182
+ if (((_a = block == null ? void 0 : block.spec) == null ? void 0 : _a.type) === "calendar") {
7183
+ nextSettings = import_lodash.default.omit(nextSettings, [
7184
+ "quickCreatePopup",
7185
+ "eventPopup",
7186
+ "quickCreatePopupSettings",
7187
+ "eventPopupSettings"
7188
+ ]);
7189
+ } else if (((_b = block == null ? void 0 : block.spec) == null ? void 0 : _b.type) === "kanban") {
7190
+ const omittedKeys = ["quickCreatePopup", "cardPopup", "quickCreatePopupSettings", "cardPopupSettings"];
7191
+ const withoutHiddenPopupSettings = import_lodash.default.omit(nextSettings, omittedKeys);
7192
+ nextSettings = Object.keys(withoutHiddenPopupSettings).length || omittedKeys.every((key) => !import_lodash.default.has(nextSettings, key)) ? withoutHiddenPopupSettings : {};
7193
+ }
7194
+ if (!import_lodash.default.isPlainObject(nextSettings == null ? void 0 : nextSettings.connectFields) || !Array.isArray(nextSettings.connectFields.targets)) {
7195
+ return nextSettings;
7196
+ }
7197
+ const resolvedSettings = import_lodash.default.cloneDeep(nextSettings);
7198
+ resolvedSettings.connectFields = {
7199
+ ...resolvedSettings.connectFields,
7200
+ targets: import_lodash.default.castArray(resolvedSettings.connectFields.targets).map((target) => {
6874
7201
  if (!import_lodash.default.isPlainObject(target) || import_lodash.default.isUndefined(target.target) || target.target === null || target.target === "") {
6875
7202
  return target;
6876
7203
  }
@@ -6882,7 +7209,7 @@ class FlowSurfacesService {
6882
7209
  return nextTarget;
6883
7210
  })
6884
7211
  };
6885
- return nextSettings;
7212
+ return resolvedSettings;
6886
7213
  }
6887
7214
  async applyInlineFieldPopup(actionName, result, popup, options) {
6888
7215
  popup = this.prepareInlinePopupTemplateAliases(actionName, popup, options.popupTemplateAliasSession);
@@ -7316,7 +7643,7 @@ class FlowSurfacesService {
7316
7643
  if (!(actionNode == null ? void 0 : actionNode.uid)) {
7317
7644
  return;
7318
7645
  }
7319
- const actionConfig = (0, import_default_action_popup.getFlowSurfaceDefaultActionPopupConfigByUse)(actionNode.use);
7646
+ const actionConfig = this.getDefaultActionPopupConfigForNode(actionNode);
7320
7647
  if (!actionConfig) {
7321
7648
  return;
7322
7649
  }
@@ -7326,7 +7653,7 @@ class FlowSurfacesService {
7326
7653
  }
7327
7654
  const uniqueKeySource = JSON.stringify(
7328
7655
  (0, import_service_utils.buildDefinedPayload)({
7329
- actionUse: actionNode.use,
7656
+ actionUse: this.resolveDefaultActionPopupSemanticUse(actionNode.use),
7330
7657
  dataSourceKey: openView == null ? void 0 : openView.dataSourceKey,
7331
7658
  collectionName: openView == null ? void 0 : openView.collectionName,
7332
7659
  associationName: openView == null ? void 0 : openView.associationName,
@@ -7363,7 +7690,7 @@ class FlowSurfacesService {
7363
7690
  if (options.autoCompleteDefaultPopup === false) {
7364
7691
  return false;
7365
7692
  }
7366
- if (!(0, import_default_action_popup.isFlowSurfaceDefaultActionPopupUse)(actionNode == null ? void 0 : actionNode.use)) {
7693
+ if (!this.isDefaultActionPopupUseForNode(actionNode)) {
7367
7694
  return false;
7368
7695
  }
7369
7696
  const openView = this.resolvePopupHostOpenView(actionNode);
@@ -7387,14 +7714,17 @@ class FlowSurfacesService {
7387
7714
  if (options.includeFallback === false) {
7388
7715
  return void 0;
7389
7716
  }
7390
- return (0, import_default_action_popup.resolveFlowSurfaceDefaultActionPopupTabTitle)(actionNode == null ? void 0 : actionNode.use, this.getActionButtonTitle(actionNode));
7717
+ return (0, import_default_action_popup.resolveFlowSurfaceDefaultActionPopupTabTitle)(
7718
+ this.resolveDefaultActionPopupSemanticUse(actionNode == null ? void 0 : actionNode.use),
7719
+ this.getActionButtonTitle(actionNode)
7720
+ );
7391
7721
  }
7392
7722
  resolveGeneratedDefaultActionPopupMetadata(actionNode, popup, popupProfile) {
7393
7723
  const explicitTitle = this.normalizeOptionalPopupTitle(popup == null ? void 0 : popup.title);
7394
7724
  if (explicitTitle) {
7395
7725
  return void 0;
7396
7726
  }
7397
- const actionConfig = (0, import_default_action_popup.getFlowSurfaceDefaultActionPopupConfigByUse)(actionNode == null ? void 0 : actionNode.use);
7727
+ const actionConfig = this.getDefaultActionPopupConfigForNode(actionNode);
7398
7728
  if (!actionConfig) {
7399
7729
  return void 0;
7400
7730
  }
@@ -7415,7 +7745,9 @@ class FlowSurfacesService {
7415
7745
  if (!collectionName) {
7416
7746
  return [];
7417
7747
  }
7418
- const actionConfig = (0, import_default_action_popup.getFlowSurfaceDefaultActionPopupConfigByUse)(input.actionUse);
7748
+ const actionConfig = (0, import_default_action_popup.getFlowSurfaceDefaultActionPopupConfigByUse)(
7749
+ this.resolveDefaultActionPopupSemanticUse(input.actionUse)
7750
+ );
7419
7751
  if (!actionConfig) {
7420
7752
  return [];
7421
7753
  }
@@ -7449,7 +7781,7 @@ class FlowSurfacesService {
7449
7781
  }
7450
7782
  buildDefaultActionPopupKeyMap(actionNode, namespace) {
7451
7783
  var _a;
7452
- const actionConfig = (0, import_default_action_popup.getFlowSurfaceDefaultActionPopupConfigByUse)(actionNode == null ? void 0 : actionNode.use);
7784
+ const actionConfig = this.getDefaultActionPopupConfigForNode(actionNode);
7453
7785
  if (!actionConfig || !namespace) {
7454
7786
  return /* @__PURE__ */ new Map();
7455
7787
  }
@@ -7571,7 +7903,7 @@ class FlowSurfacesService {
7571
7903
  enabledPackages
7572
7904
  });
7573
7905
  return this.remapDefaultActionPopupBlocks(
7574
- (0, import_default_action_popup.buildFlowSurfaceDefaultActionPopupBlocks)(actionNode == null ? void 0 : actionNode.use, fields),
7906
+ (0, import_default_action_popup.buildFlowSurfaceDefaultActionPopupBlocks)(this.resolveDefaultActionPopupSemanticUse(actionNode == null ? void 0 : actionNode.use), fields),
7575
7907
  keyMap,
7576
7908
  namespace
7577
7909
  );
@@ -7641,7 +7973,10 @@ class FlowSurfacesService {
7641
7973
  return normalizedTitle || void 0;
7642
7974
  }
7643
7975
  async syncDefaultActionPopupTabTitle(actionNode, popupTab, options) {
7644
- const popupTabTitle = this.normalizeOptionalPopupTitle(options.popupTabTitle) || (0, import_default_action_popup.resolveFlowSurfaceDefaultActionPopupTabTitle)(actionNode == null ? void 0 : actionNode.use, this.getActionButtonTitle(actionNode));
7976
+ const popupTabTitle = this.normalizeOptionalPopupTitle(options.popupTabTitle) || (0, import_default_action_popup.resolveFlowSurfaceDefaultActionPopupTabTitle)(
7977
+ this.resolveDefaultActionPopupSemanticUse(actionNode == null ? void 0 : actionNode.use),
7978
+ this.getActionButtonTitle(actionNode)
7979
+ );
7645
7980
  if (!(popupTab == null ? void 0 : popupTab.uid) || !popupTabTitle || this.resolvePopupTabTitle(popupTab) === popupTabTitle) {
7646
7981
  return;
7647
7982
  }
@@ -7667,7 +8002,10 @@ class FlowSurfacesService {
7667
8002
  });
7668
8003
  const popupPage = (0, import_service_utils.getSingleNodeSubModel)((_a = popupHost == null ? void 0 : popupHost.subModels) == null ? void 0 : _a.page);
7669
8004
  const popupTab = import_lodash.default.castArray(((_b = popupPage == null ? void 0 : popupPage.subModels) == null ? void 0 : _b.tabs) || [])[0];
7670
- const popupTabTitle = this.normalizeOptionalPopupTitle(options.popupTabTitle) || (0, import_default_action_popup.resolveFlowSurfaceDefaultActionPopupTabTitle)(actionNode == null ? void 0 : actionNode.use, this.getActionButtonTitle(actionNode));
8005
+ const popupTabTitle = this.normalizeOptionalPopupTitle(options.popupTabTitle) || (0, import_default_action_popup.resolveFlowSurfaceDefaultActionPopupTabTitle)(
8006
+ this.resolveDefaultActionPopupSemanticUse(actionNode == null ? void 0 : actionNode.use),
8007
+ this.getActionButtonTitle(actionNode)
8008
+ );
7671
8009
  if (!(popupTab == null ? void 0 : popupTab.uid) || !popupTabTitle || this.resolvePopupTabTitle(popupTab) === popupTabTitle) {
7672
8010
  return;
7673
8011
  }
@@ -7699,20 +8037,35 @@ class FlowSurfacesService {
7699
8037
  includeAsyncNode: true
7700
8038
  }) || fallbackActionNode;
7701
8039
  const openViewStep = (0, import_template_service_utils.findFlowTemplateOpenViewStep)(actionNode);
7702
- const openViewTitle = this.normalizeOptionalPopupTitle(options.openViewTitle) || (0, import_default_action_popup.resolveFlowSurfaceDefaultActionPopupTabTitle)(actionNode == null ? void 0 : actionNode.use, this.getActionButtonTitle(actionNode));
8040
+ const openViewTitle = this.normalizeOptionalPopupTitle(options.openViewTitle) || (0, import_default_action_popup.resolveFlowSurfaceDefaultActionPopupTabTitle)(
8041
+ this.resolveDefaultActionPopupSemanticUse(actionNode == null ? void 0 : actionNode.use),
8042
+ this.getActionButtonTitle(actionNode)
8043
+ );
7703
8044
  if (!openViewStep || !openViewTitle) {
7704
8045
  return;
7705
8046
  }
7706
8047
  const currentOpenView = import_lodash.default.isPlainObject(openViewStep.openView) ? openViewStep.openView : {};
7707
- if (this.normalizeOptionalPopupTitle(currentOpenView.title) === openViewTitle) {
8048
+ const popupProfile = await this.resolvePopupBlockProfile(
8049
+ actionNode.uid,
8050
+ null,
8051
+ actionNode,
8052
+ options.transaction
8053
+ ).catch(() => null);
8054
+ const filterTargetKey = (popupProfile == null ? void 0 : popupProfile.currentCollection) ? this.getCollectionFilterTargetKey(popupProfile.currentCollection) : null;
8055
+ const defaultFilterByTk = this.resolvePopupCurrentRecordResourceFilterByTk(popupProfile);
8056
+ const currentFilterByTk = import_lodash.default.isString(currentOpenView.filterByTk) ? currentOpenView.filterByTk.trim() : "";
8057
+ const preserveCustomFilterByTk = currentFilterByTk && currentFilterByTk !== "{{ctx.view.inputArgs.filterByTk}}" && currentFilterByTk !== (filterTargetKey ? `{{ctx.record.${filterTargetKey}}}` : "");
8058
+ const nextOpenView = (0, import_service_utils.buildDefinedPayload)({
8059
+ ...currentOpenView,
8060
+ title: openViewTitle,
8061
+ filterByTk: preserveCustomFilterByTk ? currentOpenView.filterByTk : defaultFilterByTk || currentOpenView.filterByTk
8062
+ });
8063
+ if (import_lodash.default.isEqual(nextOpenView, currentOpenView)) {
7708
8064
  return;
7709
8065
  }
7710
8066
  const nextStepParams = import_lodash.default.cloneDeep((actionNode == null ? void 0 : actionNode.stepParams) || {});
7711
8067
  const currentGroup = import_lodash.default.isPlainObject(nextStepParams[openViewStep.flowKey]) ? import_lodash.default.cloneDeep(nextStepParams[openViewStep.flowKey]) : {};
7712
- currentGroup[openViewStep.stepKey] = (0, import_service_utils.buildDefinedPayload)({
7713
- ...currentOpenView,
7714
- title: openViewTitle
7715
- });
8068
+ currentGroup[openViewStep.stepKey] = nextOpenView;
7716
8069
  nextStepParams[openViewStep.flowKey] = currentGroup;
7717
8070
  await this.repository.patch(
7718
8071
  {
@@ -7747,12 +8100,16 @@ class FlowSurfacesService {
7747
8100
  const nextStepParams = import_lodash.default.cloneDeep(actionNode.stepParams || {});
7748
8101
  const currentGroup = import_lodash.default.isPlainObject(nextStepParams[flowKey]) ? import_lodash.default.cloneDeep(nextStepParams[flowKey]) : {};
7749
8102
  const currentGroupOpenView = import_lodash.default.isPlainObject(currentGroup[stepKey]) ? currentGroup[stepKey] : {};
8103
+ const filterTargetKey = (popupProfile == null ? void 0 : popupProfile.currentCollection) ? this.getCollectionFilterTargetKey(popupProfile.currentCollection) : null;
8104
+ const currentFilterByTk = import_lodash.default.isString(currentGroupOpenView == null ? void 0 : currentGroupOpenView.filterByTk) ? currentGroupOpenView.filterByTk.trim() : "";
8105
+ const defaultFilterByTk = this.resolvePopupCurrentRecordResourceFilterByTk(popupProfile);
8106
+ const preserveCustomFilterByTk = currentFilterByTk && currentFilterByTk !== "{{ctx.view.inputArgs.filterByTk}}" && currentFilterByTk !== "{{ctx.record." + filterTargetKey + "}}";
7750
8107
  const nextOpenView = (0, import_service_utils.buildDefinedPayload)({
7751
8108
  ...currentGroupOpenView,
7752
8109
  dataSourceKey: (currentOpenView == null ? void 0 : currentOpenView.dataSourceKey) || (popupProfile == null ? void 0 : popupProfile.dataSourceKey) || "main",
7753
8110
  collectionName,
7754
8111
  associationName: (currentOpenView == null ? void 0 : currentOpenView.associationName) || (popupProfile == null ? void 0 : popupProfile.associationName),
7755
- filterByTk: (popupProfile == null ? void 0 : popupProfile.filterByTk) || "{{ctx.view.inputArgs.filterByTk}}",
8112
+ filterByTk: preserveCustomFilterByTk ? currentGroupOpenView.filterByTk : defaultFilterByTk || (popupProfile == null ? void 0 : popupProfile.filterByTk) || "{{ctx.view.inputArgs.filterByTk}}",
7756
8113
  sourceId: (currentOpenView == null ? void 0 : currentOpenView.sourceId) || (popupProfile == null ? void 0 : popupProfile.sourceId)
7757
8114
  });
7758
8115
  if (import_lodash.default.isEqual(nextOpenView, currentGroupOpenView)) {
@@ -7829,7 +8186,7 @@ class FlowSurfacesService {
7829
8186
  openViewActionName: actionName
7830
8187
  }
7831
8188
  );
7832
- if ((0, import_default_action_popup.isFlowSurfaceDefaultActionPopupUse)(actionNode == null ? void 0 : actionNode.use) && templateRef.mode === "copy") {
8189
+ if (this.isDefaultActionPopupUseForNode(actionNode) && templateRef.mode === "copy") {
7833
8190
  await this.syncDefaultActionPopupCopiedTemplateTabTitle(actionUid, actionNode, {
7834
8191
  ...options,
7835
8192
  popupTabTitle: templateOpenViewTitle
@@ -7861,6 +8218,12 @@ class FlowSurfacesService {
7861
8218
  openViewActionName: actionName
7862
8219
  }
7863
8220
  );
8221
+ if (this.isDefaultActionPopupUseForNode(actionNode)) {
8222
+ await this.syncDefaultActionPopupOpenViewTitle(actionUid, actionNode, {
8223
+ ...options,
8224
+ openViewTitle: templateOpenViewTitle
8225
+ });
8226
+ }
7864
8227
  this.registerInlinePopupTemplateAlias(actionName, popup, matchedTemplate, options.popupTemplateAliasSession);
7865
8228
  return;
7866
8229
  }
@@ -7949,6 +8312,15 @@ class FlowSurfacesService {
7949
8312
  current.use
7950
8313
  );
7951
8314
  });
8315
+ this.replaceExplicitPopupStepParamSubtreesForUpdateSettings(
8316
+ current,
8317
+ normalizedValues,
8318
+ nextPayload,
8319
+ options.replacePopupStepParamSubtrees === true
8320
+ );
8321
+ this.syncCalendarPopupPropsForUpdateSettings(current, normalizedValues, nextPayload);
8322
+ this.syncKanbanPopupPropsForUpdateSettings(current, normalizedValues, nextPayload);
8323
+ this.syncDefaultSortingForUpdateSettings(current, normalizedValues, nextPayload);
7952
8324
  this.syncFilterActionSettingsForUpdateSettings(current, normalizedValues, nextPayload);
7953
8325
  this.syncMirroredStepParamsForUpdateSettings(current, nextPayload);
7954
8326
  const updateActionAssignedValues = this.syncUpdateActionAssignedValuesForUpdateSettings(
@@ -7964,6 +8336,7 @@ class FlowSurfacesService {
7964
8336
  {
7965
8337
  transaction: options.transaction,
7966
8338
  popupTemplateHostUid: options.popupTemplateHostUid,
8339
+ popupTemplateHostUse: current == null ? void 0 : current.use,
7967
8340
  popupActionContext
7968
8341
  }
7969
8342
  );
@@ -8018,12 +8391,22 @@ class FlowSurfacesService {
8018
8391
  } else if (current.use === "ChartBlockModel" && !import_lodash.default.isUndefined((_b = nextPayload.stepParams) == null ? void 0 : _b.chartSettings)) {
8019
8392
  await this.syncChartDataBindingsForNode(effectiveNode, options.transaction);
8020
8393
  }
8021
- if (current.use === "CalendarBlockModel") {
8394
+ if (!options.skipHiddenPopupHostEnsure && current.use === "CalendarBlockModel") {
8022
8395
  await this.ensureCalendarBlockPopupHosts(effectiveNode, options.transaction);
8023
8396
  }
8024
- if (current.use === "KanbanBlockModel") {
8397
+ if (!options.skipHiddenPopupHostEnsure && current.use === "KanbanBlockModel") {
8025
8398
  await this.ensureKanbanBlockPopupHosts(effectiveNode, options.transaction);
8026
8399
  }
8400
+ if (!options.skipHiddenPopupHostEnsure && current.use === "KanbanCardItemModel") {
8401
+ const parentUid = String(current.parentId || "").trim() || (current.uid ? await this.locator.findParentUid(current.uid, options.transaction).catch(() => "") : "") || void 0;
8402
+ const parentNode = parentUid ? await this.repository.findModelById(parentUid, {
8403
+ transaction: options.transaction,
8404
+ includeAsyncNode: true
8405
+ }) : null;
8406
+ if ((parentNode == null ? void 0 : parentNode.use) === "KanbanBlockModel") {
8407
+ await this.ensureKanbanBlockPopupHosts(parentNode, options.transaction);
8408
+ }
8409
+ }
8027
8410
  await this.syncFlowTemplateUsagesForNodeTree(current.uid, options.transaction);
8028
8411
  if (import_approval.APPROVAL_SINGLETON_ACTION_USES.has(current.use || "")) {
8029
8412
  await this.syncApprovalRuntimeConfigForNode(current.uid, options.transaction);
@@ -8033,32 +8416,260 @@ class FlowSurfacesService {
8033
8416
  updated: Object.keys(import_lodash.default.omit(nextPayload, ["uid"]))
8034
8417
  };
8035
8418
  }
8036
- syncFilterActionSettingsForUpdateSettings(current, values, nextPayload) {
8037
- if ((current == null ? void 0 : current.use) !== "FilterActionModel") {
8419
+ syncCalendarPopupPropsForUpdateSettings(current, normalizedValues, nextPayload) {
8420
+ if ((current == null ? void 0 : current.use) !== "CalendarBlockModel" || !import_lodash.default.isPlainObject(normalizedValues == null ? void 0 : normalizedValues.props)) {
8038
8421
  return;
8039
8422
  }
8040
- const hasPropsFilterableFieldNames = import_lodash.default.isPlainObject(values == null ? void 0 : values.props) && Object.prototype.hasOwnProperty.call(values.props, "filterableFieldNames");
8041
- const hasPropsDefaultFilterValue = import_lodash.default.isPlainObject(values == null ? void 0 : values.props) && Object.prototype.hasOwnProperty.call(values.props, "defaultFilterValue");
8042
- const hasPropsFilterValue = import_lodash.default.isPlainObject(values == null ? void 0 : values.props) && Object.prototype.hasOwnProperty.call(values.props, "filterValue");
8043
- const hasStepFilterSettingsClear = import_lodash.default.isPlainObject(values == null ? void 0 : values.stepParams) && Object.prototype.hasOwnProperty.call(values.stepParams, "filterSettings") && (values.stepParams.filterSettings === null || import_lodash.default.isPlainObject(values.stepParams.filterSettings) && !Object.keys(values.stepParams.filterSettings).length);
8044
- const hasStepFilterableFieldNames = import_lodash.default.has(values, [
8045
- "stepParams",
8046
- "filterSettings",
8047
- "filterableFieldNames",
8048
- "filterableFieldNames"
8049
- ]);
8050
- const hasStepDefaultFilter = import_lodash.default.has(values, ["stepParams", "filterSettings", "defaultFilter", "defaultFilter"]);
8051
- if (!hasPropsFilterableFieldNames && !hasPropsDefaultFilterValue && !hasPropsFilterValue && !hasStepFilterSettingsClear && !hasStepFilterableFieldNames && !hasStepDefaultFilter) {
8423
+ let nextStepParams;
8424
+ for (const actionKey of import_hidden_popup_calendar.CALENDAR_POPUP_ACTION_KEYS) {
8425
+ const propKey = this.getCalendarPopupPropKey(actionKey);
8426
+ if (!Object.prototype.hasOwnProperty.call(normalizedValues.props, propKey)) {
8427
+ continue;
8428
+ }
8429
+ const value = normalizedValues.props[propKey];
8430
+ if (!import_lodash.default.has(normalizedValues, ["stepParams", "calendarSettings", propKey])) {
8431
+ nextStepParams = nextStepParams ?? import_lodash.default.cloneDeep(nextPayload.stepParams ?? (current == null ? void 0 : current.stepParams) ?? {});
8432
+ const currentSettings = import_lodash.default.get(nextStepParams, ["calendarSettings", propKey]);
8433
+ const popupSettings = import_lodash.default.isPlainObject(value) ? this.normalizeCalendarPopupSettings(
8434
+ actionKey,
8435
+ import_lodash.default.isPlainObject(currentSettings) ? { ...import_lodash.default.cloneDeep(currentSettings), ...import_lodash.default.cloneDeep(value) } : value
8436
+ ) : {};
8437
+ import_lodash.default.set(nextStepParams, ["calendarSettings", propKey], import_lodash.default.cloneDeep(popupSettings));
8438
+ }
8439
+ }
8440
+ this.stripPopupPropsFromPayload(nextPayload, import_hidden_popup_calendar.CALENDAR_POPUP_PROP_KEYS);
8441
+ if (nextStepParams) {
8442
+ nextPayload.stepParams = nextStepParams;
8443
+ }
8444
+ }
8445
+ replaceExplicitPopupStepParamSubtreesForUpdateSettings(current, normalizedValues, nextPayload, replacePopupStepParamSubtrees = false) {
8446
+ const replacePaths = UPDATE_SETTINGS_POPUP_STEP_PARAM_REPLACE_PATHS_BY_USE[(current == null ? void 0 : current.use) || ""];
8447
+ if (!(replacePaths == null ? void 0 : replacePaths.length) || !import_lodash.default.isPlainObject(normalizedValues == null ? void 0 : normalizedValues.stepParams)) {
8052
8448
  return;
8053
8449
  }
8054
- const nextProps = import_lodash.default.cloneDeep(nextPayload.props ?? (current == null ? void 0 : current.props) ?? {});
8055
- const nextStepParams = import_lodash.default.cloneDeep(nextPayload.stepParams ?? (current == null ? void 0 : current.stepParams) ?? {});
8056
- if (hasStepFilterSettingsClear) {
8057
- if (hasPropsFilterableFieldNames || hasPropsDefaultFilterValue || hasPropsFilterValue) {
8058
- (0, import_errors.throwBadRequest)(
8059
- "flowSurfaces updateSettings filter action cannot combine 'stepParams.filterSettings' clear with filter props writes"
8060
- );
8061
- }
8450
+ let nextStepParams;
8451
+ for (const path of replacePaths) {
8452
+ const inputPath = ["stepParams", ...path];
8453
+ if (!import_lodash.default.has(normalizedValues, inputPath)) {
8454
+ continue;
8455
+ }
8456
+ nextStepParams = nextStepParams ?? import_lodash.default.cloneDeep(nextPayload.stepParams ?? (current == null ? void 0 : current.stepParams) ?? {});
8457
+ const value = import_lodash.default.get(normalizedValues, inputPath);
8458
+ const currentValue = import_lodash.default.get(nextStepParams, path);
8459
+ import_lodash.default.set(
8460
+ nextStepParams,
8461
+ path,
8462
+ this.normalizePopupStepParamReplacementForUpdateSettings(
8463
+ current,
8464
+ path,
8465
+ value,
8466
+ currentValue,
8467
+ replacePopupStepParamSubtrees
8468
+ )
8469
+ );
8470
+ }
8471
+ if (nextStepParams) {
8472
+ nextPayload.stepParams = nextStepParams;
8473
+ }
8474
+ }
8475
+ normalizePopupStepParamReplacementForUpdateSettings(current, path, value, currentValue, replacePopupStepParamSubtrees = false) {
8476
+ if (!import_lodash.default.isPlainObject(value)) {
8477
+ return {};
8478
+ }
8479
+ const mergedValue = !replacePopupStepParamSubtrees && import_lodash.default.isPlainObject(currentValue) ? { ...import_lodash.default.cloneDeep(currentValue), ...import_lodash.default.cloneDeep(value) } : value;
8480
+ if ((current == null ? void 0 : current.use) === "CalendarBlockModel") {
8481
+ const actionKey = path[1] === "quickCreatePopupSettings" ? "quickCreateAction" : "eventViewAction";
8482
+ return this.normalizeCalendarPopupSettings(actionKey, mergedValue);
8483
+ }
8484
+ if ((current == null ? void 0 : current.use) === "KanbanBlockModel") {
8485
+ return this.normalizeKanbanPopupSettings("quickCreateAction", mergedValue, current.uid);
8486
+ }
8487
+ if ((current == null ? void 0 : current.use) === "KanbanCardItemModel") {
8488
+ const parentUid = String((current == null ? void 0 : current.parentId) || "").trim() || void 0;
8489
+ return this.normalizeKanbanPopupSettings("cardViewAction", mergedValue, parentUid);
8490
+ }
8491
+ return import_lodash.default.cloneDeep(mergedValue);
8492
+ }
8493
+ stripPopupPropsFromPayload(nextPayload, keys) {
8494
+ if (!import_lodash.default.isPlainObject(nextPayload.props)) {
8495
+ return;
8496
+ }
8497
+ for (const key of keys) {
8498
+ if (Object.prototype.hasOwnProperty.call(nextPayload.props, key)) {
8499
+ delete nextPayload.props[key];
8500
+ }
8501
+ }
8502
+ }
8503
+ syncDefaultSortingForUpdateSettings(current, normalizedValues, nextPayload) {
8504
+ if (!import_lodash.default.isPlainObject(normalizedValues == null ? void 0 : normalizedValues.stepParams)) {
8505
+ return;
8506
+ }
8507
+ const currentUse = current == null ? void 0 : current.use;
8508
+ const nextStepParams = import_lodash.default.cloneDeep(nextPayload.stepParams ?? (current == null ? void 0 : current.stepParams) ?? {});
8509
+ let changed = false;
8510
+ const normalizeGroupSort = (groupPath, context) => {
8511
+ const currentGroup = import_lodash.default.get(nextStepParams, groupPath);
8512
+ if (!import_lodash.default.isPlainObject(currentGroup)) {
8513
+ return;
8514
+ }
8515
+ if (!import_lodash.default.has(normalizedValues.stepParams, [...groupPath, "defaultSorting", "sort"])) {
8516
+ return;
8517
+ }
8518
+ const defaultSorting = import_lodash.default.get(currentGroup, ["defaultSorting", "sort"]);
8519
+ const normalizedSort = (0, import_public_compatibility.normalizeFlowSurfaceDefaultSorting)(defaultSorting, context);
8520
+ if (import_lodash.default.isEqual(defaultSorting, normalizedSort)) {
8521
+ return;
8522
+ }
8523
+ import_lodash.default.set(nextStepParams, [...groupPath, "defaultSorting", "sort"], normalizedSort);
8524
+ changed = true;
8525
+ };
8526
+ if (currentUse === "TableBlockModel" && Object.prototype.hasOwnProperty.call(normalizedValues.stepParams, "tableSettings")) {
8527
+ normalizeGroupSort(["tableSettings"], "tableSettings.defaultSorting.sort");
8528
+ }
8529
+ if (currentUse === "DetailsBlockModel" && Object.prototype.hasOwnProperty.call(normalizedValues.stepParams, "detailsSettings")) {
8530
+ normalizeGroupSort(["detailsSettings"], "detailsSettings.defaultSorting.sort");
8531
+ }
8532
+ if (currentUse === "ListBlockModel" && Object.prototype.hasOwnProperty.call(normalizedValues.stepParams, "listSettings")) {
8533
+ normalizeGroupSort(["listSettings"], "listSettings.defaultSorting.sort");
8534
+ }
8535
+ if (currentUse === "GridCardBlockModel" && Object.prototype.hasOwnProperty.call(normalizedValues.stepParams, "GridCardSettings")) {
8536
+ normalizeGroupSort(["GridCardSettings"], "GridCardSettings.defaultSorting.sort");
8537
+ }
8538
+ if (currentUse === "TreeBlockModel" && Object.prototype.hasOwnProperty.call(normalizedValues.stepParams, "treeSettings")) {
8539
+ normalizeGroupSort(["treeSettings"], "treeSettings.defaultSorting.sort");
8540
+ }
8541
+ if (currentUse === "KanbanBlockModel" && Object.prototype.hasOwnProperty.call(normalizedValues.stepParams, "kanbanSettings")) {
8542
+ normalizeGroupSort(["kanbanSettings"], "kanbanSettings.defaultSorting.sort");
8543
+ }
8544
+ if (currentUse === "MapBlockModel" && Object.prototype.hasOwnProperty.call(normalizedValues.stepParams, "createMapBlock")) {
8545
+ const createMapBlock = import_lodash.default.get(nextStepParams, ["createMapBlock"]);
8546
+ if (import_lodash.default.isPlainObject(createMapBlock)) {
8547
+ if (!import_lodash.default.has(normalizedValues.stepParams, ["createMapBlock", "lineSort", "sort"])) {
8548
+ return;
8549
+ }
8550
+ const defaultSorting = import_lodash.default.get(createMapBlock, ["lineSort", "sort"]);
8551
+ const normalizedSort = (0, import_public_compatibility.normalizeFlowSurfaceEmptySortingAsDefault)(
8552
+ defaultSorting,
8553
+ "createMapBlock.lineSort.sort"
8554
+ );
8555
+ if (!import_lodash.default.isEqual(defaultSorting, normalizedSort)) {
8556
+ import_lodash.default.set(nextStepParams, ["createMapBlock", "lineSort", "sort"], normalizedSort);
8557
+ changed = true;
8558
+ }
8559
+ }
8560
+ }
8561
+ if (changed) {
8562
+ nextPayload.stepParams = nextStepParams;
8563
+ }
8564
+ }
8565
+ syncKanbanPopupPropsForUpdateSettings(current, normalizedValues, nextPayload) {
8566
+ if (!import_lodash.default.isPlainObject(normalizedValues == null ? void 0 : normalizedValues.props)) {
8567
+ return;
8568
+ }
8569
+ if ((current == null ? void 0 : current.use) === "KanbanBlockModel") {
8570
+ const propToPopupKey = {
8571
+ popupMode: "mode",
8572
+ popupSize: "size",
8573
+ popupTemplateUid: "popupTemplateUid",
8574
+ popupPageModelClass: "pageModelClass",
8575
+ popupTargetUid: "uid"
8576
+ };
8577
+ const writtenProps = Object.keys(propToPopupKey).filter(
8578
+ (propKey) => Object.prototype.hasOwnProperty.call(normalizedValues.props, propKey)
8579
+ );
8580
+ const hasLegacyPopupSettings = Object.prototype.hasOwnProperty.call(
8581
+ normalizedValues.props,
8582
+ "quickCreatePopupSettings"
8583
+ );
8584
+ if (!writtenProps.length && !hasLegacyPopupSettings) {
8585
+ return;
8586
+ }
8587
+ if (import_lodash.default.has(normalizedValues, ["stepParams", "kanbanSettings", "popup"])) {
8588
+ this.stripPopupPropsFromPayload(nextPayload, import_hidden_popup_kanban.KANBAN_BLOCK_POPUP_PROP_KEYS);
8589
+ return;
8590
+ }
8591
+ const nextStepParams = import_lodash.default.cloneDeep(nextPayload.stepParams ?? (current == null ? void 0 : current.stepParams) ?? {});
8592
+ const currentPopupSettings = import_lodash.default.get(nextStepParams, ["kanbanSettings", "popup"]);
8593
+ const popupSettings = import_lodash.default.cloneDeep(import_lodash.default.isPlainObject(currentPopupSettings) ? currentPopupSettings : {});
8594
+ if (import_lodash.default.isPlainObject(normalizedValues.props.quickCreatePopupSettings)) {
8595
+ Object.assign(popupSettings, import_lodash.default.cloneDeep(normalizedValues.props.quickCreatePopupSettings));
8596
+ }
8597
+ for (const propKey of writtenProps) {
8598
+ popupSettings[propToPopupKey[propKey]] = normalizedValues.props[propKey];
8599
+ }
8600
+ import_lodash.default.set(
8601
+ nextStepParams,
8602
+ ["kanbanSettings", "popup"],
8603
+ this.normalizeKanbanPopupSettings("quickCreateAction", popupSettings, current.uid)
8604
+ );
8605
+ nextPayload.stepParams = nextStepParams;
8606
+ this.stripPopupPropsFromPayload(nextPayload, import_hidden_popup_kanban.KANBAN_BLOCK_POPUP_PROP_KEYS);
8607
+ return;
8608
+ }
8609
+ if ((current == null ? void 0 : current.use) === "KanbanCardItemModel") {
8610
+ const propToPopupKey = {
8611
+ openMode: "mode",
8612
+ popupSize: "size",
8613
+ popupTemplateUid: "popupTemplateUid",
8614
+ pageModelClass: "pageModelClass",
8615
+ popupTargetUid: "uid"
8616
+ };
8617
+ const writtenProps = Object.keys(propToPopupKey).filter(
8618
+ (propKey) => Object.prototype.hasOwnProperty.call(normalizedValues.props, propKey)
8619
+ );
8620
+ const hasLegacyPopupSettings = Object.prototype.hasOwnProperty.call(normalizedValues.props, "cardPopupSettings");
8621
+ if (!writtenProps.length && !hasLegacyPopupSettings) {
8622
+ return;
8623
+ }
8624
+ if (import_lodash.default.has(normalizedValues, ["stepParams", "cardSettings", "popup"])) {
8625
+ this.stripPopupPropsFromPayload(nextPayload, import_hidden_popup_kanban.KANBAN_CARD_POPUP_PROP_KEYS);
8626
+ return;
8627
+ }
8628
+ const parentUid = String((current == null ? void 0 : current.parentId) || "").trim() || void 0;
8629
+ const nextStepParams = import_lodash.default.cloneDeep(nextPayload.stepParams ?? (current == null ? void 0 : current.stepParams) ?? {});
8630
+ const currentPopupSettings = import_lodash.default.get(nextStepParams, ["cardSettings", "popup"]);
8631
+ const popupSettings = import_lodash.default.cloneDeep(import_lodash.default.isPlainObject(currentPopupSettings) ? currentPopupSettings : {});
8632
+ if (import_lodash.default.isPlainObject(normalizedValues.props.cardPopupSettings)) {
8633
+ Object.assign(popupSettings, import_lodash.default.cloneDeep(normalizedValues.props.cardPopupSettings));
8634
+ }
8635
+ for (const propKey of writtenProps) {
8636
+ popupSettings[propToPopupKey[propKey]] = normalizedValues.props[propKey];
8637
+ }
8638
+ import_lodash.default.set(
8639
+ nextStepParams,
8640
+ ["cardSettings", "popup"],
8641
+ this.normalizeKanbanPopupSettings("cardViewAction", popupSettings, parentUid)
8642
+ );
8643
+ nextPayload.stepParams = nextStepParams;
8644
+ this.stripPopupPropsFromPayload(nextPayload, import_hidden_popup_kanban.KANBAN_CARD_POPUP_PROP_KEYS);
8645
+ }
8646
+ }
8647
+ syncFilterActionSettingsForUpdateSettings(current, values, nextPayload) {
8648
+ if ((current == null ? void 0 : current.use) !== "FilterActionModel") {
8649
+ return;
8650
+ }
8651
+ const hasPropsFilterableFieldNames = import_lodash.default.isPlainObject(values == null ? void 0 : values.props) && Object.prototype.hasOwnProperty.call(values.props, "filterableFieldNames");
8652
+ const hasPropsDefaultFilterValue = import_lodash.default.isPlainObject(values == null ? void 0 : values.props) && Object.prototype.hasOwnProperty.call(values.props, "defaultFilterValue");
8653
+ const hasPropsFilterValue = import_lodash.default.isPlainObject(values == null ? void 0 : values.props) && Object.prototype.hasOwnProperty.call(values.props, "filterValue");
8654
+ const hasStepFilterSettingsClear = import_lodash.default.isPlainObject(values == null ? void 0 : values.stepParams) && Object.prototype.hasOwnProperty.call(values.stepParams, "filterSettings") && (values.stepParams.filterSettings === null || import_lodash.default.isPlainObject(values.stepParams.filterSettings) && !Object.keys(values.stepParams.filterSettings).length);
8655
+ const hasStepFilterableFieldNames = import_lodash.default.has(values, [
8656
+ "stepParams",
8657
+ "filterSettings",
8658
+ "filterableFieldNames",
8659
+ "filterableFieldNames"
8660
+ ]);
8661
+ const hasStepDefaultFilter = import_lodash.default.has(values, ["stepParams", "filterSettings", "defaultFilter", "defaultFilter"]);
8662
+ if (!hasPropsFilterableFieldNames && !hasPropsDefaultFilterValue && !hasPropsFilterValue && !hasStepFilterSettingsClear && !hasStepFilterableFieldNames && !hasStepDefaultFilter) {
8663
+ return;
8664
+ }
8665
+ const nextProps = import_lodash.default.cloneDeep(nextPayload.props ?? (current == null ? void 0 : current.props) ?? {});
8666
+ const nextStepParams = import_lodash.default.cloneDeep(nextPayload.stepParams ?? (current == null ? void 0 : current.stepParams) ?? {});
8667
+ if (hasStepFilterSettingsClear) {
8668
+ if (hasPropsFilterableFieldNames || hasPropsDefaultFilterValue || hasPropsFilterValue) {
8669
+ (0, import_errors.throwBadRequest)(
8670
+ "flowSurfaces updateSettings filter action cannot combine 'stepParams.filterSettings' clear with filter props writes"
8671
+ );
8672
+ }
8062
8673
  import_lodash.default.unset(nextProps, ["filterableFieldNames"]);
8063
8674
  import_lodash.default.unset(nextProps, ["defaultFilterValue"]);
8064
8675
  import_lodash.default.unset(nextProps, ["filterValue"]);
@@ -8124,7 +8735,7 @@ class FlowSurfacesService {
8124
8735
  continue;
8125
8736
  }
8126
8737
  nextStepParams = nextStepParams ?? import_lodash.default.cloneDeep(nextPayload.stepParams ?? (current == null ? void 0 : current.stepParams) ?? {});
8127
- if (import_lodash.default.has(nextStepParams, mirror.stepParamsPath)) {
8738
+ if (import_lodash.default.has(nextStepParams, mirror.stepParamsPath) && (!import_lodash.default.isEqual(import_lodash.default.get(current == null ? void 0 : current.stepParams, mirror.stepParamsPath), import_lodash.default.get(current == null ? void 0 : current[mirror.domain], mirror.key)) || !import_lodash.default.isEqual(import_lodash.default.get(nextStepParams, mirror.stepParamsPath), import_lodash.default.get(current == null ? void 0 : current.stepParams, mirror.stepParamsPath)))) {
8128
8739
  continue;
8129
8740
  }
8130
8741
  import_lodash.default.set(nextStepParams, mirror.stepParamsPath, value);
@@ -8400,11 +9011,15 @@ class FlowSurfacesService {
8400
9011
  }
8401
9012
  const requestedOpenView = import_lodash.default.get(nextPayload, openViewPath);
8402
9013
  const currentOpenView = import_lodash.default.get(current, openViewPath);
8403
- const nextOpenView = await this.normalizeOpenView(actionName, requestedOpenView, {
9014
+ let nextOpenView = await this.normalizeOpenView(actionName, requestedOpenView, {
8404
9015
  transaction: options.transaction,
8405
9016
  popupTemplateHostUid,
9017
+ popupTemplateHostUse: options.popupTemplateHostUse || (current == null ? void 0 : current.use),
8406
9018
  popupActionContext: options.popupActionContext
8407
9019
  });
9020
+ if (flowKey === "popupSettings" && String((current == null ? void 0 : current.use) || "").trim() === "AddChildActionModel" && import_lodash.default.isPlainObject(nextOpenView)) {
9021
+ nextOpenView = await this.normalizeAddChildOpenViewForAction(current, nextOpenView, options.transaction);
9022
+ }
8408
9023
  if (this.isTryTemplateOnlyOpenViewRequest(requestedOpenView) && import_lodash.default.isPlainObject(nextOpenView) && !Object.keys(nextOpenView).length) {
8409
9024
  this.unsetPayloadPathAndPruneEmptyParents(nextPayload, openViewPath);
8410
9025
  if (import_lodash.default.isEqual(nextPayload.stepParams, current.stepParams)) {
@@ -8957,7 +9572,7 @@ class FlowSurfacesService {
8957
9572
  if (!normalizedUid) {
8958
9573
  return null;
8959
9574
  }
8960
- for (const actionKey of CALENDAR_POPUP_ACTION_KEYS) {
9575
+ for (const actionKey of import_hidden_popup_calendar.CALENDAR_POPUP_ACTION_KEYS) {
8961
9576
  const suffix = `-${actionKey}`;
8962
9577
  if (normalizedUid.endsWith(suffix) && normalizedUid.length > suffix.length) {
8963
9578
  return {
@@ -8973,8 +9588,8 @@ class FlowSurfacesService {
8973
9588
  if (!normalizedUid) {
8974
9589
  return null;
8975
9590
  }
8976
- for (const actionKey of KANBAN_POPUP_ACTION_KEYS) {
8977
- const suffix = KANBAN_POPUP_ACTION_UID_SUFFIX_BY_KEY[actionKey];
9591
+ for (const actionKey of import_hidden_popup_kanban.KANBAN_POPUP_ACTION_KEYS) {
9592
+ const suffix = import_hidden_popup_kanban.KANBAN_POPUP_ACTION_UID_SUFFIX_BY_KEY[actionKey];
8978
9593
  if (normalizedUid.endsWith(suffix) && normalizedUid.length > suffix.length) {
8979
9594
  return {
8980
9595
  kanbanUid: normalizedUid.slice(0, -suffix.length),
@@ -9016,6 +9631,20 @@ class FlowSurfacesService {
9016
9631
  await this.ensureKanbanBlockPopupHosts(kanbanNode, options.transaction);
9017
9632
  }
9018
9633
  }
9634
+ const repairedTarget = await this.repository.findModelById(writeTarget.uid, {
9635
+ transaction: options.transaction,
9636
+ includeAsyncNode: true
9637
+ });
9638
+ if (repairedTarget == null ? void 0 : repairedTarget.uid) {
9639
+ return writeTarget;
9640
+ }
9641
+ const ownerNode = await this.repository.findModelById((parsedCalendarPopupTarget == null ? void 0 : parsedCalendarPopupTarget.calendarUid) || (parsedKanbanPopupTarget == null ? void 0 : parsedKanbanPopupTarget.kanbanUid), {
9642
+ transaction: options.transaction,
9643
+ includeAsyncNode: true
9644
+ }).catch(() => null);
9645
+ if (ownerNode == null ? void 0 : ownerNode.uid) {
9646
+ await this.ensureHiddenPopupBlockHostsInManagedPopupTarget(ownerNode, options.transaction);
9647
+ }
9019
9648
  return writeTarget;
9020
9649
  }
9021
9650
  normalizeRootUidValue(actionName, values) {
@@ -9424,6 +10053,19 @@ class FlowSurfacesService {
9424
10053
  isAddChildCatalogItem(item) {
9425
10054
  return (item == null ? void 0 : item.key) === "addChild" || (item == null ? void 0 : item.use) === "AddChildActionModel";
9426
10055
  }
10056
+ resolveTreeChildrenField(collection) {
10057
+ return (0, import_service_helpers.getCollectionFields)(collection).find(
10058
+ (field) => {
10059
+ var _a;
10060
+ return (field == null ? void 0 : field.treeChildren) === true || ((_a = field == null ? void 0 : field.options) == null ? void 0 : _a.treeChildren) === true;
10061
+ }
10062
+ );
10063
+ }
10064
+ resolveTreeChildrenAssociationName(collection) {
10065
+ const collectionName = (0, import_service_helpers.getCollectionName)(collection);
10066
+ const childrenFieldName = (0, import_service_helpers.getFieldName)(this.resolveTreeChildrenField(collection));
10067
+ return collectionName && childrenFieldName ? `${collectionName}.${childrenFieldName}` : void 0;
10068
+ }
9427
10069
  isTreeCollection(collection) {
9428
10070
  var _a;
9429
10071
  return (collection == null ? void 0 : collection.template) === "tree" || ((_a = collection == null ? void 0 : collection.options) == null ? void 0 : _a.template) === "tree" || (collection == null ? void 0 : collection.tree) === true;
@@ -9445,11 +10087,49 @@ class FlowSurfacesService {
9445
10087
  includeAsyncNode: true
9446
10088
  }) || node;
9447
10089
  }
9448
- async resolveOwnerCollectionForAddChild(node, transaction) {
10090
+ async resolveAddChildOwnerResourceContext(node, transaction) {
9449
10091
  var _a;
9450
10092
  const ownerNode = await this.resolveAddChildOwnerNode(node, transaction);
9451
10093
  const resourceInit = import_lodash.default.get(ownerNode, ["stepParams", "resourceSettings", "init"]) || ((ownerNode == null ? void 0 : ownerNode.uid) ? (_a = await this.locator.resolveCollectionContext(ownerNode.uid, transaction).catch(() => null)) == null ? void 0 : _a.resourceInit : null);
9452
- return this.resolveCollectionFromInit(resourceInit);
10094
+ return {
10095
+ ownerNode,
10096
+ resourceInit,
10097
+ collection: this.resolveCollectionFromInit(resourceInit)
10098
+ };
10099
+ }
10100
+ async resolveOwnerCollectionForAddChild(node, transaction) {
10101
+ return (await this.resolveAddChildOwnerResourceContext(node, transaction)).collection;
10102
+ }
10103
+ async resolveAddChildResourceInitForOwnerNode(node, transaction) {
10104
+ const { resourceInit, collection } = await this.resolveAddChildOwnerResourceContext(node, transaction);
10105
+ const associationName = this.resolveTreeChildrenAssociationName(collection);
10106
+ if (!associationName) {
10107
+ (0, import_errors.throwBadRequest)(
10108
+ `flowSurfaces addRecordAction type 'addChild' cannot resolve tree children association for '${String((resourceInit == null ? void 0 : resourceInit.collectionName) || "").trim() || "unknown"}'`
10109
+ );
10110
+ }
10111
+ return (0, import_service_utils.buildDefinedPayload)({
10112
+ dataSourceKey: (resourceInit == null ? void 0 : resourceInit.dataSourceKey) || "main",
10113
+ collectionName: resourceInit == null ? void 0 : resourceInit.collectionName,
10114
+ associationName
10115
+ });
10116
+ }
10117
+ async normalizeAddChildOpenViewForAction(actionNode, openView, transaction) {
10118
+ if (!import_lodash.default.isPlainObject(openView)) {
10119
+ return openView;
10120
+ }
10121
+ const parentUid = String((actionNode == null ? void 0 : actionNode.parentId) || "").trim() || ((actionNode == null ? void 0 : actionNode.uid) ? await this.locator.findParentUid(actionNode.uid, transaction).catch(() => "") : "");
10122
+ const parentNode = parentUid ? await this.repository.findModelById(parentUid, {
10123
+ transaction,
10124
+ includeAsyncNode: true
10125
+ }) : null;
10126
+ const addChildResourceInit = await this.resolveAddChildResourceInitForOwnerNode(parentNode, transaction);
10127
+ return (0, import_service_utils.buildDefinedPayload)({
10128
+ ...import_lodash.default.omit(import_lodash.default.cloneDeep(openView), ["sourceId"]),
10129
+ dataSourceKey: addChildResourceInit.dataSourceKey,
10130
+ collectionName: addChildResourceInit.collectionName,
10131
+ associationName: addChildResourceInit.associationName
10132
+ });
9453
10133
  }
9454
10134
  async canUseAddChildOnOwnerNode(node, transaction) {
9455
10135
  const ownerNode = await this.resolveAddChildOwnerNode(node, transaction);
@@ -9457,15 +10137,26 @@ class FlowSurfacesService {
9457
10137
  return false;
9458
10138
  }
9459
10139
  const collection = await this.resolveOwnerCollectionForAddChild(ownerNode, transaction);
9460
- return this.isTreeCollection(collection);
10140
+ return this.isTreeCollection(collection) && !!this.resolveTreeChildrenAssociationName(collection);
9461
10141
  }
9462
10142
  async assertAddChildSupportedForOwnerNode(node, context, transaction) {
9463
- if (await this.canUseAddChildOnOwnerNode(node, transaction)) {
9464
- return;
10143
+ const ownerNode = await this.resolveAddChildOwnerNode(node, transaction);
10144
+ if ((ownerNode == null ? void 0 : ownerNode.use) !== "TableBlockModel" || !this.isTreeTableEnabled(ownerNode)) {
10145
+ (0, import_errors.throwBadRequest)(
10146
+ `flowSurfaces ${context} type 'addChild' only supports tables bound to tree collections with tree table enabled`
10147
+ );
10148
+ }
10149
+ const collection = await this.resolveOwnerCollectionForAddChild(ownerNode, transaction);
10150
+ if (!this.isTreeCollection(collection)) {
10151
+ (0, import_errors.throwBadRequest)(
10152
+ `flowSurfaces ${context} type 'addChild' only supports tables bound to tree collections with tree table enabled`
10153
+ );
10154
+ }
10155
+ if (!this.resolveTreeChildrenAssociationName(collection)) {
10156
+ (0, import_errors.throwBadRequest)(
10157
+ `flowSurfaces ${context} type 'addChild' tree collection '${(0, import_service_helpers.getCollectionName)(collection) || "unknown"}' does not expose a tree children field`
10158
+ );
9465
10159
  }
9466
- (0, import_errors.throwBadRequest)(
9467
- `flowSurfaces ${context} type 'addChild' only supports tables bound to tree collections with tree table enabled`
9468
- );
9469
10160
  }
9470
10161
  async filterTargetRecordActions(items, node, transaction) {
9471
10162
  if (!items.some((item) => this.isAddChildCatalogItem(item))) {
@@ -10348,7 +11039,11 @@ class FlowSurfacesService {
10348
11039
  ...(0, import_service_utils.hasOwnDefined)(changes, "density") ? { tableDensity: { size: changes.density } } : {},
10349
11040
  ...(0, import_service_utils.hasOwnDefined)(changes, "quickEdit") ? { quickEdit: { editable: changes.quickEdit } } : {},
10350
11041
  ...(0, import_service_utils.hasOwnDefined)(changes, "showRowNumbers") ? { showRowNumbers: { showIndex: changes.showRowNumbers } } : {},
10351
- ...(0, import_service_utils.hasOwnDefined)(changes, "sorting") ? { defaultSorting: { sort: changes.sorting } } : {},
11042
+ ...(0, import_service_utils.hasOwnDefined)(changes, "sorting") ? {
11043
+ defaultSorting: {
11044
+ sort: this.normalizeBlockSortingInput(changes.sorting, "tableSettings.sorting")
11045
+ }
11046
+ } : {},
10352
11047
  ...(0, import_service_utils.hasOwnDefined)(changes, "dataScope") ? { dataScope: { filter: changes.dataScope } } : {},
10353
11048
  ...(0, import_service_utils.hasOwnDefined)(changes, "treeTable") ? { treeTable: { treeTable: changes.treeTable } } : {},
10354
11049
  ...(0, import_service_utils.hasOwnDefined)(changes, "defaultExpandAllRows") ? { defaultExpandAllRows: { defaultExpandAllRows: changes.defaultExpandAllRows } } : {},
@@ -10391,20 +11086,44 @@ class FlowSurfacesService {
10391
11086
  changes,
10392
11087
  resetInvalidExisting: resourceChanged
10393
11088
  });
10394
- const quickCreatePopupSettings = Object.prototype.hasOwnProperty.call(changes, "quickCreatePopup") ? await this.normalizeCalendarPopupConfigureValue({
11089
+ const hasQuickCreatePopupChange = Object.prototype.hasOwnProperty.call(changes, "quickCreatePopup");
11090
+ const hasEventPopupChange = Object.prototype.hasOwnProperty.call(changes, "eventPopup");
11091
+ const quickCreatePopupSettingsInput = hasQuickCreatePopupChange ? await this.normalizeCalendarPopupConfigureValue({
10395
11092
  actionName: "configure calendar quickCreatePopup",
10396
11093
  blockUid: current.uid,
10397
11094
  actionKey: "quickCreateAction",
10398
11095
  value: changes.quickCreatePopup,
10399
11096
  transaction: options.transaction
10400
11097
  }) : void 0;
10401
- const eventPopupSettings = Object.prototype.hasOwnProperty.call(changes, "eventPopup") ? await this.normalizeCalendarPopupConfigureValue({
11098
+ const eventPopupSettingsInput = hasEventPopupChange ? await this.normalizeCalendarPopupConfigureValue({
10402
11099
  actionName: "configure calendar eventPopup",
10403
11100
  blockUid: current.uid,
10404
11101
  actionKey: "eventViewAction",
10405
11102
  value: changes.eventPopup,
10406
11103
  transaction: options.transaction
10407
11104
  }) : void 0;
11105
+ const currentQuickCreatePopupSettings = this.getCalendarPopupStoredSettings(current, "quickCreateAction");
11106
+ const currentEventPopupSettings = this.getCalendarPopupStoredSettings(current, "eventViewAction");
11107
+ const quickCreatePopupSettingsBase = resourceChanged ? this.stripCalendarPopupTargetSettingsForResourceChange("quickCreateAction", currentQuickCreatePopupSettings) : currentQuickCreatePopupSettings;
11108
+ const eventPopupSettingsBase = resourceChanged ? this.stripCalendarPopupTargetSettingsForResourceChange("eventViewAction", currentEventPopupSettings) : currentEventPopupSettings;
11109
+ const quickCreatePopupSettings = hasQuickCreatePopupChange ? import_lodash.default.isNull(changes.quickCreatePopup) ? quickCreatePopupSettingsInput || {} : this.mergeCalendarPopupSettings(
11110
+ "quickCreateAction",
11111
+ quickCreatePopupSettingsBase,
11112
+ quickCreatePopupSettingsInput
11113
+ ) : void 0;
11114
+ const eventPopupSettings = hasEventPopupChange ? import_lodash.default.isNull(changes.eventPopup) ? eventPopupSettingsInput || {} : this.mergeCalendarPopupSettings("eventViewAction", eventPopupSettingsBase, eventPopupSettingsInput) : void 0;
11115
+ const previousQuickCreateOpenView = this.buildCalendarPopupOpenView({
11116
+ blockNode: current,
11117
+ actionKey: "quickCreateAction",
11118
+ resourceInit: currentResourceInit,
11119
+ popupSettings: currentQuickCreatePopupSettings
11120
+ });
11121
+ const previousEventOpenView = this.buildCalendarPopupOpenView({
11122
+ blockNode: current,
11123
+ actionKey: "eventViewAction",
11124
+ resourceInit: currentResourceInit,
11125
+ popupSettings: currentEventPopupSettings
11126
+ });
10408
11127
  const result = await this.updateSettings(
10409
11128
  {
10410
11129
  target,
@@ -10413,9 +11132,7 @@ class FlowSurfacesService {
10413
11132
  defaultView,
10414
11133
  enableQuickCreateEvent: quickCreateEvent,
10415
11134
  showLunar,
10416
- weekStart,
10417
- quickCreatePopupSettings,
10418
- eventPopupSettings
11135
+ weekStart
10419
11136
  }),
10420
11137
  stepParams: {
10421
11138
  ...cardSettings ? { cardSettings } : {},
@@ -10434,7 +11151,10 @@ class FlowSurfacesService {
10434
11151
  "showLunar",
10435
11152
  "weekStart",
10436
11153
  "dataScope",
10437
- "linkageRules"
11154
+ "linkageRules",
11155
+ "quickCreatePopup",
11156
+ "eventPopup",
11157
+ "resource"
10438
11158
  ]) ? {
10439
11159
  calendarSettings: (0, import_service_utils.buildDefinedPayload)({
10440
11160
  ...(0, import_service_utils.hasOwnDefined)(changes, "titleField") ? { titleField: { titleField: fieldNames.title } } : {},
@@ -10446,18 +11166,37 @@ class FlowSurfacesService {
10446
11166
  ...(0, import_service_utils.hasOwnDefined)(changes, "showLunar") ? { showLunar: { showLunar: showLunar === true } } : {},
10447
11167
  ...(0, import_service_utils.hasOwnDefined)(changes, "weekStart") ? { weekStart: { weekStart } } : {},
10448
11168
  ...(0, import_service_utils.hasOwnDefined)(changes, "dataScope") ? { dataScope: { filter: changes.dataScope } } : {},
10449
- ...(0, import_service_utils.hasOwnDefined)(changes, "linkageRules") ? { linkageRules: { value: changes.linkageRules } } : {}
11169
+ ...(0, import_service_utils.hasOwnDefined)(changes, "linkageRules") ? { linkageRules: { value: changes.linkageRules } } : {},
11170
+ ...hasQuickCreatePopupChange ? { quickCreatePopupSettings: quickCreatePopupSettings || {} } : resourceChanged ? { quickCreatePopupSettings: quickCreatePopupSettingsBase } : {},
11171
+ ...hasEventPopupChange ? { eventPopupSettings: eventPopupSettings || {} } : resourceChanged ? { eventPopupSettings: eventPopupSettingsBase } : {}
10450
11172
  })
10451
11173
  } : {}
10452
11174
  }
10453
11175
  },
10454
- options
11176
+ {
11177
+ ...options,
11178
+ replacePopupStepParamSubtrees: resourceChanged,
11179
+ skipHiddenPopupHostEnsure: true
11180
+ }
10455
11181
  );
10456
11182
  const reloaded = await this.repository.findModelById(current.uid, {
10457
11183
  transaction: options.transaction,
10458
11184
  includeAsyncNode: true
10459
11185
  });
10460
- await this.ensureCalendarBlockPopupHosts(reloaded, options.transaction);
11186
+ await this.ensureCalendarBlockPopupHosts(
11187
+ reloaded,
11188
+ options.transaction,
11189
+ {
11190
+ quickCreateAction: hasQuickCreatePopupChange ? quickCreatePopupSettings : resourceChanged ? quickCreatePopupSettingsBase : void 0,
11191
+ eventViewAction: hasEventPopupChange ? eventPopupSettings : resourceChanged ? eventPopupSettingsBase : void 0
11192
+ },
11193
+ {
11194
+ displayFallbackOpenViews: {
11195
+ quickCreateAction: previousQuickCreateOpenView,
11196
+ eventViewAction: previousEventOpenView
11197
+ }
11198
+ }
11199
+ );
10461
11200
  return result;
10462
11201
  }
10463
11202
  async configureTreeBlock(target, current, changes, options) {
@@ -10503,7 +11242,11 @@ class FlowSurfacesService {
10503
11242
  ...(0, import_service_utils.hasOwnDefined)(changes, "titleField") ? { titleField: { titleField: nextFieldNames.title } } : {},
10504
11243
  ...(0, import_service_utils.hasOwnDefined)(changes, "pageSize") ? { pageSize: { pageSize: changes.pageSize } } : {},
10505
11244
  ...(0, import_service_utils.hasOwnDefined)(changes, "dataScope") ? { dataScope: { filter: changes.dataScope } } : {},
10506
- ...(0, import_service_utils.hasOwnDefined)(changes, "sorting") ? { defaultSorting: { sort: changes.sorting } } : {}
11245
+ ...(0, import_service_utils.hasOwnDefined)(changes, "sorting") ? {
11246
+ defaultSorting: {
11247
+ sort: this.normalizeBlockSortingInput(changes.sorting, "treeSettings.sorting")
11248
+ }
11249
+ } : {}
10507
11250
  })
10508
11251
  } : {}
10509
11252
  }
@@ -10678,20 +11421,44 @@ class FlowSurfacesService {
10678
11421
  const nextDragEnabled = requestedDragEnabled === true && !!nextDragSortBy;
10679
11422
  const nextStyleVariantProp = (0, import_service_utils.hasOwnDefined)(changes, "styleVariant") ? String(changes.styleVariant || "").trim() === "default" ? "default" : "color" : void 0;
10680
11423
  const nextStyleVariantSetting = (0, import_service_utils.hasOwnDefined)(changes, "styleVariant") ? String(changes.styleVariant || "").trim() : void 0;
10681
- const quickCreatePopup = Object.prototype.hasOwnProperty.call(changes, "quickCreatePopup") ? await this.normalizeKanbanPopupConfigureValue({
11424
+ const shouldWriteQuickCreatePopup = Object.prototype.hasOwnProperty.call(changes, "quickCreatePopup");
11425
+ const shouldWriteCardPopup = Object.prototype.hasOwnProperty.call(changes, "cardPopup");
11426
+ const quickCreatePopupInput = shouldWriteQuickCreatePopup ? await this.normalizeKanbanPopupConfigureValue({
10682
11427
  actionName: "configure kanban quickCreatePopup",
10683
11428
  blockUid: current.uid,
10684
11429
  actionKey: "quickCreateAction",
10685
11430
  value: changes.quickCreatePopup,
10686
11431
  transaction: options.transaction
10687
11432
  }) : void 0;
10688
- const cardPopup = Object.prototype.hasOwnProperty.call(changes, "cardPopup") ? await this.normalizeKanbanPopupConfigureValue({
11433
+ const cardPopupInput = shouldWriteCardPopup ? await this.normalizeKanbanPopupConfigureValue({
10689
11434
  actionName: "configure kanban cardPopup",
10690
11435
  blockUid: current.uid,
10691
11436
  actionKey: "cardViewAction",
10692
11437
  value: changes.cardPopup,
10693
11438
  transaction: options.transaction
10694
11439
  }) : void 0;
11440
+ const currentQuickCreatePopupSettings = this.getKanbanPopupStoredSettings(current, "quickCreateAction");
11441
+ const currentCardPopupSettings = this.getKanbanPopupStoredSettings(current, "cardViewAction");
11442
+ const quickCreatePopupBase = resourceChanged ? this.stripKanbanPopupTargetSettingsForResourceChange(
11443
+ "quickCreateAction",
11444
+ currentQuickCreatePopupSettings,
11445
+ current.uid
11446
+ ) : currentQuickCreatePopupSettings;
11447
+ const cardPopupBase = resourceChanged ? this.stripKanbanPopupTargetSettingsForResourceChange("cardViewAction", currentCardPopupSettings, current.uid) : currentCardPopupSettings;
11448
+ const quickCreatePopup = shouldWriteQuickCreatePopup ? import_lodash.default.isNull(changes.quickCreatePopup) ? quickCreatePopupInput || {} : this.mergeKanbanPopupSettings("quickCreateAction", quickCreatePopupBase, quickCreatePopupInput, current.uid) : void 0;
11449
+ const cardPopup = shouldWriteCardPopup ? import_lodash.default.isNull(changes.cardPopup) ? cardPopupInput || {} : this.mergeKanbanPopupSettings("cardViewAction", cardPopupBase, cardPopupInput, current.uid) : void 0;
11450
+ const previousQuickCreateOpenView = this.buildKanbanPopupOpenView({
11451
+ blockNode: current,
11452
+ actionKey: "quickCreateAction",
11453
+ resourceInit: currentResourceInit,
11454
+ popupSettings: currentQuickCreatePopupSettings
11455
+ });
11456
+ const previousCardOpenView = this.buildKanbanPopupOpenView({
11457
+ blockNode: current,
11458
+ actionKey: "cardViewAction",
11459
+ resourceInit: currentResourceInit,
11460
+ popupSettings: currentCardPopupSettings
11461
+ });
10695
11462
  const nextCardLayout = (0, import_service_utils.hasOwnDefined)(changes, "cardLayout") ? (0, import_service_utils.normalizeSimpleLayoutValue)(changes.cardLayout) : void 0;
10696
11463
  const shouldWriteGrouping = resourceChanged || (0, import_service_utils.hasOwnDefined)(changes, "groupField") || (0, import_service_utils.hasOwnDefined)(changes, "groupTitleField") || (0, import_service_utils.hasOwnDefined)(changes, "groupColorField") || (0, import_service_utils.hasOwnDefined)(changes, "groupOptions") || groupFieldChanged;
10697
11464
  const shouldWriteDrag = resourceChanged || (0, import_service_utils.hasOwnDefined)(changes, "dragEnabled") || (0, import_service_utils.hasOwnDefined)(changes, "dragSortBy") || groupFieldChanged;
@@ -10703,7 +11470,7 @@ class FlowSurfacesService {
10703
11470
  groupOptions: nextGroupOptions || []
10704
11471
  } : {},
10705
11472
  ...(0, import_service_utils.hasOwnDefined)(changes, "styleVariant") ? { styleVariant: nextStyleVariantProp } : {},
10706
- ...(0, import_service_utils.hasOwnDefined)(changes, "sorting") ? { globalSort: changes.sorting } : {},
11473
+ ...(0, import_service_utils.hasOwnDefined)(changes, "sorting") ? { globalSort: this.normalizeBlockSortingInput(changes.sorting, "kanban.globalSort") } : {},
10707
11474
  ...shouldWriteDrag ? {
10708
11475
  dragEnabled: nextDragEnabled,
10709
11476
  dragSortBy: nextDragSortBy ?? null
@@ -10712,14 +11479,7 @@ class FlowSurfacesService {
10712
11479
  quickCreateEnabled: changes.quickCreateEnabled === true
10713
11480
  } : {},
10714
11481
  ...(0, import_service_utils.hasOwnDefined)(changes, "pageSize") ? { pageSize: changes.pageSize } : {},
10715
- ...(0, import_service_utils.hasOwnDefined)(changes, "columnWidth") ? { columnWidth: changes.columnWidth } : {},
10716
- ...(0, import_service_utils.hasOwnDefined)(changes, "quickCreatePopup") ? {
10717
- popupMode: (quickCreatePopup == null ? void 0 : quickCreatePopup.mode) ?? null,
10718
- popupSize: (quickCreatePopup == null ? void 0 : quickCreatePopup.size) ?? null,
10719
- popupTemplateUid: (quickCreatePopup == null ? void 0 : quickCreatePopup.popupTemplateUid) ?? null,
10720
- popupPageModelClass: (quickCreatePopup == null ? void 0 : quickCreatePopup.pageModelClass) ?? null,
10721
- popupTargetUid: (quickCreatePopup == null ? void 0 : quickCreatePopup.uid) ?? null
10722
- } : {}
11482
+ ...(0, import_service_utils.hasOwnDefined)(changes, "columnWidth") ? { columnWidth: changes.columnWidth } : {}
10723
11483
  });
10724
11484
  const blockStepParams = (0, import_service_utils.buildDefinedPayload)({
10725
11485
  ...blockCardSettings ? { cardSettings: blockCardSettings } : {},
@@ -10728,7 +11488,7 @@ class FlowSurfacesService {
10728
11488
  init: nextResourceInit
10729
11489
  }
10730
11490
  } : {},
10731
- ...shouldWriteGrouping || (0, import_service_utils.hasOwnDefined)(changes, "styleVariant") || (0, import_service_utils.hasOwnDefined)(changes, "sorting") || shouldWriteDrag || (0, import_service_utils.hasOwnDefined)(changes, "quickCreateEnabled") || (0, import_service_utils.hasOwnDefined)(changes, "quickCreatePopup") || (0, import_service_utils.hasOwnDefined)(changes, "pageSize") || (0, import_service_utils.hasOwnDefined)(changes, "columnWidth") || (0, import_service_utils.hasOwnDefined)(changes, "dataScope") ? {
11491
+ ...shouldWriteGrouping || (0, import_service_utils.hasOwnDefined)(changes, "styleVariant") || (0, import_service_utils.hasOwnDefined)(changes, "sorting") || shouldWriteDrag || (0, import_service_utils.hasOwnDefined)(changes, "quickCreateEnabled") || shouldWriteQuickCreatePopup || (0, import_service_utils.hasOwnDefined)(changes, "pageSize") || (0, import_service_utils.hasOwnDefined)(changes, "columnWidth") || (0, import_service_utils.hasOwnDefined)(changes, "dataScope") ? {
10732
11492
  kanbanSettings: (0, import_service_utils.buildDefinedPayload)({
10733
11493
  ...shouldWriteGrouping ? {
10734
11494
  grouping: (0, import_service_utils.buildDefinedPayload)({
@@ -10745,7 +11505,7 @@ class FlowSurfacesService {
10745
11505
  } : {},
10746
11506
  ...(0, import_service_utils.hasOwnDefined)(changes, "sorting") ? {
10747
11507
  defaultSorting: {
10748
- sort: changes.sorting
11508
+ sort: this.normalizeBlockSortingInput(changes.sorting, "kanbanSettings.defaultSorting.sort")
10749
11509
  }
10750
11510
  } : {},
10751
11511
  ...shouldWriteDrag ? {
@@ -10761,7 +11521,7 @@ class FlowSurfacesService {
10761
11521
  quickCreateEnabled: changes.quickCreateEnabled === true
10762
11522
  }
10763
11523
  } : {},
10764
- ...(0, import_service_utils.hasOwnDefined)(changes, "quickCreatePopup") ? {
11524
+ ...shouldWriteQuickCreatePopup ? {
10765
11525
  popup: quickCreatePopup || {}
10766
11526
  } : {},
10767
11527
  ...(0, import_service_utils.hasOwnDefined)(changes, "pageSize") ? {
@@ -10786,13 +11546,6 @@ class FlowSurfacesService {
10786
11546
  ...(0, import_service_utils.hasOwnDefined)(changes, "enableCardClick") ? {
10787
11547
  enableCardClick: changes.enableCardClick === true
10788
11548
  } : {},
10789
- ...(0, import_service_utils.hasOwnDefined)(changes, "cardPopup") ? {
10790
- openMode: (cardPopup == null ? void 0 : cardPopup.mode) ?? null,
10791
- popupSize: (cardPopup == null ? void 0 : cardPopup.size) ?? null,
10792
- popupTemplateUid: (cardPopup == null ? void 0 : cardPopup.popupTemplateUid) ?? null,
10793
- pageModelClass: (cardPopup == null ? void 0 : cardPopup.pageModelClass) ?? null,
10794
- popupTargetUid: (cardPopup == null ? void 0 : cardPopup.uid) ?? null
10795
- } : {},
10796
11549
  ...(0, import_service_utils.hasOwnDefined)(changes, "cardLayout") ? {
10797
11550
  layout: nextCardLayout
10798
11551
  } : {},
@@ -10802,14 +11555,14 @@ class FlowSurfacesService {
10802
11555
  ...(0, import_service_utils.hasOwnDefined)(changes, "cardColon") ? { colon: changes.cardColon === true } : {}
10803
11556
  });
10804
11557
  const itemStepParams = (0, import_service_utils.buildDefinedPayload)({
10805
- ...(0, import_service_utils.hasOwnDefined)(changes, "enableCardClick") || (0, import_service_utils.hasOwnDefined)(changes, "cardPopup") || (0, import_service_utils.hasOwnDefined)(changes, "cardLayout") || (0, import_service_utils.hasOwnDefined)(changes, "cardLabelAlign") || (0, import_service_utils.hasOwnDefined)(changes, "cardLabelWidth") || (0, import_service_utils.hasOwnDefined)(changes, "cardLabelWrap") || (0, import_service_utils.hasOwnDefined)(changes, "cardColon") ? {
11558
+ ...(0, import_service_utils.hasOwnDefined)(changes, "enableCardClick") || shouldWriteCardPopup || (0, import_service_utils.hasOwnDefined)(changes, "cardLayout") || (0, import_service_utils.hasOwnDefined)(changes, "cardLabelAlign") || (0, import_service_utils.hasOwnDefined)(changes, "cardLabelWidth") || (0, import_service_utils.hasOwnDefined)(changes, "cardLabelWrap") || (0, import_service_utils.hasOwnDefined)(changes, "cardColon") ? {
10806
11559
  cardSettings: (0, import_service_utils.buildDefinedPayload)({
10807
11560
  ...(0, import_service_utils.hasOwnDefined)(changes, "enableCardClick") ? {
10808
11561
  click: {
10809
11562
  enableCardClick: changes.enableCardClick === true
10810
11563
  }
10811
11564
  } : {},
10812
- ...(0, import_service_utils.hasOwnDefined)(changes, "cardPopup") ? {
11565
+ ...shouldWriteCardPopup ? {
10813
11566
  popup: cardPopup || {}
10814
11567
  } : {},
10815
11568
  ...(0, import_service_utils.hasOwnDefined)(changes, "cardLayout") || (0, import_service_utils.hasOwnDefined)(changes, "cardLabelAlign") || (0, import_service_utils.hasOwnDefined)(changes, "cardLabelWidth") || (0, import_service_utils.hasOwnDefined)(changes, "cardLabelWrap") || (0, import_service_utils.hasOwnDefined)(changes, "cardColon") ? {
@@ -10832,7 +11585,11 @@ class FlowSurfacesService {
10832
11585
  props: blockProps,
10833
11586
  stepParams: blockStepParams
10834
11587
  },
10835
- options
11588
+ {
11589
+ ...options,
11590
+ replacePopupStepParamSubtrees: resourceChanged,
11591
+ skipHiddenPopupHostEnsure: true
11592
+ }
10836
11593
  );
10837
11594
  import_lodash.default.castArray((blockResult == null ? void 0 : blockResult.updated) || []).forEach((key) => updated.add(String(key)));
10838
11595
  }
@@ -10845,7 +11602,11 @@ class FlowSurfacesService {
10845
11602
  props: itemProps,
10846
11603
  stepParams: itemStepParams
10847
11604
  },
10848
- options
11605
+ {
11606
+ ...options,
11607
+ replacePopupStepParamSubtrees: resourceChanged,
11608
+ skipHiddenPopupHostEnsure: true
11609
+ }
10849
11610
  );
10850
11611
  import_lodash.default.castArray((itemResult == null ? void 0 : itemResult.updated) || []).forEach((key) => updated.add(String(key)));
10851
11612
  }
@@ -10853,7 +11614,37 @@ class FlowSurfacesService {
10853
11614
  transaction: options.transaction,
10854
11615
  includeAsyncNode: true
10855
11616
  });
10856
- await this.ensureKanbanBlockPopupHosts(reloaded, options.transaction);
11617
+ const popupSettingsStorageNode = reloaded || current;
11618
+ if (resourceChanged && !shouldWriteQuickCreatePopup) {
11619
+ await this.replaceKanbanStoredPopupSettings(
11620
+ popupSettingsStorageNode,
11621
+ "quickCreateAction",
11622
+ quickCreatePopupBase,
11623
+ options.transaction
11624
+ );
11625
+ }
11626
+ if (resourceChanged && !shouldWriteCardPopup) {
11627
+ await this.replaceKanbanStoredPopupSettings(
11628
+ popupSettingsStorageNode,
11629
+ "cardViewAction",
11630
+ cardPopupBase,
11631
+ options.transaction
11632
+ );
11633
+ }
11634
+ await this.ensureKanbanBlockPopupHosts(
11635
+ reloaded,
11636
+ options.transaction,
11637
+ {
11638
+ quickCreateAction: shouldWriteQuickCreatePopup ? quickCreatePopup || {} : resourceChanged ? quickCreatePopupBase : void 0,
11639
+ cardViewAction: shouldWriteCardPopup ? cardPopup || {} : resourceChanged ? cardPopupBase : void 0
11640
+ },
11641
+ {
11642
+ displayFallbackOpenViews: {
11643
+ quickCreateAction: previousQuickCreateOpenView,
11644
+ cardViewAction: previousCardOpenView
11645
+ }
11646
+ }
11647
+ );
10857
11648
  return (0, import_service_utils.buildDefinedPayload)({
10858
11649
  uid: current.uid,
10859
11650
  ...updated.size ? { updated: Array.from(updated) } : {}
@@ -10953,7 +11744,11 @@ class FlowSurfacesService {
10953
11744
  colon: changes.colon
10954
11745
  })
10955
11746
  } : {},
10956
- ...(0, import_service_utils.hasOwnDefined)(changes, "sorting") ? { defaultSorting: { sort: changes.sorting } } : {},
11747
+ ...(0, import_service_utils.hasOwnDefined)(changes, "sorting") ? {
11748
+ defaultSorting: {
11749
+ sort: this.normalizeBlockSortingInput(changes.sorting, "detailsSettings.sorting")
11750
+ }
11751
+ } : {},
10957
11752
  ...(0, import_service_utils.hasOwnDefined)(changes, "dataScope") ? { dataScope: { filter: changes.dataScope } } : {},
10958
11753
  ...(0, import_service_utils.hasOwnDefined)(changes, "linkageRules") ? { linkageRules: { value: changes.linkageRules } } : {}
10959
11754
  })
@@ -11023,7 +11818,11 @@ class FlowSurfacesService {
11023
11818
  listSettings: (0, import_service_utils.buildDefinedPayload)({
11024
11819
  ...(0, import_service_utils.hasOwnDefined)(changes, "pageSize") ? { pageSize: { pageSize: changes.pageSize } } : {},
11025
11820
  ...(0, import_service_utils.hasOwnDefined)(changes, "dataScope") ? { dataScope: { filter: changes.dataScope } } : {},
11026
- ...(0, import_service_utils.hasOwnDefined)(changes, "sorting") ? { defaultSorting: { sort: changes.sorting } } : {},
11821
+ ...(0, import_service_utils.hasOwnDefined)(changes, "sorting") ? {
11822
+ defaultSorting: {
11823
+ sort: this.normalizeBlockSortingInput(changes.sorting, "listSettings.sorting")
11824
+ }
11825
+ } : {},
11027
11826
  ...(0, import_service_utils.hasOwnDefined)(changes, "layout") ? { layout: { layout: layoutValue } } : {}
11028
11827
  })
11029
11828
  } : {}
@@ -11053,7 +11852,11 @@ class FlowSurfacesService {
11053
11852
  ...columns ? { columnCount: { columnCount: columns } } : {},
11054
11853
  ...(0, import_service_utils.hasOwnDefined)(changes, "rowCount") ? { rowCount: { rowCount: changes.rowCount } } : {},
11055
11854
  ...(0, import_service_utils.hasOwnDefined)(changes, "dataScope") ? { dataScope: { filter: changes.dataScope } } : {},
11056
- ...(0, import_service_utils.hasOwnDefined)(changes, "sorting") ? { defaultSorting: { sort: changes.sorting } } : {},
11855
+ ...(0, import_service_utils.hasOwnDefined)(changes, "sorting") ? {
11856
+ defaultSorting: {
11857
+ sort: this.normalizeBlockSortingInput(changes.sorting, "GridCardSettings.sorting")
11858
+ }
11859
+ } : {},
11057
11860
  ...(0, import_service_utils.hasOwnDefined)(changes, "layout") ? { layout: { layout: layoutValue } } : {}
11058
11861
  })
11059
11862
  } : {}
@@ -11230,7 +12033,11 @@ class FlowSurfacesService {
11230
12033
  })
11231
12034
  } : {},
11232
12035
  ...(0, import_service_utils.hasOwnDefined)(changes, "dataScope") ? { dataScope: { filter: changes.dataScope } } : {},
11233
- ...(0, import_service_utils.hasOwnDefined)(changes, "sorting") ? { lineSort: { sort: changes.sorting } } : {},
12036
+ ...(0, import_service_utils.hasOwnDefined)(changes, "sorting") ? {
12037
+ lineSort: {
12038
+ sort: this.normalizeMapSortingInput(changes.sorting, "createMapBlock.lineSort.sort")
12039
+ }
12040
+ } : {},
11234
12041
  ...(0, import_service_utils.hasOwnDefined)(changes, "zoom") ? { mapZoom: { zoom: changes.zoom } } : {}
11235
12042
  })
11236
12043
  } : {}
@@ -11795,6 +12602,10 @@ class FlowSurfacesService {
11795
12602
  return import_lodash.default.cloneDeep(value);
11796
12603
  }
11797
12604
  async configureActionNode(target, use, changes, options) {
12605
+ const currentNode = options.current || (target.uid ? await this.repository.findModelById(target.uid, {
12606
+ transaction: options.transaction,
12607
+ includeAsyncNode: true
12608
+ }) : null);
11798
12609
  changes = await this.normalizeActionPanelActionChanges(changes, options);
11799
12610
  const allowedKeys = (0, import_configure_options.getConfigureOptionKeysForUse)(use);
11800
12611
  (0, import_service_utils.assertSupportedSimpleChanges)("action", changes, allowedKeys);
@@ -11862,8 +12673,12 @@ class FlowSurfacesService {
11862
12673
  } else if (!POPUP_ACTION_USES.has(use)) {
11863
12674
  (0, import_errors.throwBadRequest)(`flowSurfaces configure action '${use}' does not support openView`);
11864
12675
  } else {
12676
+ let openView = import_lodash.default.cloneDeep(changes.openView);
12677
+ if (use === "AddChildActionModel") {
12678
+ openView = await this.normalizeAddChildOpenViewForAction(currentNode, openView, options.transaction);
12679
+ }
11865
12680
  stepParams.popupSettings = {
11866
- openView: import_lodash.default.cloneDeep(changes.openView)
12681
+ openView
11867
12682
  };
11868
12683
  }
11869
12684
  }
@@ -11992,24 +12807,25 @@ class FlowSurfacesService {
11992
12807
  })
11993
12808
  };
11994
12809
  }
12810
+ const props = (0, import_service_utils.buildDefinedPayload)({
12811
+ title: changes.title,
12812
+ tooltip: changes.tooltip,
12813
+ icon: changes.icon,
12814
+ type: changes.type,
12815
+ htmlType: changes.htmlType,
12816
+ position: changes.position,
12817
+ danger: changes.danger,
12818
+ color: changes.color,
12819
+ ...(0, import_service_utils.hasOwnDefined)(changes, "filterableFieldNames") ? { filterableFieldNames: import_lodash.default.cloneDeep(changes.filterableFieldNames) } : {},
12820
+ ...(0, import_service_utils.hasOwnDefined)(changes, "defaultFilter") ? {
12821
+ defaultFilterValue: normalizedDefaultFilter,
12822
+ filterValue: import_lodash.default.cloneDeep(normalizedDefaultFilter)
12823
+ } : {}
12824
+ });
11995
12825
  return this.updateSettings(
11996
12826
  {
11997
12827
  target,
11998
- props: (0, import_service_utils.buildDefinedPayload)({
11999
- title: changes.title,
12000
- tooltip: changes.tooltip,
12001
- icon: changes.icon,
12002
- type: changes.type,
12003
- htmlType: changes.htmlType,
12004
- position: changes.position,
12005
- danger: changes.danger,
12006
- color: changes.color,
12007
- ...(0, import_service_utils.hasOwnDefined)(changes, "filterableFieldNames") ? { filterableFieldNames: import_lodash.default.cloneDeep(changes.filterableFieldNames) } : {},
12008
- ...(0, import_service_utils.hasOwnDefined)(changes, "defaultFilter") ? {
12009
- defaultFilterValue: normalizedDefaultFilter,
12010
- filterValue: import_lodash.default.cloneDeep(normalizedDefaultFilter)
12011
- } : {}
12012
- }),
12828
+ ...Object.keys(props).length ? { props } : {},
12013
12829
  stepParams: Object.keys(stepParams).length ? stepParams : void 0
12014
12830
  },
12015
12831
  {
@@ -13157,33 +13973,120 @@ class FlowSurfacesService {
13157
13973
  ) || (field == null ? void 0 : field.targetCollection) || null;
13158
13974
  }
13159
13975
  resolvePopupHostOpenView(node) {
13160
- for (const [flowKey, stepKey] of import_template_service_utils.POPUP_HOST_STEP_PARAM_PATHS) {
13161
- const openView = import_lodash.default.get(node, ["stepParams", flowKey, stepKey]);
13162
- if (import_lodash.default.isPlainObject(openView)) {
13163
- return openView;
13164
- }
13165
- }
13166
- return null;
13976
+ return (0, import_hidden_popup_contract.resolveHiddenPopupHostOpenView)(node);
13167
13977
  }
13168
- resolvePopupSourceRecordCollectionName(popupAssociationName, hostContext) {
13169
- var _a, _b, _c;
13170
- const normalizedAssociationName = String(popupAssociationName || "").trim();
13171
- const resourceCollectionName = String(((_b = (_a = hostContext == null ? void 0 : hostContext.resourceContext) == null ? void 0 : _a.resourceInit) == null ? void 0 : _b.collectionName) || "").trim();
13172
- if (((_c = hostContext == null ? void 0 : hostContext.associationContext) == null ? void 0 : _c.associationField) && resourceCollectionName) {
13173
- return resourceCollectionName;
13174
- }
13175
- if (normalizedAssociationName.includes(".")) {
13176
- return normalizedAssociationName.split(".")[0];
13177
- }
13178
- if (normalizedAssociationName && resourceCollectionName) {
13179
- return resourceCollectionName;
13180
- }
13181
- return void 0;
13978
+ popupHostHasLocalContent(actionNode) {
13979
+ return (0, import_hidden_popup_contract.hiddenPopupHostHasLocalContent)(actionNode);
13182
13980
  }
13183
- async resolvePopupContextLevel(uid2, hostNode, transaction, options = {}) {
13184
- var _a, _b, _c, _d, _e, _f, _g;
13185
- const popupConfig = this.resolvePopupHostOpenView(hostNode);
13186
- const hostContext = (hostNode == null ? void 0 : hostNode.uid) ? await this.resolvePopupHostProfileContext(hostNode, transaction).catch(() => null) : null;
13981
+ shouldAutoBindPopupTemplate(openView, popupSettings, expectedHostUid, hostNode) {
13982
+ return (0, import_hidden_popup_contract.shouldAutoBindHiddenPopupTemplate)(openView, popupSettings, expectedHostUid, {
13983
+ hostHasLocalContent: !!(hostNode == null ? void 0 : hostNode.uid) && this.popupHostHasLocalContent(hostNode)
13984
+ });
13985
+ }
13986
+ async patchPopupOpenViewIfChanged(actionUid, openView, transaction) {
13987
+ const actionNode = await this.repository.findModelById(actionUid, {
13988
+ transaction,
13989
+ includeAsyncNode: true
13990
+ });
13991
+ if (!(actionNode == null ? void 0 : actionNode.uid)) {
13992
+ return false;
13993
+ }
13994
+ const currentOpenView = this.resolvePopupHostOpenView(actionNode);
13995
+ if (import_lodash.default.isEqual(currentOpenView, openView)) {
13996
+ return false;
13997
+ }
13998
+ await this.repository.patch(
13999
+ {
14000
+ uid: actionUid,
14001
+ stepParams: (0, import_hidden_popup_contract.buildHiddenPopupActionStepParams)(actionNode.stepParams, openView)
14002
+ },
14003
+ { transaction }
14004
+ );
14005
+ return true;
14006
+ }
14007
+ async buildPopupOpenViewWithTemplate(input) {
14008
+ var _a;
14009
+ const hasExplicitTargetSettings = (0, import_hidden_popup_contract.hasExplicitHiddenPopupTargetSettings)(input.popupSettings, input.actionUid);
14010
+ const shouldAutoBind = this.shouldAutoBindPopupTemplate(
14011
+ input.openView,
14012
+ input.popupSettings,
14013
+ input.actionUid,
14014
+ input.existingHost
14015
+ );
14016
+ if (!hasExplicitTargetSettings && !shouldAutoBind) {
14017
+ return input.openView;
14018
+ }
14019
+ const openViewForNormalize = shouldAutoBind && String(((_a = input.openView) == null ? void 0 : _a.uid) || "").trim() === input.actionUid ? { ...input.openView, uid: void 0, tryTemplate: true } : shouldAutoBind ? { ...input.openView, tryTemplate: true } : input.openView;
14020
+ const normalized = await this.normalizeOpenView(input.actionName, openViewForNormalize, {
14021
+ transaction: input.transaction,
14022
+ popupTemplateHostUid: input.actionUid,
14023
+ popupActionContext: {
14024
+ hasCurrentRecord: !!input.hasCurrentRecord
14025
+ }
14026
+ });
14027
+ const normalizedOpenView = input.normalizePopupSettings(normalized || input.openView);
14028
+ return input.mergeDisplaySettings(
14029
+ (0, import_service_utils.buildDefinedPayload)({
14030
+ ...input.openView,
14031
+ ...normalizedOpenView,
14032
+ uid: normalizedOpenView.uid || input.openView.uid,
14033
+ collectionName: normalizedOpenView.collectionName || input.openView.collectionName,
14034
+ dataSourceKey: normalizedOpenView.dataSourceKey || input.openView.dataSourceKey
14035
+ }),
14036
+ input.popupSettings,
14037
+ input.openView
14038
+ );
14039
+ }
14040
+ async completePopupHostDefaultContent(input) {
14041
+ const popup = (0, import_hidden_popup_contract.buildImplicitHiddenPopupDefaultContent)(input.popupSettings);
14042
+ if (!popup) {
14043
+ return;
14044
+ }
14045
+ await this.applyInlineActionPopup(input.actionName, input.actionUid, popup, {
14046
+ transaction: input.transaction,
14047
+ popupActionContext: {
14048
+ hasCurrentRecord: !!input.hasCurrentRecord
14049
+ }
14050
+ });
14051
+ }
14052
+ async ensurePopupHostDefaultContent(input) {
14053
+ let actionNode = await this.repository.findModelById(input.actionUid, {
14054
+ transaction: input.transaction,
14055
+ includeAsyncNode: true
14056
+ });
14057
+ const openView = this.resolvePopupHostOpenView(actionNode);
14058
+ if (!this.shouldAutoBindPopupTemplate(openView, input.popupSettings, input.actionUid) || String((openView == null ? void 0 : openView.popupTemplateUid) || "").trim() || this.popupHostHasLocalContent(actionNode)) {
14059
+ return false;
14060
+ }
14061
+ await this.completePopupHostDefaultContent(input);
14062
+ actionNode = await this.repository.findModelById(input.actionUid, {
14063
+ transaction: input.transaction,
14064
+ includeAsyncNode: true
14065
+ });
14066
+ const completedOpenView = this.resolvePopupHostOpenView(actionNode);
14067
+ const mergedCompletedOpenView = input.mergeDisplaySettings(completedOpenView, input.popupSettings, openView);
14068
+ await this.patchPopupOpenViewIfChanged(input.actionUid, mergedCompletedOpenView, input.transaction);
14069
+ return true;
14070
+ }
14071
+ resolvePopupSourceRecordCollectionName(popupAssociationName, hostContext) {
14072
+ var _a, _b, _c;
14073
+ const normalizedAssociationName = String(popupAssociationName || "").trim();
14074
+ const resourceCollectionName = String(((_b = (_a = hostContext == null ? void 0 : hostContext.resourceContext) == null ? void 0 : _a.resourceInit) == null ? void 0 : _b.collectionName) || "").trim();
14075
+ if (((_c = hostContext == null ? void 0 : hostContext.associationContext) == null ? void 0 : _c.associationField) && resourceCollectionName) {
14076
+ return resourceCollectionName;
14077
+ }
14078
+ if (normalizedAssociationName.includes(".")) {
14079
+ return normalizedAssociationName.split(".")[0];
14080
+ }
14081
+ if (normalizedAssociationName && resourceCollectionName) {
14082
+ return resourceCollectionName;
14083
+ }
14084
+ return void 0;
14085
+ }
14086
+ async resolvePopupContextLevel(uid2, hostNode, transaction, options = {}) {
14087
+ var _a, _b, _c, _d, _e, _f, _g;
14088
+ const popupConfig = this.resolvePopupHostOpenView(hostNode);
14089
+ const hostContext = (hostNode == null ? void 0 : hostNode.uid) ? await this.resolvePopupHostProfileContext(hostNode, transaction).catch(() => null) : null;
13187
14090
  const popupDataSourceKey = (popupConfig == null ? void 0 : popupConfig.dataSourceKey) || ((_a = hostContext == null ? void 0 : hostContext.associationContext) == null ? void 0 : _a.dataSourceKey) || ((_c = (_b = hostContext == null ? void 0 : hostContext.resourceContext) == null ? void 0 : _b.resourceInit) == null ? void 0 : _c.dataSourceKey) || "main";
13188
14091
  const popupCollectionName = String((popupConfig == null ? void 0 : popupConfig.collectionName) || ((_d = hostContext == null ? void 0 : hostContext.associationContext) == null ? void 0 : _d.collectionName) || "").trim() || void 0;
13189
14092
  const popupAssociationName = String(
@@ -13441,108 +14344,60 @@ class FlowSurfacesService {
13441
14344
  });
13442
14345
  }
13443
14346
  normalizeKanbanPopupSettings(actionKey, popupSettings, blockUid) {
13444
- const nextParams = import_lodash.default.cloneDeep(popupSettings || {});
13445
- const actionUid = blockUid && actionKey ? this.getKanbanPopupActionUid(blockUid, actionKey) : void 0;
13446
- const popupTemplateUidProvided = Object.prototype.hasOwnProperty.call(nextParams, "popupTemplateUid");
13447
- const popupTemplateUid = typeof nextParams.popupTemplateUid === "string" ? nextParams.popupTemplateUid.trim() : nextParams.popupTemplateUid;
13448
- if (popupTemplateUidProvided && (popupTemplateUid === void 0 || popupTemplateUid === null || popupTemplateUid === "")) {
13449
- delete nextParams.popupTemplateUid;
13450
- delete nextParams.popupTemplateContext;
13451
- delete nextParams.popupTemplateHasFilterByTk;
13452
- delete nextParams.popupTemplateHasSourceId;
13453
- delete nextParams.uid;
13454
- }
13455
- const normalizedUid = typeof nextParams.uid === "string" ? nextParams.uid.trim() : nextParams.uid;
13456
- if (!normalizedUid || normalizedUid === blockUid || normalizedUid === actionUid) {
13457
- delete nextParams.uid;
13458
- } else {
13459
- nextParams.uid = normalizedUid;
13460
- }
13461
- if (typeof nextParams.mode === "string") {
13462
- nextParams.mode = OPEN_VIEW_MODE_ALIASES[nextParams.mode] || nextParams.mode;
13463
- }
13464
- if (typeof nextParams.size === "string" && !nextParams.size.trim()) {
13465
- delete nextParams.size;
13466
- }
13467
- if (typeof nextParams.pageModelClass === "string" && !nextParams.pageModelClass.trim()) {
13468
- delete nextParams.pageModelClass;
13469
- }
13470
- return nextParams;
13471
- }
13472
- getKanbanPopupActionUse(actionKey) {
13473
- return actionKey === "quickCreateAction" ? "KanbanQuickCreateActionModel" : "KanbanCardViewActionModel";
14347
+ return (0, import_hidden_popup_kanban.normalizeKanbanPopupSettings)(actionKey, popupSettings, blockUid);
13474
14348
  }
13475
14349
  getKanbanPopupActionUid(kanbanUid, actionKey) {
13476
- return `${kanbanUid}${KANBAN_POPUP_ACTION_UID_SUFFIX_BY_KEY[actionKey]}`;
14350
+ return (0, import_hidden_popup_kanban.getKanbanPopupActionUid)(kanbanUid, actionKey);
13477
14351
  }
13478
14352
  getKanbanBlockResourceInit(blockNode) {
13479
- const resourceInit = import_lodash.default.cloneDeep(import_lodash.default.get(blockNode, ["stepParams", "resourceSettings", "init"]) || {});
13480
- if (resourceInit.collectionName && !resourceInit.dataSourceKey) {
13481
- resourceInit.dataSourceKey = "main";
13482
- }
13483
- return resourceInit;
14353
+ return (0, import_hidden_popup_kanban.getKanbanBlockResourceInit)(blockNode);
14354
+ }
14355
+ buildKanbanInitialStepParams(input) {
14356
+ return (0, import_hidden_popup_kanban.buildKanbanInitialStepParams)(input);
14357
+ }
14358
+ buildKanbanInitialItemProps(input) {
14359
+ return (0, import_hidden_popup_kanban.buildKanbanInitialItemProps)(input);
14360
+ }
14361
+ buildKanbanInitialItemStepParams(input) {
14362
+ return (0, import_hidden_popup_kanban.buildKanbanInitialItemStepParams)(input);
13484
14363
  }
13485
14364
  getKanbanPopupStoredSettings(blockNode, actionKey) {
13486
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
13487
- const itemNode = (0, import_service_utils.getSingleNodeSubModel)((_a = blockNode == null ? void 0 : blockNode.subModels) == null ? void 0 : _a.item);
13488
- const rawPopupSettings = actionKey === "quickCreateAction" ? import_lodash.default.get(blockNode, ["stepParams", "kanbanSettings", "popup"]) || {
13489
- mode: (_b = blockNode == null ? void 0 : blockNode.props) == null ? void 0 : _b.popupMode,
13490
- size: (_c = blockNode == null ? void 0 : blockNode.props) == null ? void 0 : _c.popupSize,
13491
- popupTemplateUid: (_d = blockNode == null ? void 0 : blockNode.props) == null ? void 0 : _d.popupTemplateUid,
13492
- pageModelClass: (_e = blockNode == null ? void 0 : blockNode.props) == null ? void 0 : _e.popupPageModelClass,
13493
- uid: (_f = blockNode == null ? void 0 : blockNode.props) == null ? void 0 : _f.popupTargetUid
13494
- } : import_lodash.default.get(itemNode, ["stepParams", "cardSettings", "popup"]) || {
13495
- mode: (_g = itemNode == null ? void 0 : itemNode.props) == null ? void 0 : _g.openMode,
13496
- size: (_h = itemNode == null ? void 0 : itemNode.props) == null ? void 0 : _h.popupSize,
13497
- popupTemplateUid: (_i = itemNode == null ? void 0 : itemNode.props) == null ? void 0 : _i.popupTemplateUid,
13498
- pageModelClass: (_j = itemNode == null ? void 0 : itemNode.props) == null ? void 0 : _j.pageModelClass,
13499
- uid: (_k = itemNode == null ? void 0 : itemNode.props) == null ? void 0 : _k.popupTargetUid
13500
- };
13501
- return this.normalizeKanbanPopupSettings(actionKey, rawPopupSettings, blockNode == null ? void 0 : blockNode.uid);
14365
+ return (0, import_hidden_popup_kanban.getKanbanPopupStoredSettings)(blockNode, actionKey);
14366
+ }
14367
+ mergeKanbanPopupSettings(actionKey, current, value, blockUid) {
14368
+ return (0, import_hidden_popup_kanban.mergeKanbanPopupSettings)(actionKey, current, value, blockUid);
14369
+ }
14370
+ stripKanbanPopupTargetSettingsForResourceChange(actionKey, popupSettings, blockUid) {
14371
+ return (0, import_hidden_popup_kanban.stripKanbanPopupTargetSettingsForResourceChange)(actionKey, popupSettings, blockUid);
13502
14372
  }
13503
14373
  buildKanbanPopupOpenView(input) {
13504
- const actionUid = this.getKanbanPopupActionUid(input.blockNode.uid, input.actionKey);
13505
- const resourceInit = input.resourceInit || this.getKanbanBlockResourceInit(input.blockNode);
13506
- const defaults = (0, import_service_utils.buildDefinedPayload)({
13507
- mode: "drawer",
13508
- size: "medium",
13509
- pageModelClass: "ChildPageModel",
13510
- uid: actionUid,
13511
- collectionName: resourceInit.collectionName,
13512
- dataSourceKey: resourceInit.dataSourceKey || (resourceInit.collectionName ? "main" : void 0)
13513
- });
13514
- const current = this.getKanbanPopupStoredSettings(input.blockNode, input.actionKey);
13515
- return (0, import_service_utils.buildDefinedPayload)({
13516
- ...defaults,
13517
- ...current,
13518
- uid: current.uid || defaults.uid,
13519
- collectionName: current.collectionName || defaults.collectionName,
13520
- dataSourceKey: current.dataSourceKey || defaults.dataSourceKey
13521
- });
14374
+ return (0, import_hidden_popup_kanban.buildKanbanPopupOpenView)(input);
13522
14375
  }
13523
14376
  async normalizeKanbanPopupConfigureValue(input) {
13524
- if (import_lodash.default.isUndefined(input.value)) {
13525
- return void 0;
13526
- }
13527
- if (import_lodash.default.isNull(input.value)) {
13528
- return {};
13529
- }
13530
- const actionUid = this.getKanbanPopupActionUid(input.blockUid, input.actionKey);
13531
- const normalized = await this.normalizeOpenView(input.actionName, input.value, {
13532
- transaction: input.transaction,
13533
- popupTemplateHostUid: actionUid,
13534
- popupActionContext: {
13535
- hasCurrentRecord: input.actionKey === "cardViewAction"
13536
- }
14377
+ return (0, import_hidden_popup_kanban.normalizeKanbanPopupConfigureValue)({
14378
+ ...input,
14379
+ normalizeOpenView: (actionName, value, options) => this.normalizeOpenView(actionName, value, options)
13537
14380
  });
13538
- return this.normalizeKanbanPopupSettings(input.actionKey, normalized || {}, input.blockUid);
13539
14381
  }
13540
14382
  buildKanbanInitialBlockProps(input) {
13541
14383
  const { collection, collectionName, dataSourceKey } = this.assertKanbanCollectionCompatible(
13542
14384
  input.actionName,
13543
14385
  input.resourceInit
13544
14386
  );
13545
- const currentProps = import_lodash.default.cloneDeep(input.props || {});
14387
+ const currentProps = {
14388
+ ...import_lodash.default.isPlainObject(input.settings) ? import_lodash.default.pick(input.settings, [
14389
+ "groupField",
14390
+ "groupOptions",
14391
+ "groupTitleField",
14392
+ "groupColorField",
14393
+ "styleVariant",
14394
+ "dragEnabled",
14395
+ "dragSortBy",
14396
+ "quickCreateEnabled",
14397
+ "globalSort"
14398
+ ]) : {},
14399
+ ...import_lodash.default.cloneDeep(input.props || {})
14400
+ };
13546
14401
  const defaultGroupFieldName = this.getKanbanDefaultGroupFieldName(collection);
13547
14402
  const nextGroupFieldName = String(currentProps.groupField || defaultGroupFieldName || "").trim();
13548
14403
  const nextGroupField = this.getKanbanGroupField(collection, nextGroupFieldName);
@@ -13599,7 +14454,7 @@ class FlowSurfacesService {
13599
14454
  kind: "groupColorField"
13600
14455
  });
13601
14456
  }
13602
- return (0, import_service_utils.buildDefinedPayload)({
14457
+ const props = (0, import_service_utils.buildDefinedPayload)({
13603
14458
  ...currentProps,
13604
14459
  groupField: nextGroupFieldName,
13605
14460
  groupTitleField: nextGroupTitleField,
@@ -13608,8 +14463,26 @@ class FlowSurfacesService {
13608
14463
  styleVariant: currentProps.styleVariant || "color",
13609
14464
  quickCreateEnabled: currentProps.quickCreateEnabled === true,
13610
14465
  dragEnabled: nextDragEnabled,
13611
- dragSortBy: nextDragSortBy || void 0
13612
- });
14466
+ dragSortBy: nextDragSortBy || void 0,
14467
+ ...Object.prototype.hasOwnProperty.call(currentProps, "globalSort") ? { globalSort: this.normalizeBlockSortingInput(currentProps.globalSort, "kanban.globalSort") } : {}
14468
+ });
14469
+ delete props.quickCreatePopup;
14470
+ delete props.quickCreatePopupSettings;
14471
+ delete props.cardPopup;
14472
+ delete props.cardPopupSettings;
14473
+ for (const propKey of import_hidden_popup_kanban.KANBAN_BLOCK_POPUP_PROP_KEYS) {
14474
+ delete props[propKey];
14475
+ }
14476
+ for (const propKey of [
14477
+ "cardOpenMode",
14478
+ "cardPopupSize",
14479
+ "cardPopupTemplateUid",
14480
+ "cardPopupPageModelClass",
14481
+ "cardPopupTargetUid"
14482
+ ]) {
14483
+ delete props[propKey];
14484
+ }
14485
+ return props;
13613
14486
  }
13614
14487
  normalizeCalendarFieldPathInput(value, context, options = {}) {
13615
14488
  if (import_lodash.default.isUndefined(value)) {
@@ -13825,86 +14698,50 @@ class FlowSurfacesService {
13825
14698
  });
13826
14699
  }
13827
14700
  normalizeCalendarPopupSettings(actionKey, popupSettings) {
13828
- const nextParams = import_lodash.default.cloneDeep(popupSettings || {});
13829
- const popupTemplateUidProvided = Object.prototype.hasOwnProperty.call(nextParams, "popupTemplateUid");
13830
- const popupTemplateUid = typeof nextParams.popupTemplateUid === "string" ? nextParams.popupTemplateUid.trim() : nextParams.popupTemplateUid;
13831
- if (popupTemplateUidProvided && (popupTemplateUid === void 0 || popupTemplateUid === null || popupTemplateUid === "")) {
13832
- delete nextParams.popupTemplateUid;
13833
- delete nextParams.popupTemplateContext;
13834
- delete nextParams.popupTemplateHasFilterByTk;
13835
- delete nextParams.popupTemplateHasSourceId;
13836
- delete nextParams.uid;
13837
- }
13838
- if (actionKey === "quickCreateAction") {
13839
- const hasRecordScopedTemplate = !!nextParams.popupTemplateHasFilterByTk || !!nextParams.popupTemplateHasSourceId || !import_lodash.default.isUndefined(nextParams.filterByTk) || !import_lodash.default.isUndefined(nextParams.sourceId) || !!String(nextParams.associationName || "").trim();
13840
- if (hasRecordScopedTemplate) {
13841
- delete nextParams.popupTemplateUid;
13842
- delete nextParams.popupTemplateContext;
13843
- delete nextParams.popupTemplateHasFilterByTk;
13844
- delete nextParams.popupTemplateHasSourceId;
13845
- delete nextParams.uid;
13846
- }
13847
- delete nextParams.associationName;
13848
- delete nextParams.filterByTk;
13849
- delete nextParams.sourceId;
13850
- }
13851
- return nextParams;
13852
- }
13853
- getCalendarPopupActionUse(actionKey) {
13854
- return actionKey === "quickCreateAction" ? "CalendarQuickCreateActionModel" : "CalendarEventViewActionModel";
14701
+ return (0, import_hidden_popup_calendar.normalizeCalendarPopupSettings)(actionKey, popupSettings);
13855
14702
  }
13856
- getCalendarPopupPropKey(actionKey) {
13857
- return actionKey === "quickCreateAction" ? "quickCreatePopupSettings" : "eventPopupSettings";
14703
+ getCalendarBlockResourceInit(blockNode) {
14704
+ return (0, import_hidden_popup_calendar.getCalendarBlockResourceInit)(blockNode);
13858
14705
  }
13859
- getCalendarPopupActionUid(calendarUid, actionKey) {
13860
- return `${calendarUid}-${actionKey}`;
14706
+ getCalendarPopupStoredSettings(blockNode, actionKey) {
14707
+ return (0, import_hidden_popup_calendar.getCalendarPopupStoredSettings)(blockNode, actionKey);
13861
14708
  }
13862
- getCalendarBlockResourceInit(blockNode) {
13863
- const resourceInit = import_lodash.default.cloneDeep(import_lodash.default.get(blockNode, ["stepParams", "resourceSettings", "init"]) || {});
13864
- if (resourceInit.collectionName && !resourceInit.dataSourceKey) {
13865
- resourceInit.dataSourceKey = "main";
13866
- }
13867
- return resourceInit;
14709
+ getCalendarPopupPropKey(actionKey) {
14710
+ return (0, import_hidden_popup_calendar.getCalendarPopupPropKey)(actionKey);
14711
+ }
14712
+ buildCalendarInitialStepParams(input) {
14713
+ return (0, import_hidden_popup_calendar.buildCalendarInitialStepParams)(input);
13868
14714
  }
13869
14715
  buildCalendarPopupOpenView(input) {
13870
- const actionUid = this.getCalendarPopupActionUid(input.blockNode.uid, input.actionKey);
13871
- const resourceInit = input.resourceInit || this.getCalendarBlockResourceInit(input.blockNode);
13872
- const defaults = (0, import_service_utils.buildDefinedPayload)({
13873
- mode: "drawer",
13874
- size: "medium",
13875
- pageModelClass: "ChildPageModel",
13876
- uid: actionUid,
13877
- collectionName: resourceInit.collectionName,
13878
- dataSourceKey: resourceInit.dataSourceKey || (resourceInit.collectionName ? "main" : void 0)
13879
- });
13880
- const current = this.normalizeCalendarPopupSettings(
13881
- input.actionKey,
13882
- import_lodash.default.get(input.blockNode, ["props", this.getCalendarPopupPropKey(input.actionKey)]) || {}
13883
- );
13884
- return (0, import_service_utils.buildDefinedPayload)({
13885
- ...defaults,
13886
- ...current,
13887
- uid: current.uid || defaults.uid,
13888
- collectionName: current.collectionName || defaults.collectionName,
13889
- dataSourceKey: current.dataSourceKey || defaults.dataSourceKey
13890
- });
14716
+ return (0, import_hidden_popup_calendar.buildCalendarPopupOpenView)(input);
14717
+ }
14718
+ mergeCalendarPopupSettings(actionKey, current, value) {
14719
+ return (0, import_hidden_popup_calendar.mergeCalendarPopupSettings)(actionKey, current, value);
14720
+ }
14721
+ stripCalendarPopupTargetSettingsForResourceChange(actionKey, popupSettings) {
14722
+ return (0, import_hidden_popup_calendar.stripCalendarPopupTargetSettingsForResourceChange)(actionKey, popupSettings);
13891
14723
  }
13892
14724
  async normalizeCalendarPopupConfigureValue(input) {
13893
- if (import_lodash.default.isUndefined(input.value)) {
13894
- return void 0;
13895
- }
13896
- if (import_lodash.default.isNull(input.value)) {
13897
- return {};
13898
- }
13899
- const actionUid = this.getCalendarPopupActionUid(input.blockUid, input.actionKey);
13900
- const normalized = await this.normalizeOpenView(input.actionName, input.value, {
13901
- transaction: input.transaction,
13902
- popupTemplateHostUid: actionUid,
13903
- popupActionContext: {
13904
- hasCurrentRecord: input.actionKey === "eventViewAction"
13905
- }
14725
+ return (0, import_hidden_popup_calendar.normalizeCalendarPopupConfigureValue)({
14726
+ ...input,
14727
+ normalizeOpenView: (actionName, value, options) => this.normalizeOpenView(actionName, value, options)
13906
14728
  });
13907
- return this.normalizeCalendarPopupSettings(input.actionKey, normalized || {});
14729
+ }
14730
+ normalizeCalendarInlineSettingsForConfigure(settings) {
14731
+ return (0, import_hidden_popup_calendar.normalizeCalendarInlineSettingsForConfigure)(settings);
14732
+ }
14733
+ omitHiddenPopupSettingsForConfigure(settings, type) {
14734
+ if (!import_lodash.default.isPlainObject(settings)) {
14735
+ return settings;
14736
+ }
14737
+ const omittedKeys = type === "calendar" ? ["quickCreatePopup", "eventPopup", "quickCreatePopupSettings", "eventPopupSettings"] : ["quickCreatePopup", "cardPopup", "quickCreatePopupSettings", "cardPopupSettings"];
14738
+ return import_lodash.default.omit(settings, omittedKeys);
14739
+ }
14740
+ resolveCalendarInitialPopupOverride(settings, primaryKey, legacyKey) {
14741
+ return (0, import_hidden_popup_calendar.resolveCalendarInitialPopupOverride)(settings, primaryKey, legacyKey);
14742
+ }
14743
+ resolveKanbanInitialPopupOverride(settings, primaryKey, legacyKey) {
14744
+ return (0, import_hidden_popup_kanban.resolveKanbanInitialPopupOverride)(settings, primaryKey, legacyKey);
13908
14745
  }
13909
14746
  buildCalendarInitialBlockProps(input) {
13910
14747
  const { collection, collectionName } = this.assertCalendarCollectionCompatible(
@@ -13912,7 +14749,7 @@ class FlowSurfacesService {
13912
14749
  input.resourceInit
13913
14750
  );
13914
14751
  const currentProps = import_lodash.default.cloneDeep(input.props || {});
13915
- return {
14752
+ const props = {
13916
14753
  ...currentProps,
13917
14754
  fieldNames: this.normalizeCalendarFieldNamesForCollection({
13918
14755
  actionName: input.actionName,
@@ -13925,259 +14762,83 @@ class FlowSurfacesService {
13925
14762
  enableQuickCreateEvent: typeof currentProps.enableQuickCreateEvent === "boolean" ? currentProps.enableQuickCreateEvent : true,
13926
14763
  weekStart: typeof currentProps.weekStart === "number" ? currentProps.weekStart : 1
13927
14764
  };
13928
- }
13929
- async ensureCalendarBlockPopupHosts(blockNode, transaction) {
13930
- var _a;
13931
- if (!(blockNode == null ? void 0 : blockNode.uid) || blockNode.use !== "CalendarBlockModel") {
13932
- return blockNode;
13933
- }
13934
- const resourceInit = this.getCalendarBlockResourceInit(blockNode);
13935
- let changed = false;
13936
- for (const actionKey of CALENDAR_POPUP_ACTION_KEYS) {
13937
- const existing = (0, import_service_utils.getSingleNodeSubModel)((_a = blockNode.subModels) == null ? void 0 : _a[actionKey]);
13938
- const expectedUid = this.getCalendarPopupActionUid(blockNode.uid, actionKey);
13939
- const expectedUse = this.getCalendarPopupActionUse(actionKey);
13940
- const openView = this.buildCalendarPopupOpenView({
13941
- blockNode,
13942
- actionKey,
13943
- resourceInit
13944
- });
13945
- const currentOpenView = this.resolvePopupHostOpenView(existing);
13946
- const shouldReplaceExisting = (existing == null ? void 0 : existing.uid) && existing.uid !== expectedUid;
13947
- const shouldUpsert = !(existing == null ? void 0 : existing.uid) || shouldReplaceExisting || existing.use !== expectedUse || !import_lodash.default.isEqual(currentOpenView, openView);
13948
- if (!shouldUpsert) {
13949
- continue;
13950
- }
13951
- if (shouldReplaceExisting) {
13952
- await this.removeNodeTreeWithBindings(existing.uid, transaction);
13953
- }
13954
- if ((existing == null ? void 0 : existing.uid) && existing.uid === expectedUid && !import_lodash.default.isEqual(currentOpenView, openView)) {
13955
- await this.reconcilePopupOpenViewTransition(expectedUid, currentOpenView, openView, transaction);
13956
- }
13957
- const nextActionNode = {
13958
- ...(existing == null ? void 0 : existing.uid) && existing.uid === expectedUid ? import_lodash.default.cloneDeep(existing) : {},
13959
- uid: expectedUid,
13960
- use: expectedUse,
13961
- stepParams: import_lodash.default.merge({}, (existing == null ? void 0 : existing.uid) === expectedUid ? import_lodash.default.cloneDeep(existing.stepParams || {}) : {}, {
13962
- popupSettings: {
13963
- openView
13964
- }
13965
- })
13966
- };
13967
- await this.repository.upsertModel(
13968
- {
13969
- parentId: blockNode.uid,
13970
- subKey: actionKey,
13971
- subType: "object",
13972
- ...nextActionNode
13973
- },
13974
- { transaction }
13975
- );
13976
- changed = true;
13977
- }
13978
- if (!changed) {
13979
- return blockNode;
13980
- }
13981
- return this.repository.findModelById(blockNode.uid, {
14765
+ delete props.quickCreatePopup;
14766
+ delete props.quickCreatePopupSettings;
14767
+ delete props.eventPopup;
14768
+ delete props.eventPopupSettings;
14769
+ return props;
14770
+ }
14771
+ async ensureCalendarBlockPopupHosts(blockNode, transaction, popupSettingsOverrides, options = {}) {
14772
+ return (0, import_hidden_popup_calendar.ensureCalendarBlockPopupHosts)(
14773
+ this.hiddenPopupRuntime,
14774
+ blockNode,
13982
14775
  transaction,
13983
- includeAsyncNode: true
13984
- });
14776
+ popupSettingsOverrides,
14777
+ options
14778
+ );
13985
14779
  }
13986
- async ensureCalendarBlockPopupHostsInTree(node, transaction) {
13987
- if (!node || typeof node !== "object") {
13988
- return node;
13989
- }
13990
- let current = node;
13991
- if (current.use === "CalendarBlockModel") {
13992
- current = await this.ensureCalendarBlockPopupHosts(current, transaction);
13993
- }
13994
- for (const [subKey, value] of Object.entries(current.subModels || {})) {
13995
- if (Array.isArray(value)) {
13996
- const nextItems = [];
13997
- let changed = false;
13998
- for (const item of value) {
13999
- const nextItem = await this.ensureCalendarBlockPopupHostsInTree(item, transaction);
14000
- nextItems.push(nextItem);
14001
- changed = changed || nextItem !== item;
14002
- }
14003
- if (changed) {
14004
- current.subModels[subKey] = nextItems;
14005
- }
14006
- continue;
14007
- }
14008
- const nextValue = await this.ensureCalendarBlockPopupHostsInTree(value, transaction);
14009
- if (nextValue !== value) {
14010
- current.subModels[subKey] = nextValue;
14011
- }
14012
- }
14013
- return current;
14780
+ projectCalendarBlockPopupHostsInTree(node) {
14781
+ return (0, import_hidden_popup_calendar.projectCalendarBlockPopupHostsInTree)(node);
14782
+ }
14783
+ async replaceKanbanStoredPopupSettings(blockNode, actionKey, popupSettings, transaction) {
14784
+ return (0, import_hidden_popup_kanban.replaceKanbanStoredPopupSettings)(
14785
+ this.hiddenPopupRuntime,
14786
+ blockNode,
14787
+ actionKey,
14788
+ popupSettings,
14789
+ transaction
14790
+ );
14014
14791
  }
14015
- projectCalendarBlockPopupHosts(node) {
14016
- var _a;
14017
- if (!node || typeof node !== "object") {
14018
- return node;
14019
- }
14020
- const current = node;
14021
- if (!(current == null ? void 0 : current.uid) || current.use !== "CalendarBlockModel") {
14022
- return node;
14023
- }
14024
- const resourceInit = this.getCalendarBlockResourceInit(current);
14025
- let nextSubModels = current.subModels;
14026
- let changed = false;
14027
- for (const actionKey of CALENDAR_POPUP_ACTION_KEYS) {
14028
- const existing = (0, import_service_utils.getSingleNodeSubModel)((_a = current.subModels) == null ? void 0 : _a[actionKey]);
14029
- const expectedUid = this.getCalendarPopupActionUid(current.uid, actionKey);
14030
- const expectedUse = this.getCalendarPopupActionUse(actionKey);
14031
- const openView = this.buildCalendarPopupOpenView({
14032
- blockNode: current,
14033
- actionKey,
14034
- resourceInit
14035
- });
14036
- const currentOpenView = this.resolvePopupHostOpenView(existing);
14037
- if ((existing == null ? void 0 : existing.uid) === expectedUid && existing.use === expectedUse && import_lodash.default.isEqual(currentOpenView, openView)) {
14038
- continue;
14039
- }
14040
- const nextActionNode = {
14041
- ...(existing == null ? void 0 : existing.uid) === expectedUid ? import_lodash.default.cloneDeep(existing) : {},
14042
- uid: expectedUid,
14043
- use: expectedUse,
14044
- stepParams: import_lodash.default.merge({}, (existing == null ? void 0 : existing.uid) === expectedUid ? import_lodash.default.cloneDeep(existing.stepParams || {}) : {}, {
14045
- popupSettings: {
14046
- openView
14047
- }
14048
- })
14049
- };
14050
- if (!changed) {
14051
- nextSubModels = {
14052
- ...current.subModels || {}
14053
- };
14054
- changed = true;
14055
- }
14056
- nextSubModels[actionKey] = nextActionNode;
14057
- }
14058
- if (!changed) {
14059
- return node;
14060
- }
14061
- return {
14062
- ...current,
14063
- subModels: nextSubModels
14064
- };
14792
+ async ensureKanbanBlockPopupHosts(blockNode, transaction, popupSettingsOverrides, options = {}) {
14793
+ return (0, import_hidden_popup_kanban.ensureKanbanBlockPopupHosts)(
14794
+ this.hiddenPopupRuntime,
14795
+ blockNode,
14796
+ transaction,
14797
+ popupSettingsOverrides,
14798
+ options
14799
+ );
14065
14800
  }
14066
- projectCalendarBlockPopupHostsInTree(node) {
14067
- if (!node || typeof node !== "object") {
14068
- return node;
14069
- }
14070
- let current = this.projectCalendarBlockPopupHosts(node);
14071
- let nextSubModels = current == null ? void 0 : current.subModels;
14072
- let changed = current !== node;
14073
- if (!nextSubModels || typeof nextSubModels !== "object") {
14074
- return current;
14075
- }
14076
- for (const [subKey, value] of Object.entries(nextSubModels)) {
14077
- if (Array.isArray(value)) {
14078
- const nextItems = [];
14079
- let itemsChanged = false;
14080
- for (const item of value) {
14081
- const nextItem = this.projectCalendarBlockPopupHostsInTree(item);
14082
- nextItems.push(nextItem);
14083
- itemsChanged = itemsChanged || nextItem !== item;
14084
- }
14085
- if (!itemsChanged) {
14086
- continue;
14087
- }
14088
- if (!changed) {
14089
- current = {
14090
- ...current,
14091
- subModels: {
14092
- ...nextSubModels
14093
- }
14094
- };
14095
- nextSubModels = current.subModels;
14096
- changed = true;
14097
- }
14098
- nextSubModels[subKey] = nextItems;
14099
- continue;
14100
- }
14101
- const nextValue = this.projectCalendarBlockPopupHostsInTree(value);
14102
- if (nextValue === value) {
14103
- continue;
14104
- }
14105
- if (!changed) {
14106
- current = {
14107
- ...current,
14108
- subModels: {
14109
- ...nextSubModels
14110
- }
14111
- };
14112
- nextSubModels = current.subModels;
14113
- changed = true;
14114
- }
14115
- nextSubModels[subKey] = nextValue;
14116
- }
14117
- return current;
14801
+ projectKanbanBlockPopupHostsInTree(node) {
14802
+ return (0, import_hidden_popup_kanban.projectKanbanBlockPopupHostsInTree)(node);
14118
14803
  }
14119
- async ensureKanbanBlockPopupHosts(blockNode, transaction) {
14120
- var _a;
14121
- if (!(blockNode == null ? void 0 : blockNode.uid) || blockNode.use !== "KanbanBlockModel") {
14122
- return blockNode;
14804
+ resolveManagedPopupTargetUidForHiddenPopupBackfill(hostNode) {
14805
+ const openView = this.resolvePopupHostOpenView(hostNode);
14806
+ const externalPopupHostUid = this.resolveExternalPopupHostUid(hostNode == null ? void 0 : hostNode.uid, openView);
14807
+ if (!externalPopupHostUid) {
14808
+ return void 0;
14123
14809
  }
14124
- const resourceInit = this.getKanbanBlockResourceInit(blockNode);
14125
- let changed = false;
14126
- for (const actionKey of KANBAN_POPUP_ACTION_KEYS) {
14127
- const existing = (0, import_service_utils.getSingleNodeSubModel)((_a = blockNode.subModels) == null ? void 0 : _a[actionKey]);
14128
- const expectedUid = this.getKanbanPopupActionUid(blockNode.uid, actionKey);
14129
- const expectedUse = this.getKanbanPopupActionUse(actionKey);
14130
- const openView = this.buildKanbanPopupOpenView({
14131
- blockNode,
14132
- actionKey,
14133
- resourceInit
14134
- });
14135
- const currentOpenView = this.resolvePopupHostOpenView(existing);
14136
- const shouldReplaceExisting = (existing == null ? void 0 : existing.uid) && existing.uid !== expectedUid;
14137
- const shouldUpsert = !(existing == null ? void 0 : existing.uid) || shouldReplaceExisting || existing.use !== expectedUse || !import_lodash.default.isEqual(currentOpenView, openView);
14138
- if (!shouldUpsert) {
14139
- continue;
14140
- }
14141
- if (shouldReplaceExisting) {
14142
- await this.removeNodeTreeWithBindings(existing.uid, transaction);
14143
- }
14144
- if ((existing == null ? void 0 : existing.uid) && existing.uid === expectedUid && !import_lodash.default.isEqual(currentOpenView, openView)) {
14145
- await this.reconcilePopupOpenViewTransition(expectedUid, currentOpenView, openView, transaction);
14146
- }
14147
- const nextActionNode = {
14148
- ...(existing == null ? void 0 : existing.uid) && existing.uid === expectedUid ? import_lodash.default.cloneDeep(existing) : {},
14149
- uid: expectedUid,
14150
- use: expectedUse,
14151
- stepParams: import_lodash.default.merge({}, (existing == null ? void 0 : existing.uid) === expectedUid ? import_lodash.default.cloneDeep(existing.stepParams || {}) : {}, {
14152
- popupSettings: {
14153
- openView
14154
- }
14155
- })
14156
- };
14157
- await this.repository.upsertModel(
14158
- {
14159
- parentId: blockNode.uid,
14160
- subKey: actionKey,
14161
- subType: "object",
14162
- ...nextActionNode
14163
- },
14164
- { transaction }
14165
- );
14166
- changed = true;
14810
+ if ((openView == null ? void 0 : openView.popupTemplateContext) || String((openView == null ? void 0 : openView.popupTemplateUid) || "").trim()) {
14811
+ return externalPopupHostUid;
14167
14812
  }
14168
- if (!changed) {
14169
- return blockNode;
14813
+ return void 0;
14814
+ }
14815
+ async ensureHiddenPopupBlockHostsInManagedPopupTarget(hostNode, transaction, visitedPopupTargetUids = /* @__PURE__ */ new Set()) {
14816
+ const popupTargetUid = this.resolveManagedPopupTargetUidForHiddenPopupBackfill(hostNode);
14817
+ if (!popupTargetUid || visitedPopupTargetUids.has(popupTargetUid)) {
14818
+ return;
14170
14819
  }
14171
- return this.repository.findModelById(blockNode.uid, {
14820
+ visitedPopupTargetUids.add(popupTargetUid);
14821
+ const popupTarget = await this.repository.findModelById(popupTargetUid, {
14172
14822
  transaction,
14173
14823
  includeAsyncNode: true
14824
+ }).catch(() => null);
14825
+ if (!(popupTarget == null ? void 0 : popupTarget.uid)) {
14826
+ return;
14827
+ }
14828
+ await this.ensureHiddenPopupBlockHostsInTree(popupTarget, transaction, {
14829
+ ensureManagedPopupTemplateTargets: true,
14830
+ visitedPopupTargetUids
14174
14831
  });
14175
14832
  }
14176
- async ensureKanbanBlockPopupHostsInTree(node, transaction) {
14833
+ async ensureHiddenPopupBlockHostsInTree(node, transaction, options = {}) {
14177
14834
  if (!node || typeof node !== "object") {
14178
14835
  return node;
14179
14836
  }
14837
+ const visitedPopupTargetUids = options.visitedPopupTargetUids || /* @__PURE__ */ new Set();
14180
14838
  let current = node;
14839
+ if (current.use === "CalendarBlockModel") {
14840
+ current = await this.ensureCalendarBlockPopupHosts(current, transaction);
14841
+ }
14181
14842
  if (current.use === "KanbanBlockModel") {
14182
14843
  current = await this.ensureKanbanBlockPopupHosts(current, transaction);
14183
14844
  }
@@ -14186,7 +14847,10 @@ class FlowSurfacesService {
14186
14847
  const nextItems = [];
14187
14848
  let changed = false;
14188
14849
  for (const item of value) {
14189
- const nextItem = await this.ensureKanbanBlockPopupHostsInTree(item, transaction);
14850
+ const nextItem = await this.ensureHiddenPopupBlockHostsInTree(item, transaction, {
14851
+ ...options,
14852
+ visitedPopupTargetUids
14853
+ });
14190
14854
  nextItems.push(nextItem);
14191
14855
  changed = changed || nextItem !== item;
14192
14856
  }
@@ -14195,114 +14859,16 @@ class FlowSurfacesService {
14195
14859
  }
14196
14860
  continue;
14197
14861
  }
14198
- const nextValue = await this.ensureKanbanBlockPopupHostsInTree(value, transaction);
14862
+ const nextValue = await this.ensureHiddenPopupBlockHostsInTree(value, transaction, {
14863
+ ...options,
14864
+ visitedPopupTargetUids
14865
+ });
14199
14866
  if (nextValue !== value) {
14200
14867
  current.subModels[subKey] = nextValue;
14201
14868
  }
14202
14869
  }
14203
- return current;
14204
- }
14205
- projectKanbanBlockPopupHosts(node) {
14206
- var _a;
14207
- if (!node || typeof node !== "object") {
14208
- return node;
14209
- }
14210
- const current = node;
14211
- if (!(current == null ? void 0 : current.uid) || current.use !== "KanbanBlockModel") {
14212
- return node;
14213
- }
14214
- const resourceInit = this.getKanbanBlockResourceInit(current);
14215
- let nextSubModels = current.subModels;
14216
- let changed = false;
14217
- for (const actionKey of KANBAN_POPUP_ACTION_KEYS) {
14218
- const existing = (0, import_service_utils.getSingleNodeSubModel)((_a = current.subModels) == null ? void 0 : _a[actionKey]);
14219
- const expectedUid = this.getKanbanPopupActionUid(current.uid, actionKey);
14220
- const expectedUse = this.getKanbanPopupActionUse(actionKey);
14221
- const openView = this.buildKanbanPopupOpenView({
14222
- blockNode: current,
14223
- actionKey,
14224
- resourceInit
14225
- });
14226
- const currentOpenView = this.resolvePopupHostOpenView(existing);
14227
- if ((existing == null ? void 0 : existing.uid) === expectedUid && existing.use === expectedUse && import_lodash.default.isEqual(currentOpenView, openView)) {
14228
- continue;
14229
- }
14230
- const nextActionNode = {
14231
- ...(existing == null ? void 0 : existing.uid) === expectedUid ? import_lodash.default.cloneDeep(existing) : {},
14232
- uid: expectedUid,
14233
- use: expectedUse,
14234
- stepParams: import_lodash.default.merge({}, (existing == null ? void 0 : existing.uid) === expectedUid ? import_lodash.default.cloneDeep(existing.stepParams || {}) : {}, {
14235
- popupSettings: {
14236
- openView
14237
- }
14238
- })
14239
- };
14240
- if (!changed) {
14241
- nextSubModels = {
14242
- ...current.subModels || {}
14243
- };
14244
- changed = true;
14245
- }
14246
- nextSubModels[actionKey] = nextActionNode;
14247
- }
14248
- if (!changed) {
14249
- return node;
14250
- }
14251
- return {
14252
- ...current,
14253
- subModels: nextSubModels
14254
- };
14255
- }
14256
- projectKanbanBlockPopupHostsInTree(node) {
14257
- if (!node || typeof node !== "object") {
14258
- return node;
14259
- }
14260
- let current = this.projectKanbanBlockPopupHosts(node);
14261
- let nextSubModels = current == null ? void 0 : current.subModels;
14262
- let changed = current !== node;
14263
- if (!nextSubModels || typeof nextSubModels !== "object") {
14264
- return current;
14265
- }
14266
- for (const [subKey, value] of Object.entries(nextSubModels)) {
14267
- if (Array.isArray(value)) {
14268
- const nextItems = [];
14269
- let itemsChanged = false;
14270
- for (const item of value) {
14271
- const nextItem = this.projectKanbanBlockPopupHostsInTree(item);
14272
- nextItems.push(nextItem);
14273
- itemsChanged = itemsChanged || nextItem !== item;
14274
- }
14275
- if (!itemsChanged) {
14276
- continue;
14277
- }
14278
- if (!changed) {
14279
- current = {
14280
- ...current,
14281
- subModels: {
14282
- ...nextSubModels
14283
- }
14284
- };
14285
- nextSubModels = current.subModels;
14286
- changed = true;
14287
- }
14288
- nextSubModels[subKey] = nextItems;
14289
- continue;
14290
- }
14291
- const nextValue = this.projectKanbanBlockPopupHostsInTree(value);
14292
- if (nextValue === value) {
14293
- continue;
14294
- }
14295
- if (!changed) {
14296
- current = {
14297
- ...current,
14298
- subModels: {
14299
- ...nextSubModels
14300
- }
14301
- };
14302
- nextSubModels = current.subModels;
14303
- changed = true;
14304
- }
14305
- nextSubModels[subKey] = nextValue;
14870
+ if (options.ensureManagedPopupTemplateTargets) {
14871
+ await this.ensureHiddenPopupBlockHostsInManagedPopupTarget(current, transaction, visitedPopupTargetUids);
14306
14872
  }
14307
14873
  return current;
14308
14874
  }
@@ -14839,6 +15405,31 @@ class FlowSurfacesService {
14839
15405
  usesAssociationValueBinding: false
14840
15406
  };
14841
15407
  }
15408
+ collectionFieldHasRequiredValidation(field) {
15409
+ var _a, _b, _c;
15410
+ const rules = [
15411
+ ...import_lodash.default.castArray(((_a = field == null ? void 0 : field.validation) == null ? void 0 : _a.rules) || []),
15412
+ ...import_lodash.default.castArray(((_c = (_b = field == null ? void 0 : field.options) == null ? void 0 : _b.validation) == null ? void 0 : _c.rules) || [])
15413
+ ];
15414
+ return rules.some((rule) => String((rule == null ? void 0 : rule.name) || "").trim() === "required");
15415
+ }
15416
+ buildRequiredCollectionFieldFormWrapperDefaults(input) {
15417
+ if (!REQUIRED_COLLECTION_FIELD_FORM_WRAPPER_USES.has(input.wrapperUse || "") || !this.collectionFieldHasRequiredValidation(input.field)) {
15418
+ return {};
15419
+ }
15420
+ return {
15421
+ props: {
15422
+ required: true
15423
+ },
15424
+ stepParams: {
15425
+ editItemSettings: {
15426
+ required: {
15427
+ required: true
15428
+ }
15429
+ }
15430
+ }
15431
+ };
15432
+ }
14842
15433
  getCollectionFieldOrBadRequest(collection, fieldPath, context) {
14843
15434
  const field = (0, import_service_helpers.resolveFieldFromCollection)(collection, fieldPath);
14844
15435
  if (!field) {
@@ -15566,10 +16157,9 @@ class FlowSurfacesService {
15566
16157
  if (options.persistCalendarPopupHosts === false) {
15567
16158
  return this.projectKanbanBlockPopupHostsInTree(this.projectCalendarBlockPopupHostsInTree(node));
15568
16159
  }
15569
- return this.ensureKanbanBlockPopupHostsInTree(
15570
- await this.ensureCalendarBlockPopupHostsInTree(node, transaction),
15571
- transaction
15572
- );
16160
+ return this.ensureHiddenPopupBlockHostsInTree(node, transaction, {
16161
+ ensureManagedPopupTemplateTargets: options.ensureManagedPopupTemplateTargets === true
16162
+ });
15573
16163
  }
15574
16164
  normalizePopupTreeShape(node) {
15575
16165
  if (!node || typeof node !== "object") {