-
Notifications
You must be signed in to change notification settings - Fork 811
Confirm Dialog Updates #7327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Confirm Dialog Updates #7327
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
beef010
Refine "Modals" documentation: updated confirm dialog behavior and usβ¦
bszyman edd44f6
Refine "Confirm Dialog" documentation: adjusted phrasing for configurβ¦
bszyman 0678572
Clarify default button color of modal.
bszyman efc503a
Fixing soft-wrap/text formatting
bszyman d1fea2f
Simplified code example
nielslyngsoe e8fd5aa
Merge remote-tracking branch 'umbraco/main' into confirm-dialog
nielslyngsoe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
...aco-cms/customizing/extending-overview/extension-types/modals/confirm-dialog.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| --- | ||
| description: Ask the user for confirmation | ||
| --- | ||
|
|
||
| # Confirm Dialog | ||
|
|
||
| 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. | ||
|
|
||
| The confirm modal itself is built-in and does not need to be registered in the extension registry. | ||
|
|
||
| The modal token describes the options that you can pass to the modal. The confirm modal token has the following properties: | ||
|
|
||
| * `headline` - The headline of the modal. | ||
| * `content` - The content of the modal, which can be a TemplateResult or a string. | ||
| * `color` - (Optional) The color of the modal. This can be `positive` or `danger`. | ||
| * `confirmLabel` - (Optional) The label of the confirm button. | ||
|
|
||
| ## Basic Usage | ||
|
|
||
| {% code title="my-element.ts" %} | ||
| ```typescript | ||
| import { html, LitElement, customElement } from "@umbraco-cms/backoffice/external/lit"; | ||
| import { UmbElementMixin } from '@umbraco-cms/backoffice/element-api'; | ||
| import { UMB_MODAL_MANAGER_CONTEXT, UMB_CONFIRM_MODAL } from '@umbraco-cms/backoffice/modal'; | ||
|
|
||
| @customElement('my-element') | ||
| export class MyElement extends UmbElementMixin(LitElement) { | ||
|
|
||
|
|
||
| async #onRequestDisable() { | ||
| const context = await this.getContext(UMB_MODAL_MANAGER_CONTEXT) | ||
|
|
||
| const modal = context?.open( | ||
| this, UMB_CONFIRM_MODAL, | ||
| { | ||
| data: { | ||
| headline: `#actions_disable`, | ||
| content: `#defaultdialogs_confirmdisable`, | ||
| color: "danger", | ||
| confirmLabel: "Disable", | ||
| } | ||
| } | ||
| ); | ||
|
|
||
| modal?.onSubmit() | ||
| .then(() => { | ||
| console.log("User has approved"); | ||
| }) | ||
| .catch(() => { | ||
| console.log("User has rejected"); | ||
| }); | ||
| } | ||
|
|
||
| render() { | ||
| return html`<uui-button | ||
| look="primary" | ||
| color="danger" | ||
| @click=${this.#onRequestDisable} | ||
| label=${this.localize.term("actions_disable")}></uui-button>`; | ||
| } | ||
| } | ||
| ``` | ||
| {% endcode %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.