mirror of
https://github.com/home-assistant/frontend.git
synced 2025-12-20 10:48:44 +00:00
Migrate dialog-areas-floors-order to ha-wa-dialog (#28424)
* Migrate dialog-areas-floors-order.ts from ha-md-dialog to ha-wa-dialog * Fix saving * Remove render nothing if dialog false * Remove custom width
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { mdiClose, mdiDragHorizontalVariant, mdiTextureBox } from "@mdi/js";
|
import { mdiDragHorizontalVariant, mdiTextureBox } from "@mdi/js";
|
||||||
import type { CSSResultGroup } from "lit";
|
import type { CSSResultGroup } from "lit";
|
||||||
import { LitElement, css, html, nothing } from "lit";
|
import { LitElement, css, html, nothing } from "lit";
|
||||||
import { customElement, property, query, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { repeat } from "lit/directives/repeat";
|
import { repeat } from "lit/directives/repeat";
|
||||||
import {
|
import {
|
||||||
type AreasFloorHierarchy,
|
type AreasFloorHierarchy,
|
||||||
@@ -11,12 +11,10 @@ import {
|
|||||||
} from "../../../common/areas/areas-floor-hierarchy";
|
} from "../../../common/areas/areas-floor-hierarchy";
|
||||||
import { fireEvent } from "../../../common/dom/fire_event";
|
import { fireEvent } from "../../../common/dom/fire_event";
|
||||||
import "../../../components/ha-button";
|
import "../../../components/ha-button";
|
||||||
import "../../../components/ha-dialog-header";
|
import "../../../components/ha-dialog-footer";
|
||||||
import "../../../components/ha-floor-icon";
|
import "../../../components/ha-floor-icon";
|
||||||
import "../../../components/ha-icon";
|
import "../../../components/ha-icon";
|
||||||
import "../../../components/ha-icon-button";
|
import "../../../components/ha-wa-dialog";
|
||||||
import "../../../components/ha-md-dialog";
|
|
||||||
import type { HaMdDialog } from "../../../components/ha-md-dialog";
|
|
||||||
import "../../../components/ha-md-list";
|
import "../../../components/ha-md-list";
|
||||||
import "../../../components/ha-md-list-item";
|
import "../../../components/ha-md-list-item";
|
||||||
import "../../../components/ha-sortable";
|
import "../../../components/ha-sortable";
|
||||||
@@ -49,8 +47,6 @@ class DialogAreasFloorsOrder extends LitElement {
|
|||||||
|
|
||||||
@state() private _saving = false;
|
@state() private _saving = false;
|
||||||
|
|
||||||
@query("ha-md-dialog") private _dialog?: HaMdDialog;
|
|
||||||
|
|
||||||
public async showDialog(
|
public async showDialog(
|
||||||
_params: AreasFloorsOrderDialogParams
|
_params: AreasFloorsOrderDialogParams
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
@@ -66,7 +62,8 @@ class DialogAreasFloorsOrder extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public closeDialog(): void {
|
public closeDialog(): void {
|
||||||
this._dialog?.close();
|
this._saving = false;
|
||||||
|
this._open = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _dialogClosed(): void {
|
private _dialogClosed(): void {
|
||||||
@@ -77,7 +74,7 @@ class DialogAreasFloorsOrder extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
if (!this._open || !this._hierarchy) {
|
if (!this._hierarchy) {
|
||||||
return nothing;
|
return nothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,17 +86,13 @@ class DialogAreasFloorsOrder extends LitElement {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<ha-md-dialog open @closed=${this._dialogClosed}>
|
<ha-wa-dialog
|
||||||
<ha-dialog-header slot="headline">
|
.hass=${this.hass}
|
||||||
<ha-icon-button
|
.open=${this._open}
|
||||||
slot="navigationIcon"
|
header-title=${dialogTitle}
|
||||||
.label=${this.hass.localize("ui.common.close")}
|
@closed=${this._dialogClosed}
|
||||||
.path=${mdiClose}
|
>
|
||||||
@click=${this.closeDialog}
|
<div class="content">
|
||||||
></ha-icon-button>
|
|
||||||
<span slot="title" .title=${dialogTitle}>${dialogTitle}</span>
|
|
||||||
</ha-dialog-header>
|
|
||||||
<div slot="content" class="content">
|
|
||||||
<ha-sortable
|
<ha-sortable
|
||||||
handle-selector=".floor-handle"
|
handle-selector=".floor-handle"
|
||||||
draggable-selector=".floor"
|
draggable-selector=".floor"
|
||||||
@@ -116,15 +109,23 @@ class DialogAreasFloorsOrder extends LitElement {
|
|||||||
</ha-sortable>
|
</ha-sortable>
|
||||||
${this._renderUnassignedAreas()}
|
${this._renderUnassignedAreas()}
|
||||||
</div>
|
</div>
|
||||||
<div slot="actions">
|
<ha-dialog-footer slot="footer">
|
||||||
<ha-button @click=${this.closeDialog} appearance="plain">
|
<ha-button
|
||||||
|
slot="secondaryAction"
|
||||||
|
@click=${this.closeDialog}
|
||||||
|
appearance="plain"
|
||||||
|
>
|
||||||
${this.hass.localize("ui.common.cancel")}
|
${this.hass.localize("ui.common.cancel")}
|
||||||
</ha-button>
|
</ha-button>
|
||||||
<ha-button @click=${this._save} .disabled=${this._saving}>
|
<ha-button
|
||||||
|
slot="primaryAction"
|
||||||
|
@click=${this._save}
|
||||||
|
.disabled=${this._saving}
|
||||||
|
>
|
||||||
${this.hass.localize("ui.common.save")}
|
${this.hass.localize("ui.common.save")}
|
||||||
</ha-button>
|
</ha-button>
|
||||||
</div>
|
</ha-dialog-footer>
|
||||||
</ha-md-dialog>
|
</ha-wa-dialog>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -391,15 +392,13 @@ class DialogAreasFloorsOrder extends LitElement {
|
|||||||
haStyle,
|
haStyle,
|
||||||
haStyleDialog,
|
haStyleDialog,
|
||||||
css`
|
css`
|
||||||
ha-md-dialog {
|
ha-wa-dialog {
|
||||||
min-width: 600px;
|
|
||||||
max-height: 90%;
|
max-height: 90%;
|
||||||
--dialog-content-padding: 8px 24px;
|
--dialog-content-padding: var(--ha-space-2) var(--ha-space-6);
|
||||||
}
|
}
|
||||||
|
|
||||||
@media all and (max-width: 600px), all and (max-height: 500px) {
|
@media all and (max-width: 580px), all and (max-height: 500px) {
|
||||||
ha-md-dialog {
|
ha-wa-dialog {
|
||||||
--md-dialog-container-shape: 0;
|
|
||||||
min-width: 100%;
|
min-width: 100%;
|
||||||
min-height: 100%;
|
min-height: 100%;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user