You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/dialog-api.md
+57-1Lines changed: 57 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -230,6 +230,7 @@ To show a progress dialog, call the method `studioPro.ui.dialogs.showProgressDia
To see how `resolveImmediatelyOnCancel` influences the final state of the result, let's use the example above modified to set a value twice for each step into a dictionary called `state`. If `resolveImmediatelyOnCancel` is omitted when calling `showProgressDialog` (which is the default behavior), then the cancelled step will finish executing and the final result will have a value of `2` for the dictionary value set at that step.
320
+
If however, the developer needs the cancelled step to not influence the final result, they should pass `true` for `resolveImmediatelyOnCancel`, and once the user cancels the progress dialog, the `state` dictionary will contain a value of `1` instead of `2` for the cancelled step.
321
+
322
+
```typescript
323
+
const state: { [step:string]:number } = {};
324
+
325
+
const step1:ProgressDialogStep= {
326
+
title: "Step 1",
327
+
description: "Executing Step 1",
328
+
action: async () => {
329
+
// perform action
330
+
state["step1"] =1;
331
+
// other things happening...
332
+
awaitsleep(5000);
333
+
state["step1"] =2;
334
+
returntrue;
335
+
}
336
+
};
337
+
338
+
const step2:ProgressDialogStep= {
339
+
title: "Step 2",
340
+
description: "Executing Step 2",
341
+
action: async () => {
342
+
// perform action
343
+
state["step2"] =1;
344
+
// other things happening...
345
+
awaitsleep(5000);
346
+
state["step2"] =2;
347
+
348
+
returntrue;
349
+
}
350
+
};
351
+
352
+
const step3:ProgressDialogStep= {
353
+
title: "Step 3",
354
+
description: "Executing Step 3",
355
+
action: async () => {
356
+
// perform action
357
+
state["step3"] =1;
358
+
// other things happening...
359
+
awaitsleep(5000);
360
+
state["step3"] =2;
361
+
returntrue;
362
+
}
363
+
};
364
+
365
+
const resolveImmediatelyOnCancel =true;
366
+
const result =awaitstudioPro.ui.dialogs.showProgressDialog("Cancel This Progress", [step1, step2, step3], resolveImmediatelyOnCancel);
367
+
368
+
if (result.result==="Success") awaitstudioPro.ui.messageBoxes.show("info", "Process completed successfully");
369
+
if (result.result==="UserCancelled") awaitstudioPro.ui.messageBoxes.show("info", "Process was cancelled. Result: "+JSON.stringify(state));
370
+
```
371
+
316
372
Mendix recommends wrapping your step action body in a `try/catch` block so you can control the error that is returned to the user:
0 commit comments