@acorex/platform 20.7.7 → 20.7.9

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.
@@ -1481,6 +1481,10 @@ class DialogContainerBuilder {
1481
1481
  }
1482
1482
  return this;
1483
1483
  }
1484
+ onAction(handler) {
1485
+ (this.dialogState.dialogOptions ??= {}).onAction = handler;
1486
+ return this;
1487
+ }
1484
1488
  addCustomAction(action) {
1485
1489
  // Add to actions based on position
1486
1490
  const position = action.position || 'suffix';
@@ -1538,6 +1542,7 @@ class DialogContainerBuilder {
1538
1542
  context: initialContext,
1539
1543
  definition: dialogNode,
1540
1544
  actions: this.dialogState.actions,
1545
+ onAction: this.dialogState.dialogOptions?.onAction,
1541
1546
  };
1542
1547
  // The Promise resolves when user clicks an action button
1543
1548
  return new Promise(async (resolve) => {
@@ -1550,7 +1555,6 @@ class DialogContainerBuilder {
1550
1555
  data: {
1551
1556
  config: dialogConfig,
1552
1557
  callBack: (result) => {
1553
- // Resolve with the dialog reference when user clicks an action
1554
1558
  resolve(result);
1555
1559
  },
1556
1560
  },
@@ -2249,16 +2253,39 @@ class AXPDialogRendererComponent extends AXBasePageComponent {
2249
2253
  return;
2250
2254
  }
2251
2255
  }
2256
+ const context = this.context();
2257
+ const onAction = this.config?.onAction;
2258
+ if (onAction) {
2259
+ const dialogRef = {
2260
+ close: (res) => this.close(res),
2261
+ context: () => this.context(),
2262
+ action: () => cmd ?? undefined,
2263
+ setLoading: (loading) => this.isDialogLoading.set(loading),
2264
+ };
2265
+ try {
2266
+ this.isDialogLoading.set(true);
2267
+ const result = await Promise.resolve(onAction(dialogRef));
2268
+ this.callBack(result);
2269
+ this.close(result);
2270
+ }
2271
+ catch {
2272
+ // Handler threw: stay open for retry, actions remain clickable
2273
+ }
2274
+ finally {
2275
+ this.isDialogLoading.set(false);
2276
+ }
2277
+ return;
2278
+ }
2252
2279
  // Fallback: treat as regular dialog action (cancel/confirm/custom)
2253
- const result = { context: this.context(), action: cmd };
2280
+ const result = { context, action: cmd };
2254
2281
  this.dialogResult = result;
2255
2282
  if (this.data) {
2256
2283
  this.data.context = result.context;
2257
2284
  this.data.action = result.action;
2258
2285
  }
2259
2286
  this.callBack({
2260
- close: (result) => {
2261
- this.close(result);
2287
+ close: (res) => {
2288
+ this.close(res);
2262
2289
  },
2263
2290
  context: () => this.context(),
2264
2291
  action: () => result.action,