mirror of
https://github.com/home-assistant/frontend.git
synced 2025-06-24 02:56:34 +00:00
Migrate dialog-box to ha-dialog (#6140)
This commit is contained in:
parent
26a87e9280
commit
cda6310373
@ -1,5 +1,4 @@
|
|||||||
import "@material/mwc-button/mwc-button";
|
import "@material/mwc-button/mwc-button";
|
||||||
import "@polymer/paper-dialog-scrollable/paper-dialog-scrollable";
|
|
||||||
import "@polymer/paper-input/paper-input";
|
import "@polymer/paper-input/paper-input";
|
||||||
import {
|
import {
|
||||||
css,
|
css,
|
||||||
@ -11,7 +10,7 @@ import {
|
|||||||
TemplateResult,
|
TemplateResult,
|
||||||
} from "lit-element";
|
} from "lit-element";
|
||||||
import { classMap } from "lit-html/directives/class-map";
|
import { classMap } from "lit-html/directives/class-map";
|
||||||
import "../../components/dialog/ha-paper-dialog";
|
import "../../components/ha-dialog";
|
||||||
import "../../components/ha-switch";
|
import "../../components/ha-switch";
|
||||||
import { PolymerChangedEvent } from "../../polymer-types";
|
import { PolymerChangedEvent } from "../../polymer-types";
|
||||||
import { haStyleDialog } from "../../resources/styles";
|
import { haStyleDialog } from "../../resources/styles";
|
||||||
@ -41,21 +40,17 @@ class DialogBox extends LitElement {
|
|||||||
const confirmPrompt = this._params.confirmation || this._params.prompt;
|
const confirmPrompt = this._params.confirmation || this._params.prompt;
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<ha-paper-dialog
|
<ha-dialog
|
||||||
with-backdrop
|
open
|
||||||
opened
|
scrimClickAction
|
||||||
modal
|
escapeKeyAction
|
||||||
@opened-changed="${this._openedChanged}"
|
@close=${this._close}
|
||||||
|
.heading=${this._params.title
|
||||||
|
? this._params.title
|
||||||
|
: this._params.confirmation &&
|
||||||
|
this.hass.localize("ui.dialogs.generic.default_confirmation_title")}
|
||||||
>
|
>
|
||||||
<h2>
|
<div>
|
||||||
${this._params.title
|
|
||||||
? this._params.title
|
|
||||||
: this._params.confirmation &&
|
|
||||||
this.hass.localize(
|
|
||||||
"ui.dialogs.generic.default_confirmation_title"
|
|
||||||
)}
|
|
||||||
</h2>
|
|
||||||
<paper-dialog-scrollable>
|
|
||||||
${this._params.text
|
${this._params.text
|
||||||
? html`
|
? html`
|
||||||
<p
|
<p
|
||||||
@ -83,23 +78,21 @@ class DialogBox extends LitElement {
|
|||||||
></paper-input>
|
></paper-input>
|
||||||
`
|
`
|
||||||
: ""}
|
: ""}
|
||||||
</paper-dialog-scrollable>
|
|
||||||
<div class="paper-dialog-buttons">
|
|
||||||
${confirmPrompt &&
|
|
||||||
html`
|
|
||||||
<mwc-button @click="${this._dismiss}">
|
|
||||||
${this._params.dismissText
|
|
||||||
? this._params.dismissText
|
|
||||||
: this.hass.localize("ui.dialogs.generic.cancel")}
|
|
||||||
</mwc-button>
|
|
||||||
`}
|
|
||||||
<mwc-button @click="${this._confirm}">
|
|
||||||
${this._params.confirmText
|
|
||||||
? this._params.confirmText
|
|
||||||
: this.hass.localize("ui.dialogs.generic.ok")}
|
|
||||||
</mwc-button>
|
|
||||||
</div>
|
</div>
|
||||||
</ha-paper-dialog>
|
${confirmPrompt &&
|
||||||
|
html`
|
||||||
|
<mwc-button @click=${this._dismiss} slot="secondaryAction">
|
||||||
|
${this._params.dismissText
|
||||||
|
? this._params.dismissText
|
||||||
|
: this.hass.localize("ui.dialogs.generic.cancel")}
|
||||||
|
</mwc-button>
|
||||||
|
`}
|
||||||
|
<mwc-button @click=${this._confirm} slot="primaryAction">
|
||||||
|
${this._params.confirmText
|
||||||
|
? this._params.confirmText
|
||||||
|
: this.hass.localize("ui.dialogs.generic.ok")}
|
||||||
|
</mwc-button>
|
||||||
|
</ha-dialog>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,10 +120,8 @@ class DialogBox extends LitElement {
|
|||||||
this._dismiss();
|
this._dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
private _openedChanged(ev: PolymerChangedEvent<boolean>): void {
|
private _close(): void {
|
||||||
if (!(ev.detail as any).value) {
|
this._params = undefined;
|
||||||
this._params = undefined;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static get styles(): CSSResult[] {
|
static get styles(): CSSResult[] {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user