Skip to content

Commit beef010

Browse files
committed
Refine "Modals" documentation: updated confirm dialog behavior and usage examples.
1 parent 84daace commit beef010

File tree

2 files changed

+38
-32
lines changed

2 files changed

+38
-32
lines changed

16/umbraco-cms/customizing/extending-overview/extension-types/modals/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ description: >-
88

99
## **Modal Types**
1010

11-
The Dialog modal appears in the middle of the screen and the Sidebar Modal slides in from the right.
11+
The Dialog modal appears in the middle of the screen, and the Sidebar Modal slides in from the right.
1212

1313
## Open a Modal
1414

16/umbraco-cms/customizing/extending-overview/extension-types/modals/confirm-dialog.md

Lines changed: 37 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,52 @@
11
---
2-
description: Ask the user for confirmation
2+
description: Present a dialog to ask the user for confirmation.
33
---
44

55
# Confirm Dialog
66

7-
{% hint style="warning" %}
8-
This page is a work in progress and may undergo further revisions, updates, or amendments. The information contained herein is subject to change without notice.
9-
{% endhint %}
7+
Confirmation dialogs are used to ask the user for confirmation to complete some action, and are presented as a
8+
center-aligned modal in the backoffice.
109

11-
This example shows how to open a confirm dialog. The `UMB_CONFIRM_MODAL` is a token that represents the confirm dialog. The `open` method takes the token and an object with the data for the confirm dialog. The `onSubmit` method returns a promise that resolves when the user confirms the dialog and rejects when the user cancels the dialog.
10+
Extension authors do not need to register the dialog in their extension's manifest, instead these dialogs are opened by
11+
importing and calling the `umbOpenModal` function.
1212

13-
The confirm modal itself is built-in and does not need to be registered in the extension registry.
14-
15-
The modal token describes the options that you can pass to the modal. The confirm modal token has the following properties:
13+
Extension authors can customize the dialog with several configuration options, such as the headline, body content,
14+
colors, and button labels.
1615

1716
* `headline` - The headline of the modal.
1817
* `content` - The content of the modal, which can be a TemplateResult or a string.
19-
* `color` - (Optional) The color of the modal. This can be `positive` or `danger`.
20-
* `confirmLabel` - (Optional) The label of the confirm button.
18+
* `color` - (Optional) The color of the modal, can be `positive` or `danger`.
19+
* `confirmLabel` - (Optional) The label of the confirmation button.
20+
* `cancelLabel` - (Optional) The label of the cancel button.
21+
22+
To see all properties of the `UMB_CONFIRM_MODAL` token, see the [API reference](https://apidocs.umbraco.com/v16/ui-api/interfaces/packages_core_modal.UmbConfirmModalData.html).
23+
24+
The `onSubmit` method returns a promise that resolves when the user confirms the dialog, and rejects when the user
25+
cancels the dialog.
2126

2227
## Basic Usage
2328

2429
{% code title="my-element.ts" %}
2530
```typescript
26-
import { html, LitElement, customElement } from "@umbraco-cms/backoffice/external/lit";
27-
import { UmbElementMixin } from '@umbraco-cms/backoffice/element-api';
28-
import { umbOpenModal, UMB_CONFIRM_MODAL } from '@umbraco-cms/backoffice/modal';
29-
30-
@customElement('my-element')
31-
export class MyElement extends UmbElementMixin(LitElement) {
31+
import {
32+
html,
33+
LitElement,
34+
customElement,
35+
} from "@umbraco-cms/backoffice/external/lit";
36+
import { UmbElementMixin } from "@umbraco-cms/backoffice/element-api";
37+
import { umbOpenModal, UMB_CONFIRM_MODAL } from "@umbraco-cms/backoffice/modal";
3238

39+
@customElement("my-confirmation-modal")
40+
export class MyConfirmationModal extends UmbElementMixin(LitElement) {
3341
#onRequestDisable() {
34-
const modalContext = umbOpenModal(
35-
this, UMB_CONFIRM_MODAL,
36-
{
37-
data: {
38-
headline: this.localize.term("actions_disable"),
39-
content: this.localize.term("defaultdialogs_confirmdisable"),
40-
color: "danger",
41-
confirmLabel: this.localize.term("actions_disable"),
42-
}
43-
}
44-
)
42+
umbOpenModal(this, UMB_CONFIRM_MODAL, {
43+
data: {
44+
headline: this.localize.term("actions_disable"),
45+
content: this.localize.term("defaultdialogs_confirmdisable"),
46+
color: "danger",
47+
confirmLabel: this.localize.term("actions_disable"),
48+
},
49+
})
4550
.then(() => {
4651
console.log("User has approved");
4752
})
@@ -52,10 +57,11 @@ export class MyElement extends UmbElementMixin(LitElement) {
5257

5358
render() {
5459
return html`<uui-button
55-
look="primary"
56-
color="danger"
57-
@click=${this.#onRequestDisable}
58-
label=${this.localize.term("actions_disable")}></uui-button>`;
60+
look="primary"
61+
color="danger"
62+
@click=${this.#onRequestDisable}
63+
label=${this.localize.term("actions_disable")}
64+
></uui-button>`;
5965
}
6066
}
6167
```

0 commit comments

Comments
 (0)