mirror of
https://github.com/home-assistant/frontend.git
synced 2025-12-12 19:17:21 +00:00
Compare commits
23 Commits
targets-on
...
copilot/mi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
76c21c5e78 | ||
|
|
b5afa9d457 | ||
|
|
6f38e4fd75 | ||
|
|
44fcb72b79 | ||
|
|
a88fcd41b5 | ||
|
|
0a8c0c1c89 | ||
|
|
6f140d30f5 | ||
|
|
baa84ea36c | ||
|
|
68033fa8b4 | ||
|
|
5fd9bac9e5 | ||
|
|
a1c7f91dd0 | ||
|
|
10538989f1 | ||
|
|
0b88a78ec0 | ||
|
|
885f31a4b4 | ||
|
|
e825a2b090 | ||
|
|
657f88595b | ||
|
|
fdeca95215 | ||
|
|
13b60ed2ee | ||
|
|
d74127001c | ||
|
|
eb9d1c119a | ||
|
|
cecf0a95c8 | ||
|
|
950a773f7e | ||
|
|
dddcd04ce9 |
@@ -16,8 +16,10 @@ import { slugify } from "../../../common/string/slugify";
|
|||||||
import { groupBy } from "../../../common/util/group-by";
|
import { groupBy } from "../../../common/util/group-by";
|
||||||
import { afterNextRender } from "../../../common/util/render-status";
|
import { afterNextRender } from "../../../common/util/render-status";
|
||||||
import "../../../components/ha-button";
|
import "../../../components/ha-button";
|
||||||
import "../../../components/ha-button-menu";
|
|
||||||
import "../../../components/ha-card";
|
import "../../../components/ha-card";
|
||||||
|
import "../../../components/ha-dropdown";
|
||||||
|
import "../../../components/ha-dropdown-item";
|
||||||
|
import type { HaDropdownItem } from "../../../components/ha-dropdown-item";
|
||||||
import "../../../components/ha-icon-button";
|
import "../../../components/ha-icon-button";
|
||||||
import "../../../components/ha-icon-next";
|
import "../../../components/ha-icon-next";
|
||||||
import "../../../components/ha-list";
|
import "../../../components/ha-list";
|
||||||
@@ -226,32 +228,23 @@ class HaConfigAreaPage extends LitElement {
|
|||||||
></ha-icon>`
|
></ha-icon>`
|
||||||
: nothing}${area.name}`}
|
: nothing}${area.name}`}
|
||||||
>
|
>
|
||||||
<ha-button-menu slot="toolbar-icon">
|
<ha-dropdown slot="toolbar-icon" @wa-select=${this._handleMenuAction}>
|
||||||
<ha-icon-button
|
<ha-icon-button
|
||||||
slot="trigger"
|
slot="trigger"
|
||||||
.label=${this.hass.localize("ui.common.menu")}
|
.label=${this.hass.localize("ui.common.menu")}
|
||||||
.path=${mdiDotsVertical}
|
.path=${mdiDotsVertical}
|
||||||
></ha-icon-button>
|
></ha-icon-button>
|
||||||
|
|
||||||
<ha-list-item
|
<ha-dropdown-item value="settings" .entry=${area}>
|
||||||
graphic="icon"
|
<ha-svg-icon slot="icon" .path=${mdiPencil}></ha-svg-icon>
|
||||||
.entry=${area}
|
|
||||||
@click=${this._showSettings}
|
|
||||||
>
|
|
||||||
${this.hass.localize("ui.panel.config.areas.edit_settings")}
|
${this.hass.localize("ui.panel.config.areas.edit_settings")}
|
||||||
<ha-svg-icon slot="graphic" .path=${mdiPencil}> </ha-svg-icon>
|
</ha-dropdown-item>
|
||||||
</ha-list-item>
|
|
||||||
|
|
||||||
<ha-list-item
|
<ha-dropdown-item value="delete" variant="danger">
|
||||||
class="warning"
|
<ha-svg-icon slot="icon" .path=${mdiDelete}></ha-svg-icon>
|
||||||
graphic="icon"
|
|
||||||
@click=${this._deleteConfirm}
|
|
||||||
>
|
|
||||||
${this.hass.localize("ui.panel.config.areas.editor.delete")}
|
${this.hass.localize("ui.panel.config.areas.editor.delete")}
|
||||||
<ha-svg-icon class="warning" slot="graphic" .path=${mdiDelete}>
|
</ha-dropdown-item>
|
||||||
</ha-svg-icon>
|
</ha-dropdown>
|
||||||
</ha-list-item>
|
|
||||||
</ha-button-menu>
|
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="column">
|
<div class="column">
|
||||||
@@ -613,6 +606,20 @@ class HaConfigAreaPage extends LitElement {
|
|||||||
this._related = await findRelated(this.hass, "area", this.areaId);
|
this._related = await findRelated(this.hass, "area", this.areaId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _handleMenuAction(ev: CustomEvent) {
|
||||||
|
const item = ev.detail.item as HaDropdownItem & {
|
||||||
|
entry: AreaRegistryEntry;
|
||||||
|
};
|
||||||
|
switch (item.value) {
|
||||||
|
case "settings":
|
||||||
|
this._openDialog(item.entry);
|
||||||
|
break;
|
||||||
|
case "delete":
|
||||||
|
this._deleteConfirm();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private _showSettings(ev: MouseEvent) {
|
private _showSettings(ev: MouseEvent) {
|
||||||
const entry: AreaRegistryEntry = (ev.currentTarget! as any).entry;
|
const entry: AreaRegistryEntry = (ev.currentTarget! as any).entry;
|
||||||
this._openDialog(entry);
|
this._openDialog(entry);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { ActionDetail } from "@material/mwc-list";
|
import "@home-assistant/webawesome/dist/components/divider/divider";
|
||||||
import {
|
import {
|
||||||
mdiDelete,
|
mdiDelete,
|
||||||
mdiDotsVertical,
|
mdiDotsVertical,
|
||||||
@@ -24,10 +24,12 @@ import {
|
|||||||
type AreasFloorHierarchy,
|
type AreasFloorHierarchy,
|
||||||
} from "../../../common/areas/areas-floor-hierarchy";
|
} from "../../../common/areas/areas-floor-hierarchy";
|
||||||
import { formatListWithAnds } from "../../../common/string/format-list";
|
import { formatListWithAnds } from "../../../common/string/format-list";
|
||||||
|
import "../../../components/ha-dropdown";
|
||||||
|
import "../../../components/ha-dropdown-item";
|
||||||
|
import type { HaDropdownItem } from "../../../components/ha-dropdown-item";
|
||||||
import "../../../components/ha-fab";
|
import "../../../components/ha-fab";
|
||||||
import "../../../components/ha-floor-icon";
|
import "../../../components/ha-floor-icon";
|
||||||
import "../../../components/ha-icon-button";
|
import "../../../components/ha-icon-button";
|
||||||
import "../../../components/ha-list-item";
|
|
||||||
import "../../../components/ha-sortable";
|
import "../../../components/ha-sortable";
|
||||||
import type { HaSortableOptions } from "../../../components/ha-sortable";
|
import type { HaSortableOptions } from "../../../components/ha-sortable";
|
||||||
import "../../../components/ha-svg-icon";
|
import "../../../components/ha-svg-icon";
|
||||||
@@ -196,44 +198,43 @@ export class HaConfigAreasDashboard extends LitElement {
|
|||||||
${floor.name}
|
${floor.name}
|
||||||
</h2>
|
</h2>
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<ha-button-menu
|
<ha-dropdown
|
||||||
.floor=${floor}
|
.floor=${floor}
|
||||||
@action=${this._handleFloorAction}
|
@wa-select=${this._handleFloorAction}
|
||||||
>
|
>
|
||||||
<ha-icon-button
|
<ha-icon-button
|
||||||
slot="trigger"
|
slot="trigger"
|
||||||
.path=${mdiDotsVertical}
|
.path=${mdiDotsVertical}
|
||||||
></ha-icon-button>
|
></ha-icon-button>
|
||||||
<ha-list-item graphic="icon"
|
<ha-dropdown-item value="reorder">
|
||||||
><ha-svg-icon
|
<ha-svg-icon
|
||||||
|
slot="icon"
|
||||||
.path=${mdiSort}
|
.path=${mdiSort}
|
||||||
slot="graphic"
|
></ha-svg-icon>
|
||||||
></ha-svg-icon
|
${this.hass.localize(
|
||||||
>${this.hass.localize(
|
|
||||||
"ui.panel.config.areas.picker.reorder"
|
"ui.panel.config.areas.picker.reorder"
|
||||||
)}</ha-list-item
|
)}
|
||||||
>
|
</ha-dropdown-item>
|
||||||
<li divider role="separator"></li>
|
<wa-divider></wa-divider>
|
||||||
<ha-list-item graphic="icon"
|
<ha-dropdown-item value="edit">
|
||||||
><ha-svg-icon
|
<ha-svg-icon
|
||||||
|
slot="icon"
|
||||||
.path=${mdiPencil}
|
.path=${mdiPencil}
|
||||||
slot="graphic"
|
></ha-svg-icon>
|
||||||
></ha-svg-icon
|
${this.hass.localize(
|
||||||
>${this.hass.localize(
|
|
||||||
"ui.panel.config.areas.picker.floor.edit_floor"
|
"ui.panel.config.areas.picker.floor.edit_floor"
|
||||||
)}</ha-list-item
|
)}
|
||||||
>
|
</ha-dropdown-item>
|
||||||
<ha-list-item class="warning" graphic="icon"
|
<ha-dropdown-item value="delete" variant="danger">
|
||||||
><ha-svg-icon
|
<ha-svg-icon
|
||||||
class="warning"
|
slot="icon"
|
||||||
.path=${mdiDelete}
|
.path=${mdiDelete}
|
||||||
slot="graphic"
|
></ha-svg-icon>
|
||||||
></ha-svg-icon
|
${this.hass.localize(
|
||||||
>${this.hass.localize(
|
|
||||||
"ui.panel.config.areas.picker.floor.delete_floor"
|
"ui.panel.config.areas.picker.floor.delete_floor"
|
||||||
)}</ha-list-item
|
)}
|
||||||
>
|
</ha-dropdown-item>
|
||||||
</ha-button-menu>
|
</ha-dropdown>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<ha-sortable
|
<ha-sortable
|
||||||
@@ -273,23 +274,23 @@ export class HaConfigAreasDashboard extends LitElement {
|
|||||||
)}
|
)}
|
||||||
</h2>
|
</h2>
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<ha-button-menu
|
<ha-dropdown
|
||||||
@action=${this._handleUnassignedAreasAction}
|
@wa-select=${this._handleUnassignedAreasAction}
|
||||||
>
|
>
|
||||||
<ha-icon-button
|
<ha-icon-button
|
||||||
slot="trigger"
|
slot="trigger"
|
||||||
.path=${mdiDotsVertical}
|
.path=${mdiDotsVertical}
|
||||||
></ha-icon-button>
|
></ha-icon-button>
|
||||||
<ha-list-item graphic="icon"
|
<ha-dropdown-item value="reorder">
|
||||||
><ha-svg-icon
|
<ha-svg-icon
|
||||||
|
slot="icon"
|
||||||
.path=${mdiSort}
|
.path=${mdiSort}
|
||||||
slot="graphic"
|
></ha-svg-icon>
|
||||||
></ha-svg-icon
|
${this.hass.localize(
|
||||||
>${this.hass.localize(
|
|
||||||
"ui.panel.config.areas.picker.reorder"
|
"ui.panel.config.areas.picker.reorder"
|
||||||
)}</ha-list-item
|
)}
|
||||||
>
|
</ha-dropdown-item>
|
||||||
</ha-button-menu>
|
</ha-dropdown>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<ha-sortable
|
<ha-sortable
|
||||||
@@ -533,23 +534,25 @@ export class HaConfigAreasDashboard extends LitElement {
|
|||||||
}, time);
|
}, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _handleFloorAction(ev: CustomEvent<ActionDetail>) {
|
private _handleFloorAction(ev: CustomEvent) {
|
||||||
|
const item = ev.detail.item as HaDropdownItem;
|
||||||
const floor = (ev.currentTarget as any).floor;
|
const floor = (ev.currentTarget as any).floor;
|
||||||
switch (ev.detail.index) {
|
switch (item.value) {
|
||||||
case 0:
|
case "reorder":
|
||||||
this._showReorderDialog();
|
this._showReorderDialog();
|
||||||
break;
|
break;
|
||||||
case 1:
|
case "edit":
|
||||||
this._editFloor(floor);
|
this._editFloor(floor);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case "delete":
|
||||||
this._deleteFloor(floor);
|
this._deleteFloor(floor);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _handleUnassignedAreasAction(ev: CustomEvent<ActionDetail>) {
|
private _handleUnassignedAreasAction(ev: CustomEvent) {
|
||||||
if (ev.detail.index === 0) {
|
const item = ev.detail.item as HaDropdownItem;
|
||||||
|
if (item.value === "reorder") {
|
||||||
this._showReorderDialog();
|
this._showReorderDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
import "@home-assistant/webawesome/dist/components/divider/divider";
|
||||||
import { ResizeController } from "@lit-labs/observers/resize-controller";
|
import { ResizeController } from "@lit-labs/observers/resize-controller";
|
||||||
import { consume } from "@lit/context";
|
import { consume } from "@lit/context";
|
||||||
import {
|
import {
|
||||||
mdiChevronRight,
|
|
||||||
mdiCog,
|
mdiCog,
|
||||||
mdiContentDuplicate,
|
mdiContentDuplicate,
|
||||||
mdiDelete,
|
mdiDelete,
|
||||||
@@ -23,7 +23,7 @@ import { differenceInDays } from "date-fns";
|
|||||||
import type { UnsubscribeFunc } from "home-assistant-js-websocket";
|
import type { UnsubscribeFunc } from "home-assistant-js-websocket";
|
||||||
import type { CSSResultGroup, PropertyValues, TemplateResult } from "lit";
|
import type { CSSResultGroup, PropertyValues, TemplateResult } 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 { styleMap } from "lit/directives/style-map";
|
import { styleMap } from "lit/directives/style-map";
|
||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
import { computeCssColor } from "../../../common/color/compute-color";
|
import { computeCssColor } from "../../../common/color/compute-color";
|
||||||
@@ -36,7 +36,6 @@ import { fireEvent } from "../../../common/dom/fire_event";
|
|||||||
import { computeStateName } from "../../../common/entity/compute_state_name";
|
import { computeStateName } from "../../../common/entity/compute_state_name";
|
||||||
import { navigate } from "../../../common/navigate";
|
import { navigate } from "../../../common/navigate";
|
||||||
import { slugify } from "../../../common/string/slugify";
|
import { slugify } from "../../../common/string/slugify";
|
||||||
import "../../../components/ha-tooltip";
|
|
||||||
import type { LocalizeFunc } from "../../../common/translations/localize";
|
import type { LocalizeFunc } from "../../../common/translations/localize";
|
||||||
import {
|
import {
|
||||||
hasRejectedItems,
|
hasRejectedItems,
|
||||||
@@ -51,6 +50,9 @@ import type {
|
|||||||
} from "../../../components/data-table/ha-data-table";
|
} from "../../../components/data-table/ha-data-table";
|
||||||
import "../../../components/data-table/ha-data-table-labels";
|
import "../../../components/data-table/ha-data-table-labels";
|
||||||
import "../../../components/entity/ha-entity-toggle";
|
import "../../../components/entity/ha-entity-toggle";
|
||||||
|
import "../../../components/ha-dropdown";
|
||||||
|
import "../../../components/ha-dropdown-item";
|
||||||
|
import type { HaDropdownItem } from "../../../components/ha-dropdown-item";
|
||||||
import "../../../components/ha-fab";
|
import "../../../components/ha-fab";
|
||||||
import "../../../components/ha-filter-blueprints";
|
import "../../../components/ha-filter-blueprints";
|
||||||
import "../../../components/ha-filter-categories";
|
import "../../../components/ha-filter-categories";
|
||||||
@@ -59,13 +61,9 @@ import "../../../components/ha-filter-entities";
|
|||||||
import "../../../components/ha-filter-floor-areas";
|
import "../../../components/ha-filter-floor-areas";
|
||||||
import "../../../components/ha-filter-labels";
|
import "../../../components/ha-filter-labels";
|
||||||
import "../../../components/ha-icon-button";
|
import "../../../components/ha-icon-button";
|
||||||
import "../../../components/ha-md-divider";
|
|
||||||
import "../../../components/ha-md-menu";
|
|
||||||
import type { HaMdMenu } from "../../../components/ha-md-menu";
|
|
||||||
import "../../../components/ha-md-menu-item";
|
|
||||||
import type { HaMdMenuItem } from "../../../components/ha-md-menu-item";
|
|
||||||
import "../../../components/ha-sub-menu";
|
|
||||||
import "../../../components/ha-svg-icon";
|
import "../../../components/ha-svg-icon";
|
||||||
|
import "../../../components/ha-tooltip";
|
||||||
import { createAreaRegistryEntry } from "../../../data/area_registry";
|
import { createAreaRegistryEntry } from "../../../data/area_registry";
|
||||||
import type { AutomationEntity } from "../../../data/automation";
|
import type { AutomationEntity } from "../../../data/automation";
|
||||||
import {
|
import {
|
||||||
@@ -175,8 +173,6 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) {
|
|||||||
@consume({ context: fullEntitiesContext, subscribe: true })
|
@consume({ context: fullEntitiesContext, subscribe: true })
|
||||||
_entityReg!: EntityRegistryEntry[];
|
_entityReg!: EntityRegistryEntry[];
|
||||||
|
|
||||||
@state() private _overflowAutomation?: AutomationItem;
|
|
||||||
|
|
||||||
@storage({ key: "automation-table-sort", state: false, subscribe: false })
|
@storage({ key: "automation-table-sort", state: false, subscribe: false })
|
||||||
private _activeSorting?: SortingChangedEvent;
|
private _activeSorting?: SortingChangedEvent;
|
||||||
|
|
||||||
@@ -204,8 +200,6 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) {
|
|||||||
})
|
})
|
||||||
private _activeHiddenColumns?: string[];
|
private _activeHiddenColumns?: string[];
|
||||||
|
|
||||||
@query("#overflow-menu") private _overflowMenu!: HaMdMenu;
|
|
||||||
|
|
||||||
private _sizeController = new ResizeController(this, {
|
private _sizeController = new ResizeController(this, {
|
||||||
callback: (entries) => entries[0]?.contentRect.width,
|
callback: (entries) => entries[0]?.contentRect.width,
|
||||||
});
|
});
|
||||||
@@ -368,12 +362,81 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) {
|
|||||||
moveable: false,
|
moveable: false,
|
||||||
hideable: false,
|
hideable: false,
|
||||||
template: (automation) => html`
|
template: (automation) => html`
|
||||||
<ha-icon-button
|
<ha-dropdown
|
||||||
.automation=${automation}
|
.automation=${automation}
|
||||||
|
@wa-select=${this._handleRowOverflowMenu}
|
||||||
|
>
|
||||||
|
<ha-icon-button
|
||||||
|
slot="trigger"
|
||||||
.label=${this.hass.localize("ui.common.overflow_menu")}
|
.label=${this.hass.localize("ui.common.overflow_menu")}
|
||||||
.path=${mdiDotsVertical}
|
.path=${mdiDotsVertical}
|
||||||
@click=${this._showOverflowMenu}
|
|
||||||
></ha-icon-button>
|
></ha-icon-button>
|
||||||
|
<ha-dropdown-item value="show-info">
|
||||||
|
<ha-svg-icon
|
||||||
|
slot="icon"
|
||||||
|
.path=${mdiInformationOutline}
|
||||||
|
></ha-svg-icon>
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.show_info"
|
||||||
|
)}
|
||||||
|
</ha-dropdown-item>
|
||||||
|
<ha-dropdown-item value="show-settings">
|
||||||
|
<ha-svg-icon slot="icon" .path=${mdiCog}></ha-svg-icon>
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.panel.config.automation.picker.show_settings"
|
||||||
|
)}
|
||||||
|
</ha-dropdown-item>
|
||||||
|
<ha-dropdown-item value="edit-category">
|
||||||
|
<ha-svg-icon slot="icon" .path=${mdiTag}></ha-svg-icon>
|
||||||
|
${this.hass.localize(
|
||||||
|
`ui.panel.config.automation.picker.${automation.category ? "edit_category" : "assign_category"}`
|
||||||
|
)}
|
||||||
|
</ha-dropdown-item>
|
||||||
|
<ha-dropdown-item value="run-actions">
|
||||||
|
<ha-svg-icon slot="icon" .path=${mdiPlay}></ha-svg-icon>
|
||||||
|
${this.hass.localize("ui.panel.config.automation.editor.run")}
|
||||||
|
</ha-dropdown-item>
|
||||||
|
<ha-dropdown-item value="show-trace">
|
||||||
|
<ha-svg-icon
|
||||||
|
slot="icon"
|
||||||
|
.path=${mdiTransitConnection}
|
||||||
|
></ha-svg-icon>
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.show_trace"
|
||||||
|
)}
|
||||||
|
</ha-dropdown-item>
|
||||||
|
<wa-divider></wa-divider>
|
||||||
|
<ha-dropdown-item value="duplicate">
|
||||||
|
<ha-svg-icon
|
||||||
|
slot="icon"
|
||||||
|
.path=${mdiContentDuplicate}
|
||||||
|
></ha-svg-icon>
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.panel.config.automation.picker.duplicate"
|
||||||
|
)}
|
||||||
|
</ha-dropdown-item>
|
||||||
|
<ha-dropdown-item value="toggle">
|
||||||
|
<ha-svg-icon
|
||||||
|
slot="icon"
|
||||||
|
.path=${automation.state === "off"
|
||||||
|
? mdiToggleSwitch
|
||||||
|
: mdiToggleSwitchOffOutline}
|
||||||
|
></ha-svg-icon>
|
||||||
|
${automation.state === "off"
|
||||||
|
? this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.enable"
|
||||||
|
)
|
||||||
|
: this.hass.localize(
|
||||||
|
"ui.panel.config.automation.editor.disable"
|
||||||
|
)}
|
||||||
|
</ha-dropdown-item>
|
||||||
|
<ha-dropdown-item value="delete" variant="danger">
|
||||||
|
<ha-svg-icon slot="icon" .path=${mdiDelete}></ha-svg-icon>
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.panel.config.automation.picker.delete"
|
||||||
|
)}
|
||||||
|
</ha-dropdown-item>
|
||||||
|
</ha-dropdown>
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -381,17 +444,38 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
private _showOverflowMenu = (ev) => {
|
private _handleRowOverflowMenu = (ev: CustomEvent) => {
|
||||||
if (
|
const item = ev.detail.item as HaDropdownItem;
|
||||||
this._overflowMenu.open &&
|
const automation = (
|
||||||
ev.target === this._overflowMenu.anchorElement
|
(ev.currentTarget as HTMLElement).closest("ha-dropdown") as any
|
||||||
) {
|
).automation;
|
||||||
this._overflowMenu.close();
|
|
||||||
return;
|
switch (item.value) {
|
||||||
|
case "show-info":
|
||||||
|
this._showInfo(automation);
|
||||||
|
break;
|
||||||
|
case "show-settings":
|
||||||
|
this._showSettings(automation);
|
||||||
|
break;
|
||||||
|
case "edit-category":
|
||||||
|
this._editCategory(automation);
|
||||||
|
break;
|
||||||
|
case "run-actions":
|
||||||
|
this._runActions(automation);
|
||||||
|
break;
|
||||||
|
case "show-trace":
|
||||||
|
this._showTrace(automation);
|
||||||
|
break;
|
||||||
|
case "duplicate":
|
||||||
|
this._duplicate(automation);
|
||||||
|
break;
|
||||||
|
case "toggle":
|
||||||
|
this._toggle(automation);
|
||||||
|
break;
|
||||||
|
case "delete":
|
||||||
|
this._deleteConfirm(automation);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
this._overflowAutomation = ev.target.automation;
|
|
||||||
this._overflowMenu.anchorElement = ev.target;
|
|
||||||
this._overflowMenu.show();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
protected hassSubscribe(): (UnsubscribeFunc | Promise<UnsubscribeFunc>)[] {
|
protected hassSubscribe(): (UnsubscribeFunc | Promise<UnsubscribeFunc>)[] {
|
||||||
@@ -409,34 +493,38 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
private _renderCategoryItems = (submenu = false) =>
|
||||||
const categoryItems = html`${this._categories?.map(
|
html`${this._categories?.map(
|
||||||
(category) =>
|
(category) =>
|
||||||
html`<ha-md-menu-item
|
html`<ha-dropdown-item
|
||||||
.value=${category.category_id}
|
.slot=${submenu ? "submenu" : ""}
|
||||||
.clickAction=${this._handleBulkCategory}
|
value="move_category"
|
||||||
|
data-category=${category.category_id}
|
||||||
>
|
>
|
||||||
${category.icon
|
${category.icon
|
||||||
? html`<ha-icon slot="start" .icon=${category.icon}></ha-icon>`
|
? html`<ha-icon slot="icon" .icon=${category.icon}></ha-icon>`
|
||||||
: html`<ha-svg-icon slot="start" .path=${mdiTag}></ha-svg-icon>`}
|
: html`<ha-svg-icon slot="icon" .path=${mdiTag}></ha-svg-icon>`}
|
||||||
<div slot="headline">${category.name}</div>
|
${category.name}
|
||||||
</ha-md-menu-item>`
|
</ha-dropdown-item>`
|
||||||
)}
|
)}
|
||||||
<ha-md-menu-item .value=${null} .clickAction=${this._handleBulkCategory}>
|
<ha-dropdown-item
|
||||||
<div slot="headline">
|
.slot=${submenu ? "submenu" : ""}
|
||||||
|
value="__no_category__"
|
||||||
|
>
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.automation.picker.bulk_actions.no_category"
|
"ui.panel.config.automation.picker.bulk_actions.no_category"
|
||||||
)}
|
)}
|
||||||
</div>
|
</ha-dropdown-item>
|
||||||
</ha-md-menu-item>
|
<wa-divider .slot=${submenu ? "submenu" : ""}></wa-divider>
|
||||||
<ha-md-divider role="separator" tabindex="-1"></ha-md-divider>
|
<ha-dropdown-item
|
||||||
<ha-md-menu-item .clickAction=${this._bulkCreateCategory}>
|
.slot=${submenu ? "submenu" : ""}
|
||||||
<div slot="headline">
|
value="__create_category__"
|
||||||
|
>
|
||||||
${this.hass.localize("ui.panel.config.category.editor.add")}
|
${this.hass.localize("ui.panel.config.category.editor.add")}
|
||||||
</div>
|
</ha-dropdown-item>`;
|
||||||
</ha-md-menu-item>`;
|
|
||||||
|
|
||||||
const labelItems = html`${this._labels?.map((label) => {
|
private _renderLabelItems = (submenu = false) =>
|
||||||
|
html`${this._labels?.map((label) => {
|
||||||
const color = label.color ? computeCssColor(label.color) : undefined;
|
const color = label.color ? computeCssColor(label.color) : undefined;
|
||||||
const selected = this._selected.every((entityId) =>
|
const selected = this._selected.every((entityId) =>
|
||||||
this.hass.entities[entityId]?.labels.includes(label.label_id)
|
this.hass.entities[entityId]?.labels.includes(label.label_id)
|
||||||
@@ -446,14 +534,14 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) {
|
|||||||
this._selected.some((entityId) =>
|
this._selected.some((entityId) =>
|
||||||
this.hass.entities[entityId]?.labels.includes(label.label_id)
|
this.hass.entities[entityId]?.labels.includes(label.label_id)
|
||||||
);
|
);
|
||||||
return html`<ha-md-menu-item
|
return html`<ha-dropdown-item
|
||||||
|
.slot=${submenu ? "submenu" : ""}
|
||||||
.value=${label.label_id}
|
.value=${label.label_id}
|
||||||
.action=${selected ? "remove" : "add"}
|
data-action=${selected ? "remove" : "add"}
|
||||||
@click=${this._handleBulkLabel}
|
@click=${this._handleBulkLabel}
|
||||||
keep-open
|
|
||||||
>
|
>
|
||||||
<ha-checkbox
|
<ha-checkbox
|
||||||
slot="start"
|
slot="icon"
|
||||||
.checked=${selected}
|
.checked=${selected}
|
||||||
.indeterminate=${partial}
|
.indeterminate=${partial}
|
||||||
reducedTouchTarget
|
reducedTouchTarget
|
||||||
@@ -467,46 +555,50 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) {
|
|||||||
: nothing}
|
: nothing}
|
||||||
${label.name}
|
${label.name}
|
||||||
</ha-label>
|
</ha-label>
|
||||||
</ha-md-menu-item>`;
|
</ha-dropdown-item>`;
|
||||||
})}
|
})}
|
||||||
<ha-md-divider role="separator" tabindex="-1"></ha-md-divider>
|
<wa-divider .slot=${submenu ? "submenu" : ""}></wa-divider>
|
||||||
<ha-md-menu-item .clickAction=${this._bulkCreateLabel}>
|
<ha-dropdown-item
|
||||||
<div slot="headline">
|
.slot=${submenu ? "submenu" : ""}
|
||||||
|
value="__create_label__"
|
||||||
|
@click=${this._bulkCreateLabel}
|
||||||
|
>
|
||||||
${this.hass.localize("ui.panel.config.labels.add_label")}
|
${this.hass.localize("ui.panel.config.labels.add_label")}
|
||||||
</div></ha-md-menu-item
|
</ha-dropdown-item>`;
|
||||||
>`;
|
|
||||||
|
|
||||||
const areaItems = html`${Object.values(this.hass.areas).map(
|
private _renderAreaItems = (submenu = false) =>
|
||||||
|
html`${Object.values(this.hass.areas).map(
|
||||||
(area) =>
|
(area) =>
|
||||||
html`<ha-md-menu-item
|
html`<ha-dropdown-item
|
||||||
.value=${area.area_id}
|
.slot=${submenu ? "submenu" : ""}
|
||||||
.clickAction=${this._handleBulkArea}
|
value="move_area"
|
||||||
|
data-area=${area.area_id}
|
||||||
>
|
>
|
||||||
${area.icon
|
${area.icon
|
||||||
? html`<ha-icon slot="start" .icon=${area.icon}></ha-icon>`
|
? html`<ha-icon slot="icon" .icon=${area.icon}></ha-icon>`
|
||||||
: html`<ha-svg-icon
|
: html`<ha-svg-icon
|
||||||
slot="start"
|
slot="icon"
|
||||||
.path=${mdiTextureBox}
|
.path=${mdiTextureBox}
|
||||||
></ha-svg-icon>`}
|
></ha-svg-icon>`}
|
||||||
<div slot="headline">${area.name}</div>
|
${area.name}
|
||||||
</ha-md-menu-item>`
|
</ha-dropdown-item>`
|
||||||
)}
|
)}
|
||||||
<ha-md-menu-item .value=${null} .clickAction=${this._handleBulkArea}>
|
<ha-dropdown-item .slot=${submenu ? "submenu" : ""} value="__no_area__">
|
||||||
<div slot="headline">
|
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.devices.picker.bulk_actions.no_area"
|
"ui.panel.config.devices.picker.bulk_actions.no_area"
|
||||||
)}
|
)}
|
||||||
</div>
|
</ha-dropdown-item>
|
||||||
</ha-md-menu-item>
|
<wa-divider .slot=${submenu ? "submenu" : ""}></wa-divider>
|
||||||
<ha-md-divider role="separator" tabindex="-1"></ha-md-divider>
|
<ha-dropdown-item
|
||||||
<ha-md-menu-item .clickAction=${this._bulkCreateArea}>
|
.slot=${submenu ? "submenu" : ""}
|
||||||
<div slot="headline">
|
value="__create_area__"
|
||||||
|
>
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.devices.picker.bulk_actions.add_area"
|
"ui.panel.config.devices.picker.bulk_actions.add_area"
|
||||||
)}
|
)}
|
||||||
</div>
|
</ha-dropdown-item>`;
|
||||||
</ha-md-menu-item>`;
|
|
||||||
|
|
||||||
|
protected render(): TemplateResult {
|
||||||
const areasInOverflow =
|
const areasInOverflow =
|
||||||
(this._sizeController.value && this._sizeController.value < 900) ||
|
(this._sizeController.value && this._sizeController.value < 900) ||
|
||||||
(!this._sizeController.value && this.hass.dockedSidebar === "docked");
|
(!this._sizeController.value && this.hass.dockedSidebar === "docked");
|
||||||
@@ -527,9 +619,9 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) {
|
|||||||
<hass-tabs-subpage-data-table
|
<hass-tabs-subpage-data-table
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.narrow=${this.narrow}
|
.narrow=${this.narrow}
|
||||||
.backPath=${
|
.backPath=${this._searchParms.has("historyBack")
|
||||||
this._searchParms.has("historyBack") ? undefined : "/config"
|
? undefined
|
||||||
}
|
: "/config"}
|
||||||
id="entity_id"
|
id="entity_id"
|
||||||
.route=${this.route}
|
.route=${this.route}
|
||||||
.tabs=${configSections.automations}
|
.tabs=${configSections.automations}
|
||||||
@@ -541,16 +633,14 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) {
|
|||||||
.selected=${this._selected.length}
|
.selected=${this._selected.length}
|
||||||
@selection-changed=${this._handleSelectionChanged}
|
@selection-changed=${this._handleSelectionChanged}
|
||||||
has-filters
|
has-filters
|
||||||
.filters=${
|
.filters=${Object.values(this._filters).filter((filter) =>
|
||||||
Object.values(this._filters).filter((filter) =>
|
|
||||||
Array.isArray(filter.value)
|
Array.isArray(filter.value)
|
||||||
? filter.value.length
|
? filter.value.length
|
||||||
: filter.value &&
|
: filter.value &&
|
||||||
Object.values(filter.value).some((val) =>
|
Object.values(filter.value).some((val) =>
|
||||||
Array.isArray(val) ? val.length : val
|
Array.isArray(val) ? val.length : val
|
||||||
)
|
)
|
||||||
).length
|
).length}
|
||||||
}
|
|
||||||
.columns=${this._columns(
|
.columns=${this._columns(
|
||||||
this.narrow,
|
this.narrow,
|
||||||
this.hass.localize,
|
this.hass.localize,
|
||||||
@@ -643,9 +733,11 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) {
|
|||||||
.narrow=${this.narrow}
|
.narrow=${this.narrow}
|
||||||
@expanded-changed=${this._filterExpanded}
|
@expanded-changed=${this._filterExpanded}
|
||||||
></ha-filter-blueprints>
|
></ha-filter-blueprints>
|
||||||
${
|
${!this.narrow
|
||||||
!this.narrow
|
? html`<ha-dropdown
|
||||||
? html`<ha-md-button-menu slot="selection-bar">
|
slot="selection-bar"
|
||||||
|
@wa-select=${this._handleOverflowMenuSelect}
|
||||||
|
>
|
||||||
<ha-assist-chip
|
<ha-assist-chip
|
||||||
slot="trigger"
|
slot="trigger"
|
||||||
.label=${this.hass.localize(
|
.label=${this.hass.localize(
|
||||||
@@ -657,11 +749,11 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) {
|
|||||||
.path=${mdiMenuDown}
|
.path=${mdiMenuDown}
|
||||||
></ha-svg-icon>
|
></ha-svg-icon>
|
||||||
</ha-assist-chip>
|
</ha-assist-chip>
|
||||||
${categoryItems}
|
${this._renderCategoryItems()}
|
||||||
</ha-md-button-menu>
|
</ha-dropdown>
|
||||||
${labelsInOverflow
|
${labelsInOverflow
|
||||||
? nothing
|
? nothing
|
||||||
: html`<ha-md-button-menu slot="selection-bar">
|
: html`<ha-dropdown slot="selection-bar">
|
||||||
<ha-assist-chip
|
<ha-assist-chip
|
||||||
slot="trigger"
|
slot="trigger"
|
||||||
.label=${this.hass.localize(
|
.label=${this.hass.localize(
|
||||||
@@ -673,11 +765,14 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) {
|
|||||||
.path=${mdiMenuDown}
|
.path=${mdiMenuDown}
|
||||||
></ha-svg-icon>
|
></ha-svg-icon>
|
||||||
</ha-assist-chip>
|
</ha-assist-chip>
|
||||||
${labelItems}
|
${this._renderLabelItems()}
|
||||||
</ha-md-button-menu>`}
|
</ha-dropdown>`}
|
||||||
${areasInOverflow
|
${areasInOverflow
|
||||||
? nothing
|
? nothing
|
||||||
: html`<ha-md-button-menu slot="selection-bar">
|
: html`<ha-dropdown
|
||||||
|
slot="selection-bar"
|
||||||
|
@wa-select=${this._handleOverflowMenuSelect}
|
||||||
|
>
|
||||||
<ha-assist-chip
|
<ha-assist-chip
|
||||||
slot="trigger"
|
slot="trigger"
|
||||||
.label=${this.hass.localize(
|
.label=${this.hass.localize(
|
||||||
@@ -689,13 +784,15 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) {
|
|||||||
.path=${mdiMenuDown}
|
.path=${mdiMenuDown}
|
||||||
></ha-svg-icon>
|
></ha-svg-icon>
|
||||||
</ha-assist-chip>
|
</ha-assist-chip>
|
||||||
${areaItems}
|
${this._renderAreaItems()}
|
||||||
</ha-md-button-menu>`}`
|
</ha-dropdown>`}`
|
||||||
: nothing
|
: nothing}
|
||||||
}
|
<ha-dropdown
|
||||||
<ha-md-button-menu has-overflow slot="selection-bar">
|
has-overflow
|
||||||
${
|
slot="selection-bar"
|
||||||
this.narrow
|
@wa-select=${this._handleOverflowMenuSelect}
|
||||||
|
>
|
||||||
|
${this.narrow
|
||||||
? html`<ha-assist-chip
|
? html`<ha-assist-chip
|
||||||
.label=${this.hass.localize(
|
.label=${this.hass.localize(
|
||||||
"ui.panel.config.automation.picker.bulk_action"
|
"ui.panel.config.automation.picker.bulk_action"
|
||||||
@@ -713,89 +810,48 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) {
|
|||||||
"ui.panel.config.automation.picker.bulk_action"
|
"ui.panel.config.automation.picker.bulk_action"
|
||||||
)}
|
)}
|
||||||
slot="trigger"
|
slot="trigger"
|
||||||
></ha-icon-button>`
|
></ha-icon-button>`}
|
||||||
}
|
${this.narrow
|
||||||
<ha-svg-icon
|
? html`<ha-dropdown-item>
|
||||||
slot="trailing-icon"
|
|
||||||
.path=${mdiMenuDown}
|
|
||||||
></ha-svg-icon
|
|
||||||
></ha-assist-chip>
|
|
||||||
${
|
|
||||||
this.narrow
|
|
||||||
? html`<ha-sub-menu>
|
|
||||||
<ha-md-menu-item slot="item">
|
|
||||||
<div slot="headline">
|
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.automation.picker.bulk_actions.move_category"
|
"ui.panel.config.automation.picker.bulk_actions.move_category"
|
||||||
)}
|
)}
|
||||||
</div>
|
${this._renderCategoryItems(true)}
|
||||||
<ha-svg-icon
|
</ha-dropdown-item>`
|
||||||
slot="end"
|
: nothing}
|
||||||
.path=${mdiChevronRight}
|
${this.narrow || labelsInOverflow
|
||||||
></ha-svg-icon>
|
? html`<ha-dropdown-item>
|
||||||
</ha-md-menu-item>
|
|
||||||
<ha-md-menu slot="menu">${categoryItems}</ha-md-menu>
|
|
||||||
</ha-sub-menu>`
|
|
||||||
: nothing
|
|
||||||
}
|
|
||||||
${
|
|
||||||
this.narrow || labelsInOverflow
|
|
||||||
? html`<ha-sub-menu>
|
|
||||||
<ha-md-menu-item slot="item">
|
|
||||||
<div slot="headline">
|
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.automation.picker.bulk_actions.add_label"
|
"ui.panel.config.automation.picker.bulk_actions.add_label"
|
||||||
)}
|
)}
|
||||||
</div>
|
${this._renderLabelItems(true)}
|
||||||
<ha-svg-icon
|
</ha-dropdown-item>`
|
||||||
slot="end"
|
: nothing}
|
||||||
.path=${mdiChevronRight}
|
${this.narrow || areasInOverflow
|
||||||
></ha-svg-icon>
|
? html`<ha-dropdown-item>
|
||||||
</ha-md-menu-item>
|
|
||||||
<ha-md-menu slot="menu">${labelItems}</ha-md-menu>
|
|
||||||
</ha-sub-menu>`
|
|
||||||
: nothing
|
|
||||||
}
|
|
||||||
${
|
|
||||||
this.narrow || areasInOverflow
|
|
||||||
? html`<ha-sub-menu>
|
|
||||||
<ha-md-menu-item slot="item">
|
|
||||||
<div slot="headline">
|
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.devices.picker.bulk_actions.move_area"
|
"ui.panel.config.devices.picker.bulk_actions.move_area"
|
||||||
)}
|
)}
|
||||||
</div>
|
${this._renderAreaItems(true)}
|
||||||
<ha-svg-icon
|
</ha-dropdown-item>`
|
||||||
slot="end"
|
: nothing}
|
||||||
.path=${mdiChevronRight}
|
<ha-dropdown-item value="enable">
|
||||||
></ha-svg-icon>
|
<ha-svg-icon slot="icon" .path=${mdiToggleSwitch}></ha-svg-icon>
|
||||||
</ha-md-menu-item>
|
|
||||||
<ha-md-menu slot="menu">${areaItems}</ha-md-menu>
|
|
||||||
</ha-sub-menu>`
|
|
||||||
: nothing
|
|
||||||
}
|
|
||||||
<ha-md-menu-item .clickAction=${this._handleBulkEnable}>
|
|
||||||
<ha-svg-icon slot="start" .path=${mdiToggleSwitch}></ha-svg-icon>
|
|
||||||
<div slot="headline">
|
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.automation.picker.bulk_actions.enable"
|
"ui.panel.config.automation.picker.bulk_actions.enable"
|
||||||
)}
|
)}
|
||||||
</div>
|
</ha-dropdown-item>
|
||||||
</ha-md-menu-item>
|
<ha-dropdown-item value="disable">
|
||||||
<ha-md-menu-item .clickAction=${this._handleBulkDisable}>
|
|
||||||
<ha-svg-icon
|
<ha-svg-icon
|
||||||
slot="start"
|
slot="icon"
|
||||||
.path=${mdiToggleSwitchOffOutline}
|
.path=${mdiToggleSwitchOffOutline}
|
||||||
></ha-svg-icon>
|
></ha-svg-icon>
|
||||||
<div slot="headline">
|
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.automation.picker.bulk_actions.disable"
|
"ui.panel.config.automation.picker.bulk_actions.disable"
|
||||||
)}
|
)}
|
||||||
</div>
|
</ha-dropdown-item>
|
||||||
</ha-md-menu-item>
|
</ha-dropdown>
|
||||||
</ha-md-button-menu>
|
${!this.automations.length
|
||||||
${
|
|
||||||
!this.automations.length
|
|
||||||
? html`<div class="empty" slot="empty">
|
? html`<div class="empty" slot="empty">
|
||||||
<ha-svg-icon .path=${mdiRobotHappy}></ha-svg-icon>
|
<ha-svg-icon .path=${mdiRobotHappy}></ha-svg-icon>
|
||||||
<h1>
|
<h1>
|
||||||
@@ -815,10 +871,7 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) {
|
|||||||
)}
|
)}
|
||||||
</p>
|
</p>
|
||||||
<ha-button
|
<ha-button
|
||||||
href=${documentationUrl(
|
href=${documentationUrl(this.hass, "/docs/automation/editor/")}
|
||||||
this.hass,
|
|
||||||
"/docs/automation/editor/"
|
|
||||||
)}
|
|
||||||
target="_blank"
|
target="_blank"
|
||||||
appearance="plain"
|
appearance="plain"
|
||||||
rel="noreferrer"
|
rel="noreferrer"
|
||||||
@@ -828,8 +881,7 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) {
|
|||||||
<ha-svg-icon slot="end" .path=${mdiOpenInNew}> </ha-svg-icon>
|
<ha-svg-icon slot="end" .path=${mdiOpenInNew}> </ha-svg-icon>
|
||||||
</ha-button>
|
</ha-button>
|
||||||
</div>`
|
</div>`
|
||||||
: nothing
|
: nothing}
|
||||||
}
|
|
||||||
<ha-fab
|
<ha-fab
|
||||||
slot="fab"
|
slot="fab"
|
||||||
.label=${this.hass.localize(
|
.label=${this.hass.localize(
|
||||||
@@ -841,80 +893,6 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) {
|
|||||||
<ha-svg-icon slot="icon" .path=${mdiPlus}></ha-svg-icon>
|
<ha-svg-icon slot="icon" .path=${mdiPlus}></ha-svg-icon>
|
||||||
</ha-fab>
|
</ha-fab>
|
||||||
</hass-tabs-subpage-data-table>
|
</hass-tabs-subpage-data-table>
|
||||||
<ha-md-menu id="overflow-menu" positioning="fixed">
|
|
||||||
<ha-md-menu-item .clickAction=${this._showInfo}>
|
|
||||||
<ha-svg-icon
|
|
||||||
.path=${mdiInformationOutline}
|
|
||||||
slot="start"
|
|
||||||
></ha-svg-icon>
|
|
||||||
<div slot="headline">
|
|
||||||
${this.hass.localize("ui.panel.config.automation.editor.show_info")}
|
|
||||||
</div>
|
|
||||||
</ha-md-menu-item>
|
|
||||||
|
|
||||||
<ha-md-menu-item .clickAction=${this._showSettings}>
|
|
||||||
<ha-svg-icon .path=${mdiCog} slot="start"></ha-svg-icon>
|
|
||||||
<div slot="headline">
|
|
||||||
${this.hass.localize(
|
|
||||||
"ui.panel.config.automation.picker.show_settings"
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</ha-md-menu-item>
|
|
||||||
<ha-md-menu-item .clickAction=${this._editCategory}>
|
|
||||||
<ha-svg-icon .path=${mdiTag} slot="start"></ha-svg-icon>
|
|
||||||
<div slot="headline">
|
|
||||||
${this.hass.localize(
|
|
||||||
`ui.panel.config.automation.picker.${this._overflowAutomation?.category ? "edit_category" : "assign_category"}`
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</ha-md-menu-item>
|
|
||||||
<ha-md-menu-item .clickAction=${this._runActions}>
|
|
||||||
<ha-svg-icon .path=${mdiPlay} slot="start"></ha-svg-icon>
|
|
||||||
<div slot="headline">
|
|
||||||
${this.hass.localize("ui.panel.config.automation.editor.run")}
|
|
||||||
</div>
|
|
||||||
</ha-md-menu-item>
|
|
||||||
<ha-md-menu-item .clickAction=${this._showTrace}>
|
|
||||||
<ha-svg-icon .path=${mdiTransitConnection} slot="start"></ha-svg-icon>
|
|
||||||
<div slot="headline">
|
|
||||||
${this.hass.localize(
|
|
||||||
"ui.panel.config.automation.editor.show_trace"
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</ha-md-menu-item>
|
|
||||||
<ha-md-divider role="separator" tabindex="-1"></ha-md-divider>
|
|
||||||
<ha-md-menu-item .clickAction=${this._duplicate}>
|
|
||||||
<ha-svg-icon .path=${mdiContentDuplicate} slot="start"></ha-svg-icon>
|
|
||||||
<div slot="headline">
|
|
||||||
${this.hass.localize("ui.panel.config.automation.picker.duplicate")}
|
|
||||||
</div>
|
|
||||||
</ha-md-menu-item>
|
|
||||||
<ha-md-menu-item .clickAction=${this._toggle}>
|
|
||||||
<ha-svg-icon
|
|
||||||
.path=${
|
|
||||||
this._overflowAutomation?.state === "off"
|
|
||||||
? mdiToggleSwitch
|
|
||||||
: mdiToggleSwitchOffOutline
|
|
||||||
}
|
|
||||||
slot="start"
|
|
||||||
></ha-svg-icon>
|
|
||||||
<div slot="headline">
|
|
||||||
${
|
|
||||||
this._overflowAutomation?.state === "off"
|
|
||||||
? this.hass.localize("ui.panel.config.automation.editor.enable")
|
|
||||||
: this.hass.localize(
|
|
||||||
"ui.panel.config.automation.editor.disable"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</ha-md-menu-item>
|
|
||||||
<ha-md-menu-item .clickAction=${this._deleteConfirm} class="warning">
|
|
||||||
<ha-svg-icon .path=${mdiDelete} slot="start"></ha-svg-icon>
|
|
||||||
<div slot="headline">
|
|
||||||
${this.hass.localize("ui.panel.config.automation.picker.delete")}
|
|
||||||
</div>
|
|
||||||
</ha-md-menu-item>
|
|
||||||
</ha-md-menu>
|
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1071,33 +1049,22 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) {
|
|||||||
this._applyFilters();
|
this._applyFilters();
|
||||||
}
|
}
|
||||||
|
|
||||||
private _showInfo = (item: HaMdMenuItem) => {
|
private _showInfo = (automation: AutomationItem) => {
|
||||||
const automation = ((item.parentElement as HaMdMenu)!.anchorElement as any)!
|
|
||||||
.automation;
|
|
||||||
fireEvent(this, "hass-more-info", { entityId: automation.entity_id });
|
fireEvent(this, "hass-more-info", { entityId: automation.entity_id });
|
||||||
};
|
};
|
||||||
|
|
||||||
private _showSettings = (item: HaMdMenuItem) => {
|
private _showSettings = (automation: AutomationItem) => {
|
||||||
const automation = ((item.parentElement as HaMdMenu)!.anchorElement as any)!
|
|
||||||
.automation;
|
|
||||||
|
|
||||||
fireEvent(this, "hass-more-info", {
|
fireEvent(this, "hass-more-info", {
|
||||||
entityId: automation.entity_id,
|
entityId: automation.entity_id,
|
||||||
view: "settings",
|
view: "settings",
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
private _runActions = (item: HaMdMenuItem) => {
|
private _runActions = (automation: AutomationItem) => {
|
||||||
const automation = ((item.parentElement as HaMdMenu)!.anchorElement as any)!
|
|
||||||
.automation;
|
|
||||||
|
|
||||||
triggerAutomationActions(this.hass, automation.entity_id);
|
triggerAutomationActions(this.hass, automation.entity_id);
|
||||||
};
|
};
|
||||||
|
|
||||||
private _editCategory = (item: HaMdMenuItem) => {
|
private _editCategory = (automation: AutomationItem) => {
|
||||||
const automation = ((item.parentElement as HaMdMenu)!.anchorElement as any)!
|
|
||||||
.automation;
|
|
||||||
|
|
||||||
const entityReg = this._entityReg.find(
|
const entityReg = this._entityReg.find(
|
||||||
(reg) => reg.entity_id === automation.entity_id
|
(reg) => reg.entity_id === automation.entity_id
|
||||||
);
|
);
|
||||||
@@ -1118,10 +1085,7 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
private _showTrace = (item: HaMdMenuItem) => {
|
private _showTrace = (automation: AutomationItem) => {
|
||||||
const automation = ((item.parentElement as HaMdMenu)!.anchorElement as any)!
|
|
||||||
.automation;
|
|
||||||
|
|
||||||
if (!automation.attributes.id) {
|
if (!automation.attributes.id) {
|
||||||
showAlertDialog(this, {
|
showAlertDialog(this, {
|
||||||
text: this.hass.localize(
|
text: this.hass.localize(
|
||||||
@@ -1135,20 +1099,14 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
private _toggle = async (item: HaMdMenuItem): Promise<void> => {
|
private _toggle = async (automation: AutomationItem): Promise<void> => {
|
||||||
const automation = ((item.parentElement as HaMdMenu)!.anchorElement as any)!
|
|
||||||
.automation;
|
|
||||||
|
|
||||||
const service = automation.state === "off" ? "turn_on" : "turn_off";
|
const service = automation.state === "off" ? "turn_on" : "turn_off";
|
||||||
await this.hass.callService("automation", service, {
|
await this.hass.callService("automation", service, {
|
||||||
entity_id: automation.entity_id,
|
entity_id: automation.entity_id,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
private _deleteConfirm = async (item: HaMdMenuItem) => {
|
private _deleteConfirm = async (automation: AutomationItem) => {
|
||||||
const automation = ((item.parentElement as HaMdMenu)!.anchorElement as any)!
|
|
||||||
.automation;
|
|
||||||
|
|
||||||
showConfirmationDialog(this, {
|
showConfirmationDialog(this, {
|
||||||
title: this.hass.localize(
|
title: this.hass.localize(
|
||||||
"ui.panel.config.automation.picker.delete_confirm_title"
|
"ui.panel.config.automation.picker.delete_confirm_title"
|
||||||
@@ -1164,8 +1122,11 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
private async _delete(automation) {
|
private async _delete(automation: AutomationEntity) {
|
||||||
try {
|
try {
|
||||||
|
if (!automation.attributes.id) {
|
||||||
|
throw new Error("Automation ID is missing");
|
||||||
|
}
|
||||||
await deleteAutomation(this.hass, automation.attributes.id);
|
await deleteAutomation(this.hass, automation.attributes.id);
|
||||||
this._selected = this._selected.filter(
|
this._selected = this._selected.filter(
|
||||||
(entityId) => entityId !== automation.entity_id
|
(entityId) => entityId !== automation.entity_id
|
||||||
@@ -1185,11 +1146,11 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _duplicate = async (item: HaMdMenuItem) => {
|
private _duplicate = async (automation: AutomationEntity) => {
|
||||||
const automation = ((item.parentElement as HaMdMenu)!.anchorElement as any)!
|
|
||||||
.automation;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (!automation.attributes.id) {
|
||||||
|
throw new Error("Automation ID is missing");
|
||||||
|
}
|
||||||
const config = await fetchAutomationFileConfig(
|
const config = await fetchAutomationFileConfig(
|
||||||
this.hass,
|
this.hass,
|
||||||
automation.attributes.id
|
automation.attributes.id
|
||||||
@@ -1261,11 +1222,6 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _handleBulkCategory = async (item) => {
|
|
||||||
const category = item.value;
|
|
||||||
this._bulkAddCategory(category);
|
|
||||||
};
|
|
||||||
|
|
||||||
private async _bulkAddCategory(category: string) {
|
private async _bulkAddCategory(category: string) {
|
||||||
const promises: Promise<UpdateEntityRegistryEntryResult>[] = [];
|
const promises: Promise<UpdateEntityRegistryEntryResult>[] = [];
|
||||||
this._selected.forEach((entityId) => {
|
this._selected.forEach((entityId) => {
|
||||||
@@ -1292,8 +1248,9 @@ ${rejected
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async _handleBulkLabel(ev) {
|
private async _handleBulkLabel(ev) {
|
||||||
|
ev.stopPropagation();
|
||||||
const label = ev.currentTarget.value;
|
const label = ev.currentTarget.value;
|
||||||
const action = ev.currentTarget.action;
|
const action = ev.currentTarget.dataset.action;
|
||||||
this._bulkLabel(label, action);
|
this._bulkLabel(label, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1327,11 +1284,6 @@ ${rejected
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _handleBulkArea = (item) => {
|
|
||||||
const area = item.value;
|
|
||||||
this._bulkAddArea(area);
|
|
||||||
};
|
|
||||||
|
|
||||||
private async _bulkAddArea(area: string) {
|
private async _bulkAddArea(area: string) {
|
||||||
const promises: Promise<UpdateEntityRegistryEntryResult>[] = [];
|
const promises: Promise<UpdateEntityRegistryEntryResult>[] = [];
|
||||||
this._selected.forEach((entityId) => {
|
this._selected.forEach((entityId) => {
|
||||||
@@ -1367,6 +1319,40 @@ ${rejected
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private _handleOverflowMenuSelect = (ev: CustomEvent) => {
|
||||||
|
const item = ev.detail.item as HaDropdownItem;
|
||||||
|
switch (item.value) {
|
||||||
|
case "enable":
|
||||||
|
this._handleBulkEnable();
|
||||||
|
break;
|
||||||
|
case "disable":
|
||||||
|
this._handleBulkDisable();
|
||||||
|
break;
|
||||||
|
case "__create_category__":
|
||||||
|
this._bulkCreateCategory();
|
||||||
|
break;
|
||||||
|
case "__no_category__":
|
||||||
|
this._bulkAddCategory("");
|
||||||
|
break;
|
||||||
|
case "move_category":
|
||||||
|
if (item.dataset.category) {
|
||||||
|
this._bulkAddCategory(item.dataset.category);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "__create_area__":
|
||||||
|
this._bulkCreateArea();
|
||||||
|
break;
|
||||||
|
case "__no_area__":
|
||||||
|
this._bulkAddArea("");
|
||||||
|
break;
|
||||||
|
case "move_area":
|
||||||
|
if (item.dataset.area) {
|
||||||
|
this._bulkAddArea(item.dataset.area);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private _handleBulkEnable = async () => {
|
private _handleBulkEnable = async () => {
|
||||||
const promises: Promise<ServiceCallResponse>[] = [];
|
const promises: Promise<ServiceCallResponse>[] = [];
|
||||||
this._selected.forEach((entityId) => {
|
this._selected.forEach((entityId) => {
|
||||||
@@ -1477,7 +1463,7 @@ ${rejected
|
|||||||
ha-assist-chip {
|
ha-assist-chip {
|
||||||
--ha-assist-chip-container-shape: 10px;
|
--ha-assist-chip-container-shape: 10px;
|
||||||
}
|
}
|
||||||
ha-md-button-menu ha-assist-chip {
|
ha-dropdown ha-assist-chip {
|
||||||
--md-assist-chip-trailing-space: 8px;
|
--md-assist-chip-trailing-space: 8px;
|
||||||
}
|
}
|
||||||
ha-label {
|
ha-label {
|
||||||
|
|||||||
@@ -6,8 +6,10 @@ import { fireEvent } from "../../../../common/dom/fire_event";
|
|||||||
import { debounce } from "../../../../common/util/debounce";
|
import { debounce } from "../../../../common/util/debounce";
|
||||||
import "../../../../components/ha-alert";
|
import "../../../../components/ha-alert";
|
||||||
import "../../../../components/ha-button";
|
import "../../../../components/ha-button";
|
||||||
import "../../../../components/ha-button-menu";
|
|
||||||
import "../../../../components/ha-card";
|
import "../../../../components/ha-card";
|
||||||
|
import "../../../../components/ha-dropdown";
|
||||||
|
import "../../../../components/ha-dropdown-item";
|
||||||
|
import type { HaDropdownItem } from "../../../../components/ha-dropdown-item";
|
||||||
import "../../../../components/ha-list-item";
|
import "../../../../components/ha-list-item";
|
||||||
import "../../../../components/ha-tip";
|
import "../../../../components/ha-tip";
|
||||||
import type {
|
import type {
|
||||||
@@ -53,26 +55,26 @@ export class CloudAccount extends SubscribeMixin(LitElement) {
|
|||||||
.narrow=${this.narrow}
|
.narrow=${this.narrow}
|
||||||
header="Home Assistant Cloud"
|
header="Home Assistant Cloud"
|
||||||
>
|
>
|
||||||
<ha-button-menu slot="toolbar-icon" @action=${this._handleMenuAction}>
|
<ha-dropdown slot="toolbar-icon" @wa-select=${this._handleMenuAction}>
|
||||||
<ha-icon-button
|
<ha-icon-button
|
||||||
slot="trigger"
|
slot="trigger"
|
||||||
.label=${this.hass.localize("ui.common.menu")}
|
.label=${this.hass.localize("ui.common.menu")}
|
||||||
.path=${mdiDotsVertical}
|
.path=${mdiDotsVertical}
|
||||||
></ha-icon-button>
|
></ha-icon-button>
|
||||||
|
|
||||||
<ha-list-item graphic="icon">
|
<ha-dropdown-item value="reset">
|
||||||
|
<ha-svg-icon slot="icon" .path=${mdiDeleteForever}></ha-svg-icon>
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.cloud.account.reset_cloud_data"
|
"ui.panel.config.cloud.account.reset_cloud_data"
|
||||||
)}
|
)}
|
||||||
<ha-svg-icon slot="graphic" .path=${mdiDeleteForever}></ha-svg-icon>
|
</ha-dropdown-item>
|
||||||
</ha-list-item>
|
<ha-dropdown-item value="download">
|
||||||
<ha-list-item graphic="icon">
|
<ha-svg-icon slot="icon" .path=${mdiDownload}></ha-svg-icon>
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.cloud.account.download_support_package"
|
"ui.panel.config.cloud.account.download_support_package"
|
||||||
)}
|
)}
|
||||||
<ha-svg-icon slot="graphic" .path=${mdiDownload}></ha-svg-icon>
|
</ha-dropdown-item>
|
||||||
</ha-list-item>
|
</ha-dropdown>
|
||||||
</ha-button-menu>
|
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<ha-config-section .isWide=${this.isWide}>
|
<ha-config-section .isWide=${this.isWide}>
|
||||||
<span slot="header">Home Assistant Cloud</span>
|
<span slot="header">Home Assistant Cloud</span>
|
||||||
@@ -297,13 +299,15 @@ export class CloudAccount extends SubscribeMixin(LitElement) {
|
|||||||
fireEvent(this, "ha-refresh-cloud-status");
|
fireEvent(this, "ha-refresh-cloud-status");
|
||||||
}
|
}
|
||||||
|
|
||||||
private _handleMenuAction(ev) {
|
private _handleMenuAction(ev: CustomEvent) {
|
||||||
switch (ev.detail.index) {
|
const item = ev.detail.item as HaDropdownItem;
|
||||||
case 0:
|
switch (item.value) {
|
||||||
|
case "reset":
|
||||||
this._deleteCloudData();
|
this._deleteCloudData();
|
||||||
break;
|
break;
|
||||||
case 1:
|
case "download":
|
||||||
this._downloadSupportPackage();
|
this._downloadSupportPackage();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,10 @@ import { customElement, property, query } from "lit/decorators";
|
|||||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||||
import { navigate } from "../../../../common/navigate";
|
import { navigate } from "../../../../common/navigate";
|
||||||
import "../../../../components/ha-alert";
|
import "../../../../components/ha-alert";
|
||||||
import "../../../../components/ha-button-menu";
|
|
||||||
import "../../../../components/ha-card";
|
import "../../../../components/ha-card";
|
||||||
|
import "../../../../components/ha-dropdown";
|
||||||
|
import "../../../../components/ha-dropdown-item";
|
||||||
|
import type { HaDropdownItem } from "../../../../components/ha-dropdown-item";
|
||||||
import "../../../../components/ha-icon-next";
|
import "../../../../components/ha-icon-next";
|
||||||
import "../../../../components/ha-list";
|
import "../../../../components/ha-list";
|
||||||
import "../../../../components/ha-list-item";
|
import "../../../../components/ha-list-item";
|
||||||
@@ -44,26 +46,26 @@ export class CloudLoginPanel extends LitElement {
|
|||||||
.narrow=${this.narrow}
|
.narrow=${this.narrow}
|
||||||
header="Home Assistant Cloud"
|
header="Home Assistant Cloud"
|
||||||
>
|
>
|
||||||
<ha-button-menu slot="toolbar-icon" @action=${this._handleMenuAction}>
|
<ha-dropdown slot="toolbar-icon" @wa-select=${this._handleMenuAction}>
|
||||||
<ha-icon-button
|
<ha-icon-button
|
||||||
slot="trigger"
|
slot="trigger"
|
||||||
.label=${this.hass.localize("ui.common.menu")}
|
.label=${this.hass.localize("ui.common.menu")}
|
||||||
.path=${mdiDotsVertical}
|
.path=${mdiDotsVertical}
|
||||||
></ha-icon-button>
|
></ha-icon-button>
|
||||||
|
|
||||||
<ha-list-item graphic="icon">
|
<ha-dropdown-item value="reset">
|
||||||
|
<ha-svg-icon slot="icon" .path=${mdiDeleteForever}></ha-svg-icon>
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.cloud.account.reset_cloud_data"
|
"ui.panel.config.cloud.account.reset_cloud_data"
|
||||||
)}
|
)}
|
||||||
<ha-svg-icon slot="graphic" .path=${mdiDeleteForever}></ha-svg-icon>
|
</ha-dropdown-item>
|
||||||
</ha-list-item>
|
<ha-dropdown-item value="download">
|
||||||
<ha-list-item graphic="icon">
|
<ha-svg-icon slot="icon" .path=${mdiDownload}></ha-svg-icon>
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.cloud.account.download_support_package"
|
"ui.panel.config.cloud.account.download_support_package"
|
||||||
)}
|
)}
|
||||||
<ha-svg-icon slot="graphic" .path=${mdiDownload}></ha-svg-icon>
|
</ha-dropdown-item>
|
||||||
</ha-list-item>
|
</ha-dropdown>
|
||||||
</ha-button-menu>
|
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<ha-config-section .isWide=${this.isWide}>
|
<ha-config-section .isWide=${this.isWide}>
|
||||||
<span slot="header">Home Assistant Cloud</span>
|
<span slot="header">Home Assistant Cloud</span>
|
||||||
@@ -164,13 +166,15 @@ export class CloudLoginPanel extends LitElement {
|
|||||||
fireEvent(this, "flash-message-changed", { value: "" });
|
fireEvent(this, "flash-message-changed", { value: "" });
|
||||||
}
|
}
|
||||||
|
|
||||||
private _handleMenuAction(ev) {
|
private _handleMenuAction(ev: CustomEvent) {
|
||||||
switch (ev.detail.index) {
|
const item = ev.detail.item as HaDropdownItem;
|
||||||
case 0:
|
switch (item.value) {
|
||||||
|
case "reset":
|
||||||
this._deleteCloudData();
|
this._deleteCloudData();
|
||||||
break;
|
break;
|
||||||
case 1:
|
case "download":
|
||||||
this._downloadSupportPackage();
|
this._downloadSupportPackage();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { RequestSelectedDetail } from "@material/mwc-list/mwc-list-item";
|
import "@home-assistant/webawesome/dist/components/divider/divider";
|
||||||
import { mdiDotsVertical, mdiRefresh } from "@mdi/js";
|
import { mdiDotsVertical, mdiRefresh } from "@mdi/js";
|
||||||
import type { HassEntities } from "home-assistant-js-websocket";
|
import type { HassEntities } from "home-assistant-js-websocket";
|
||||||
import type { TemplateResult } from "lit";
|
import type { TemplateResult } from "lit";
|
||||||
@@ -6,13 +6,12 @@ import { LitElement, css, html } from "lit";
|
|||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
|
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
|
||||||
import { shouldHandleRequestSelectedEvent } from "../../../common/mwc/handle-request-selected-event";
|
|
||||||
import "../../../components/ha-alert";
|
import "../../../components/ha-alert";
|
||||||
import "../../../components/ha-bar";
|
import "../../../components/ha-bar";
|
||||||
import "../../../components/ha-button-menu";
|
|
||||||
import "../../../components/ha-card";
|
import "../../../components/ha-card";
|
||||||
import "../../../components/ha-check-list-item";
|
import "../../../components/ha-dropdown";
|
||||||
import "../../../components/ha-list-item";
|
import "../../../components/ha-dropdown-item";
|
||||||
|
import type { HaDropdownItem } from "../../../components/ha-dropdown-item";
|
||||||
import "../../../components/ha-metric";
|
import "../../../components/ha-metric";
|
||||||
import { extractApiErrorMessage } from "../../../data/hassio/common";
|
import { extractApiErrorMessage } from "../../../data/hassio/common";
|
||||||
import type {
|
import type {
|
||||||
@@ -73,24 +72,24 @@ class HaConfigSectionUpdates extends LitElement {
|
|||||||
.path=${mdiRefresh}
|
.path=${mdiRefresh}
|
||||||
@click=${this._checkUpdates}
|
@click=${this._checkUpdates}
|
||||||
></ha-icon-button>
|
></ha-icon-button>
|
||||||
<ha-button-menu multi>
|
<ha-dropdown @wa-select=${this._handleMenuAction}>
|
||||||
<ha-icon-button
|
<ha-icon-button
|
||||||
slot="trigger"
|
slot="trigger"
|
||||||
.label=${this.hass.localize("ui.common.menu")}
|
.label=${this.hass.localize("ui.common.menu")}
|
||||||
.path=${mdiDotsVertical}
|
.path=${mdiDotsVertical}
|
||||||
></ha-icon-button>
|
></ha-icon-button>
|
||||||
<ha-check-list-item
|
<ha-dropdown-item
|
||||||
left
|
type="checkbox"
|
||||||
@request-selected=${this._toggleSkipped}
|
.checked=${this._showSkipped}
|
||||||
.selected=${this._showSkipped}
|
value="toggle_skipped"
|
||||||
>
|
>
|
||||||
${this.hass.localize("ui.panel.config.updates.show_skipped")}
|
${this.hass.localize("ui.panel.config.updates.show_skipped")}
|
||||||
</ha-check-list-item>
|
</ha-dropdown-item>
|
||||||
${this._supervisorInfo
|
${this._supervisorInfo
|
||||||
? html`
|
? html`
|
||||||
<li divider role="separator"></li>
|
<wa-divider></wa-divider>
|
||||||
<ha-list-item
|
<ha-dropdown-item
|
||||||
@request-selected=${this._toggleBeta}
|
value="toggle_beta"
|
||||||
.disabled=${this._supervisorInfo.channel === "dev"}
|
.disabled=${this._supervisorInfo.channel === "dev"}
|
||||||
>
|
>
|
||||||
${this._supervisorInfo.channel === "stable"
|
${this._supervisorInfo.channel === "stable"
|
||||||
@@ -98,10 +97,10 @@ class HaConfigSectionUpdates extends LitElement {
|
|||||||
: this.hass.localize(
|
: this.hass.localize(
|
||||||
"ui.panel.config.updates.leave_beta"
|
"ui.panel.config.updates.leave_beta"
|
||||||
)}
|
)}
|
||||||
</ha-list-item>
|
</ha-dropdown-item>
|
||||||
`
|
`
|
||||||
: ""}
|
: ""}
|
||||||
</ha-button-menu>
|
</ha-dropdown>
|
||||||
</div>
|
</div>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<ha-card outlined>
|
<ha-card outlined>
|
||||||
@@ -133,21 +132,13 @@ class HaConfigSectionUpdates extends LitElement {
|
|||||||
this._supervisorInfo = await fetchHassioSupervisorInfo(this.hass);
|
this._supervisorInfo = await fetchHassioSupervisorInfo(this.hass);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _toggleSkipped(ev: CustomEvent<RequestSelectedDetail>): void {
|
private _handleMenuAction(ev: CustomEvent): void {
|
||||||
if (ev.detail.source !== "property") {
|
const item = ev.detail.item as HaDropdownItem;
|
||||||
return;
|
switch (item.value) {
|
||||||
}
|
case "toggle_skipped":
|
||||||
|
|
||||||
this._showSkipped = !this._showSkipped;
|
this._showSkipped = !this._showSkipped;
|
||||||
}
|
break;
|
||||||
|
case "toggle_beta":
|
||||||
private async _toggleBeta(
|
|
||||||
ev: CustomEvent<RequestSelectedDetail>
|
|
||||||
): Promise<void> {
|
|
||||||
if (!shouldHandleRequestSelectedEvent(ev)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this._supervisorInfo!.channel === "stable") {
|
if (this._supervisorInfo!.channel === "stable") {
|
||||||
showJoinBetaDialog(this, {
|
showJoinBetaDialog(this, {
|
||||||
join: async () => this._setChannel("beta"),
|
join: async () => this._setChannel("beta"),
|
||||||
@@ -155,6 +146,8 @@ class HaConfigSectionUpdates extends LitElement {
|
|||||||
} else {
|
} else {
|
||||||
this._setChannel("stable");
|
this._setChannel("stable");
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _setChannel(
|
private async _setChannel(
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import type { ActionDetail } from "@material/mwc-list";
|
|
||||||
import {
|
import {
|
||||||
mdiCloudLock,
|
mdiCloudLock,
|
||||||
mdiDotsVertical,
|
mdiDotsVertical,
|
||||||
@@ -13,11 +12,12 @@ import { customElement, property, state } from "lit/decorators";
|
|||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
|
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
|
||||||
import "../../../components/chips/ha-assist-chip";
|
import "../../../components/chips/ha-assist-chip";
|
||||||
import "../../../components/ha-button-menu";
|
|
||||||
import "../../../components/ha-card";
|
import "../../../components/ha-card";
|
||||||
|
import "../../../components/ha-dropdown";
|
||||||
|
import "../../../components/ha-dropdown-item";
|
||||||
|
import type { HaDropdownItem } from "../../../components/ha-dropdown-item";
|
||||||
import "../../../components/ha-icon-button";
|
import "../../../components/ha-icon-button";
|
||||||
import "../../../components/ha-icon-next";
|
import "../../../components/ha-icon-next";
|
||||||
import "../../../components/ha-list-item";
|
|
||||||
import "../../../components/ha-menu-button";
|
import "../../../components/ha-menu-button";
|
||||||
import "../../../components/ha-svg-icon";
|
import "../../../components/ha-svg-icon";
|
||||||
import "../../../components/ha-tip";
|
import "../../../components/ha-tip";
|
||||||
@@ -226,25 +226,25 @@ class HaConfigDashboard extends SubscribeMixin(LitElement) {
|
|||||||
.path=${mdiMagnify}
|
.path=${mdiMagnify}
|
||||||
@click=${this._showQuickBar}
|
@click=${this._showQuickBar}
|
||||||
></ha-icon-button>
|
></ha-icon-button>
|
||||||
<ha-button-menu slot="actionItems" @action=${this._handleMenuAction}>
|
<ha-dropdown slot="actionItems" @wa-select=${this._handleMenuAction}>
|
||||||
<ha-icon-button
|
<ha-icon-button
|
||||||
slot="trigger"
|
slot="trigger"
|
||||||
.label=${this.hass.localize("ui.common.menu")}
|
.label=${this.hass.localize("ui.common.menu")}
|
||||||
.path=${mdiDotsVertical}
|
.path=${mdiDotsVertical}
|
||||||
></ha-icon-button>
|
></ha-icon-button>
|
||||||
|
|
||||||
<ha-list-item graphic="icon">
|
<ha-dropdown-item value="check_updates">
|
||||||
|
<ha-svg-icon slot="icon" .path=${mdiRefresh}></ha-svg-icon>
|
||||||
${this.hass.localize("ui.panel.config.updates.check_updates")}
|
${this.hass.localize("ui.panel.config.updates.check_updates")}
|
||||||
<ha-svg-icon slot="graphic" .path=${mdiRefresh}></ha-svg-icon>
|
</ha-dropdown-item>
|
||||||
</ha-list-item>
|
|
||||||
|
|
||||||
<ha-list-item graphic="icon">
|
<ha-dropdown-item value="restart">
|
||||||
|
<ha-svg-icon slot="icon" .path=${mdiPower}></ha-svg-icon>
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.system_dashboard.restart_homeassistant"
|
"ui.panel.config.system_dashboard.restart_homeassistant"
|
||||||
)}
|
)}
|
||||||
<ha-svg-icon slot="graphic" .path=${mdiPower}></ha-svg-icon>
|
</ha-dropdown-item>
|
||||||
</ha-list-item>
|
</ha-dropdown>
|
||||||
</ha-button-menu>
|
|
||||||
|
|
||||||
<ha-config-section
|
<ha-config-section
|
||||||
.narrow=${this.narrow}
|
.narrow=${this.narrow}
|
||||||
@@ -371,12 +371,13 @@ class HaConfigDashboard extends SubscribeMixin(LitElement) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _handleMenuAction(ev: CustomEvent<ActionDetail>) {
|
private async _handleMenuAction(ev: CustomEvent) {
|
||||||
switch (ev.detail.index) {
|
const item = ev.detail.item as HaDropdownItem;
|
||||||
case 0:
|
switch (item.value) {
|
||||||
|
case "check_updates":
|
||||||
checkForEntityUpdates(this, this.hass);
|
checkForEntityUpdates(this, this.hass);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case "restart":
|
||||||
showRestartDialog(this);
|
showRestartDialog(this);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { consume } from "@lit/context";
|
import { consume } from "@lit/context";
|
||||||
import {
|
import {
|
||||||
mdiCancel,
|
mdiCancel,
|
||||||
mdiChevronRight,
|
|
||||||
mdiDelete,
|
mdiDelete,
|
||||||
mdiDotsVertical,
|
mdiDotsVertical,
|
||||||
mdiMenuDown,
|
mdiMenuDown,
|
||||||
@@ -39,11 +38,15 @@ import type {
|
|||||||
SortingChangedEvent,
|
SortingChangedEvent,
|
||||||
} from "../../../components/data-table/ha-data-table";
|
} from "../../../components/data-table/ha-data-table";
|
||||||
|
|
||||||
|
import "@home-assistant/webawesome/dist/components/divider/divider";
|
||||||
import "../../../components/data-table/ha-data-table-labels";
|
import "../../../components/data-table/ha-data-table-labels";
|
||||||
import "../../../components/entity/ha-battery-icon";
|
import "../../../components/entity/ha-battery-icon";
|
||||||
import "../../../components/ha-alert";
|
import "../../../components/ha-alert";
|
||||||
import "../../../components/ha-button-menu";
|
import "../../../components/ha-button-menu";
|
||||||
import "../../../components/ha-check-list-item";
|
import "../../../components/ha-check-list-item";
|
||||||
|
import "../../../components/ha-dropdown";
|
||||||
|
import "../../../components/ha-dropdown-item";
|
||||||
|
import type { HaDropdownItem } from "../../../components/ha-dropdown-item";
|
||||||
import "../../../components/ha-fab";
|
import "../../../components/ha-fab";
|
||||||
import "../../../components/ha-filter-devices";
|
import "../../../components/ha-filter-devices";
|
||||||
import "../../../components/ha-filter-floor-areas";
|
import "../../../components/ha-filter-floor-areas";
|
||||||
@@ -51,9 +54,6 @@ import "../../../components/ha-filter-integrations";
|
|||||||
import "../../../components/ha-filter-labels";
|
import "../../../components/ha-filter-labels";
|
||||||
import "../../../components/ha-filter-states";
|
import "../../../components/ha-filter-states";
|
||||||
import "../../../components/ha-icon-button";
|
import "../../../components/ha-icon-button";
|
||||||
import "../../../components/ha-md-divider";
|
|
||||||
import "../../../components/ha-md-menu-item";
|
|
||||||
import "../../../components/ha-sub-menu";
|
|
||||||
import { createAreaRegistryEntry } from "../../../data/area_registry";
|
import { createAreaRegistryEntry } from "../../../data/area_registry";
|
||||||
import type { ConfigEntry, SubEntry } from "../../../data/config_entries";
|
import type { ConfigEntry, SubEntry } from "../../../data/config_entries";
|
||||||
import { getSubEntries, sortConfigEntries } from "../../../data/config_entries";
|
import { getSubEntries, sortConfigEntries } from "../../../data/config_entries";
|
||||||
@@ -702,6 +702,80 @@ export class HaConfigDeviceDashboard extends SubscribeMixin(LitElement) {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _renderAreaItems = (submenu = false) =>
|
||||||
|
html`${Object.values(this.hass.areas).map(
|
||||||
|
(area) =>
|
||||||
|
html`<ha-dropdown-item
|
||||||
|
.slot=${submenu ? "submenu" : ""}
|
||||||
|
value="toggle_area"
|
||||||
|
data-area=${area.area_id}
|
||||||
|
>
|
||||||
|
${area.icon
|
||||||
|
? html`<ha-icon slot="icon" .icon=${area.icon}></ha-icon>`
|
||||||
|
: html`<ha-svg-icon
|
||||||
|
slot="icon"
|
||||||
|
.path=${mdiTextureBox}
|
||||||
|
></ha-svg-icon>`}
|
||||||
|
${area.name}
|
||||||
|
</ha-dropdown-item>`
|
||||||
|
)}
|
||||||
|
<ha-dropdown-item .slot=${submenu ? "submenu" : ""} value="__no_area__">
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.panel.config.devices.picker.bulk_actions.no_area"
|
||||||
|
)}
|
||||||
|
</ha-dropdown-item>
|
||||||
|
<wa-divider .slot=${submenu ? "submenu" : ""}></wa-divider>
|
||||||
|
<ha-dropdown-item
|
||||||
|
.slot=${submenu ? "submenu" : ""}
|
||||||
|
value="__create_area__"
|
||||||
|
>
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.panel.config.devices.picker.bulk_actions.add_area"
|
||||||
|
)}
|
||||||
|
</ha-dropdown-item>`;
|
||||||
|
|
||||||
|
private _renderLabelItems = (submenu = false) =>
|
||||||
|
html`${this._labels?.map((label) => {
|
||||||
|
const color = label.color ? computeCssColor(label.color) : undefined;
|
||||||
|
const selected = this._selected.every((deviceId) =>
|
||||||
|
this.hass.devices[deviceId]?.labels.includes(label.label_id)
|
||||||
|
);
|
||||||
|
const partial =
|
||||||
|
!selected &&
|
||||||
|
this._selected.some((deviceId) =>
|
||||||
|
this.hass.devices[deviceId]?.labels.includes(label.label_id)
|
||||||
|
);
|
||||||
|
return html`<ha-dropdown-item
|
||||||
|
.slot=${submenu ? "submenu" : ""}
|
||||||
|
.value=${label.label_id}
|
||||||
|
data-action=${selected ? "remove" : "add"}
|
||||||
|
@click=${this._handleBulkLabel}
|
||||||
|
>
|
||||||
|
<ha-checkbox
|
||||||
|
slot="icon"
|
||||||
|
.checked=${selected}
|
||||||
|
.indeterminate=${partial}
|
||||||
|
reducedTouchTarget
|
||||||
|
></ha-checkbox>
|
||||||
|
<ha-label
|
||||||
|
style=${color ? `--color: ${color}` : ""}
|
||||||
|
.description=${label.description}
|
||||||
|
>
|
||||||
|
${label.icon
|
||||||
|
? html`<ha-icon slot="icon" .icon=${label.icon}></ha-icon>`
|
||||||
|
: nothing}
|
||||||
|
${label.name}
|
||||||
|
</ha-label>
|
||||||
|
</ha-dropdown-item>`;
|
||||||
|
})}
|
||||||
|
<wa-divider .slot=${submenu ? "submenu" : ""}></wa-divider>
|
||||||
|
<ha-dropdown-item
|
||||||
|
@click=${this._bulkCreateLabel}
|
||||||
|
.slot=${submenu ? "submenu" : ""}
|
||||||
|
>
|
||||||
|
${this.hass.localize("ui.panel.config.labels.add_label")}
|
||||||
|
</ha-dropdown-item>`;
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
const { devicesOutput } = this._devicesAndFilterDomains(
|
const { devicesOutput } = this._devicesAndFilterDomains(
|
||||||
this.hass.devices,
|
this.hass.devices,
|
||||||
@@ -718,77 +792,6 @@ export class HaConfigDeviceDashboard extends SubscribeMixin(LitElement) {
|
|||||||
(this._sizeController.value && this._sizeController.value < 700) ||
|
(this._sizeController.value && this._sizeController.value < 700) ||
|
||||||
(!this._sizeController.value && this.hass.dockedSidebar === "docked");
|
(!this._sizeController.value && this.hass.dockedSidebar === "docked");
|
||||||
|
|
||||||
const areaItems = html`${Object.values(this.hass.areas).map(
|
|
||||||
(area) =>
|
|
||||||
html`<ha-md-menu-item
|
|
||||||
.value=${area.area_id}
|
|
||||||
.clickAction=${this._handleBulkArea}
|
|
||||||
>
|
|
||||||
${area.icon
|
|
||||||
? html`<ha-icon slot="start" .icon=${area.icon}></ha-icon>`
|
|
||||||
: html`<ha-svg-icon
|
|
||||||
slot="start"
|
|
||||||
.path=${mdiTextureBox}
|
|
||||||
></ha-svg-icon>`}
|
|
||||||
<div slot="headline">${area.name}</div>
|
|
||||||
</ha-md-menu-item>`
|
|
||||||
)}
|
|
||||||
<ha-md-menu-item .value=${null} .clickAction=${this._handleBulkArea}>
|
|
||||||
<div slot="headline">
|
|
||||||
${this.hass.localize(
|
|
||||||
"ui.panel.config.devices.picker.bulk_actions.no_area"
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</ha-md-menu-item>
|
|
||||||
<ha-md-divider role="separator" tabindex="-1"></ha-md-divider>
|
|
||||||
<ha-md-menu-item .clickAction=${this._bulkCreateArea}>
|
|
||||||
<div slot="headline">
|
|
||||||
${this.hass.localize(
|
|
||||||
"ui.panel.config.devices.picker.bulk_actions.add_area"
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</ha-md-menu-item>`;
|
|
||||||
|
|
||||||
const labelItems = html`${this._labels?.map((label) => {
|
|
||||||
const color = label.color ? computeCssColor(label.color) : undefined;
|
|
||||||
const selected = this._selected.every((deviceId) =>
|
|
||||||
this.hass.devices[deviceId]?.labels.includes(label.label_id)
|
|
||||||
);
|
|
||||||
const partial =
|
|
||||||
!selected &&
|
|
||||||
this._selected.some((deviceId) =>
|
|
||||||
this.hass.devices[deviceId]?.labels.includes(label.label_id)
|
|
||||||
);
|
|
||||||
return html`<ha-md-menu-item
|
|
||||||
.value=${label.label_id}
|
|
||||||
.action=${selected ? "remove" : "add"}
|
|
||||||
@click=${this._handleBulkLabel}
|
|
||||||
keep-open
|
|
||||||
>
|
|
||||||
<ha-checkbox
|
|
||||||
slot="start"
|
|
||||||
.checked=${selected}
|
|
||||||
.indeterminate=${partial}
|
|
||||||
reducedTouchTarget
|
|
||||||
></ha-checkbox>
|
|
||||||
<ha-label
|
|
||||||
style=${color ? `--color: ${color}` : ""}
|
|
||||||
.description=${label.description}
|
|
||||||
>
|
|
||||||
${label.icon
|
|
||||||
? html`<ha-icon slot="icon" .icon=${label.icon}></ha-icon>`
|
|
||||||
: nothing}
|
|
||||||
${label.name}
|
|
||||||
</ha-label>
|
|
||||||
</ha-md-menu-item>`;
|
|
||||||
})}
|
|
||||||
<ha-md-divider role="separator" tabindex="-1"></ha-md-divider>
|
|
||||||
<ha-md-menu-item .clickAction=${this._bulkCreateLabel}>
|
|
||||||
<div slot="headline">
|
|
||||||
${this.hass.localize("ui.panel.config.labels.add_label")}
|
|
||||||
</div></ha-md-menu-item
|
|
||||||
>`;
|
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<hass-tabs-subpage-data-table
|
<hass-tabs-subpage-data-table
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
@@ -906,7 +909,7 @@ export class HaConfigDeviceDashboard extends SubscribeMixin(LitElement) {
|
|||||||
></ha-filter-labels>
|
></ha-filter-labels>
|
||||||
|
|
||||||
${!this.narrow
|
${!this.narrow
|
||||||
? html`<ha-md-button-menu slot="selection-bar">
|
? html`<ha-dropdown slot="selection-bar">
|
||||||
<ha-assist-chip
|
<ha-assist-chip
|
||||||
slot="trigger"
|
slot="trigger"
|
||||||
.label=${this.hass.localize(
|
.label=${this.hass.localize(
|
||||||
@@ -918,12 +921,15 @@ export class HaConfigDeviceDashboard extends SubscribeMixin(LitElement) {
|
|||||||
.path=${mdiMenuDown}
|
.path=${mdiMenuDown}
|
||||||
></ha-svg-icon>
|
></ha-svg-icon>
|
||||||
</ha-assist-chip>
|
</ha-assist-chip>
|
||||||
${labelItems}
|
${this._renderLabelItems()}
|
||||||
</ha-md-button-menu>
|
</ha-dropdown>
|
||||||
|
|
||||||
${areasInOverflow
|
${areasInOverflow
|
||||||
? nothing
|
? nothing
|
||||||
: html`<ha-md-button-menu slot="selection-bar">
|
: html`<ha-dropdown
|
||||||
|
slot="selection-bar"
|
||||||
|
@wa-select=${this._handleOverflowMenuSelect}
|
||||||
|
>
|
||||||
<ha-assist-chip
|
<ha-assist-chip
|
||||||
slot="trigger"
|
slot="trigger"
|
||||||
.label=${this.hass.localize(
|
.label=${this.hass.localize(
|
||||||
@@ -935,10 +941,14 @@ export class HaConfigDeviceDashboard extends SubscribeMixin(LitElement) {
|
|||||||
.path=${mdiMenuDown}
|
.path=${mdiMenuDown}
|
||||||
></ha-svg-icon>
|
></ha-svg-icon>
|
||||||
</ha-assist-chip>
|
</ha-assist-chip>
|
||||||
${areaItems}
|
${this._renderAreaItems()}
|
||||||
</ha-md-button-menu>`}`
|
</ha-dropdown>`}`
|
||||||
: nothing}
|
: nothing}
|
||||||
<ha-md-button-menu has-overflow slot="selection-bar">
|
<ha-dropdown
|
||||||
|
has-overflow
|
||||||
|
slot="selection-bar"
|
||||||
|
@wa-select=${this._handleOverflowMenuSelect}
|
||||||
|
>
|
||||||
${this.narrow
|
${this.narrow
|
||||||
? html`<ha-assist-chip
|
? html`<ha-assist-chip
|
||||||
.label=${this.hass.localize(
|
.label=${this.hass.localize(
|
||||||
@@ -959,51 +969,32 @@ export class HaConfigDeviceDashboard extends SubscribeMixin(LitElement) {
|
|||||||
slot="trigger"
|
slot="trigger"
|
||||||
></ha-icon-button>`}
|
></ha-icon-button>`}
|
||||||
${this.narrow
|
${this.narrow
|
||||||
? html` <ha-sub-menu>
|
? html`<ha-dropdown-item>
|
||||||
<ha-md-menu-item slot="item">
|
|
||||||
<div slot="headline">
|
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.automation.picker.bulk_actions.add_label"
|
"ui.panel.config.automation.picker.bulk_actions.add_label"
|
||||||
)}
|
)}
|
||||||
</div>
|
${this._renderLabelItems(true)}
|
||||||
<ha-svg-icon
|
</ha-dropdown-item>`
|
||||||
slot="end"
|
|
||||||
.path=${mdiChevronRight}
|
|
||||||
></ha-svg-icon>
|
|
||||||
</ha-md-menu-item>
|
|
||||||
<ha-md-menu slot="menu">${labelItems}</ha-md-menu>
|
|
||||||
</ha-sub-menu>`
|
|
||||||
: nothing}
|
: nothing}
|
||||||
${areasInOverflow
|
${areasInOverflow
|
||||||
? html`<ha-sub-menu>
|
? html`<ha-dropdown-item>
|
||||||
<ha-md-menu-item slot="item">
|
|
||||||
<div slot="headline">
|
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.devices.picker.bulk_actions.move_area"
|
"ui.panel.config.devices.picker.bulk_actions.move_area"
|
||||||
)}
|
)}
|
||||||
</div>
|
${this._renderAreaItems(true)}
|
||||||
<ha-svg-icon
|
</ha-dropdown-item>`
|
||||||
slot="end"
|
|
||||||
.path=${mdiChevronRight}
|
|
||||||
></ha-svg-icon>
|
|
||||||
</ha-md-menu-item>
|
|
||||||
<ha-md-menu slot="menu">${areaItems}</ha-md-menu>
|
|
||||||
</ha-sub-menu>
|
|
||||||
<ha-md-divider role="separator" tabindex="-1"></ha-md-divider>`
|
|
||||||
: nothing}
|
: nothing}
|
||||||
<ha-md-menu-item
|
<ha-dropdown-item
|
||||||
.clickAction=${this._deleteSelected}
|
value="delete"
|
||||||
.disabled=${!this._selectedCanDelete.length}
|
.disabled=${!this._selectedCanDelete.length}
|
||||||
class="warning"
|
variant="danger"
|
||||||
>
|
>
|
||||||
<ha-svg-icon slot="start" .path=${mdiDelete}></ha-svg-icon>
|
<ha-svg-icon slot="icon" .path=${mdiDelete}></ha-svg-icon>
|
||||||
<div slot="headline">
|
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.devices.picker.bulk_actions.delete_selected.button"
|
"ui.panel.config.devices.picker.bulk_actions.delete_selected.button"
|
||||||
)}
|
)}
|
||||||
</div>
|
</ha-dropdown-item>
|
||||||
</ha-md-menu-item>
|
</ha-dropdown>
|
||||||
</ha-md-button-menu>
|
|
||||||
</hass-tabs-subpage-data-table>
|
</hass-tabs-subpage-data-table>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
@@ -1093,12 +1084,28 @@ export class HaConfigDeviceDashboard extends SubscribeMixin(LitElement) {
|
|||||||
this._selected = ev.detail.value;
|
this._selected = ev.detail.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _handleBulkArea = (item) => {
|
private _handleOverflowMenuSelect(ev: CustomEvent) {
|
||||||
const area = item.value;
|
const item = ev.detail.item as HaDropdownItem;
|
||||||
this._bulkAddArea(area);
|
|
||||||
};
|
|
||||||
|
|
||||||
private async _bulkAddArea(area: string) {
|
switch (item.value) {
|
||||||
|
case "delete":
|
||||||
|
this._deleteSelected();
|
||||||
|
break;
|
||||||
|
case "__no_area__":
|
||||||
|
this._bulkAddArea(null);
|
||||||
|
break;
|
||||||
|
case "__create_area__":
|
||||||
|
this._bulkCreateArea();
|
||||||
|
break;
|
||||||
|
case "toggle_area":
|
||||||
|
if (item.dataset.area) {
|
||||||
|
this._bulkAddArea(item.dataset.area);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async _bulkAddArea(area: string | null) {
|
||||||
const promises: Promise<DeviceRegistryEntry>[] = [];
|
const promises: Promise<DeviceRegistryEntry>[] = [];
|
||||||
this._selected.forEach((deviceId) => {
|
this._selected.forEach((deviceId) => {
|
||||||
promises.push(
|
promises.push(
|
||||||
@@ -1133,12 +1140,6 @@ ${rejected
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
private async _handleBulkLabel(ev) {
|
|
||||||
const label = ev.currentTarget.value;
|
|
||||||
const action = ev.currentTarget.action;
|
|
||||||
this._bulkLabel(label, action);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async _bulkLabel(label: string, action: "add" | "remove") {
|
private async _bulkLabel(label: string, action: "add" | "remove") {
|
||||||
const promises: Promise<DeviceRegistryEntry>[] = [];
|
const promises: Promise<DeviceRegistryEntry>[] = [];
|
||||||
this._selected.forEach((deviceId) => {
|
this._selected.forEach((deviceId) => {
|
||||||
@@ -1178,6 +1179,13 @@ ${rejected
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private async _handleBulkLabel(ev) {
|
||||||
|
ev.stopPropagation();
|
||||||
|
const label = ev.currentTarget.value;
|
||||||
|
const action = ev.currentTarget.dataset.action;
|
||||||
|
this._bulkLabel(label, action);
|
||||||
|
}
|
||||||
|
|
||||||
private _deleteSelected = () => {
|
private _deleteSelected = () => {
|
||||||
showConfirmationDialog(this, {
|
showConfirmationDialog(this, {
|
||||||
title: this.hass.localize(
|
title: this.hass.localize(
|
||||||
@@ -1277,7 +1285,7 @@ ${rejected
|
|||||||
ha-assist-chip {
|
ha-assist-chip {
|
||||||
--ha-assist-chip-container-shape: 10px;
|
--ha-assist-chip-container-shape: 10px;
|
||||||
}
|
}
|
||||||
ha-md-button-menu ha-assist-chip {
|
ha-dropdown ha-assist-chip {
|
||||||
--md-assist-chip-trailing-space: 8px;
|
--md-assist-chip-trailing-space: 8px;
|
||||||
}
|
}
|
||||||
ha-label {
|
ha-label {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
|
import "@home-assistant/webawesome/dist/components/divider/divider";
|
||||||
import { consume } from "@lit/context";
|
import { consume } from "@lit/context";
|
||||||
import {
|
import {
|
||||||
mdiAlertCircle,
|
mdiAlertCircle,
|
||||||
mdiCancel,
|
mdiCancel,
|
||||||
mdiChevronRight,
|
|
||||||
mdiDelete,
|
mdiDelete,
|
||||||
mdiDotsVertical,
|
mdiDotsVertical,
|
||||||
mdiEye,
|
mdiEye,
|
||||||
@@ -42,6 +42,7 @@ import {
|
|||||||
PROTOCOL_INTEGRATIONS,
|
PROTOCOL_INTEGRATIONS,
|
||||||
protocolIntegrationPicked,
|
protocolIntegrationPicked,
|
||||||
} from "../../../common/integrations/protocolIntegrationPicked";
|
} from "../../../common/integrations/protocolIntegrationPicked";
|
||||||
|
import { slugify } from "../../../common/string/slugify";
|
||||||
import type { LocalizeFunc } from "../../../common/translations/localize";
|
import type { LocalizeFunc } from "../../../common/translations/localize";
|
||||||
import {
|
import {
|
||||||
hasRejectedItems,
|
hasRejectedItems,
|
||||||
@@ -55,8 +56,9 @@ import type {
|
|||||||
} from "../../../components/data-table/ha-data-table";
|
} from "../../../components/data-table/ha-data-table";
|
||||||
import "../../../components/data-table/ha-data-table-labels";
|
import "../../../components/data-table/ha-data-table-labels";
|
||||||
import "../../../components/ha-alert";
|
import "../../../components/ha-alert";
|
||||||
import "../../../components/ha-button-menu";
|
import "../../../components/ha-dropdown";
|
||||||
import "../../../components/ha-check-list-item";
|
import "../../../components/ha-dropdown-item";
|
||||||
|
import type { HaDropdownItem } from "../../../components/ha-dropdown-item";
|
||||||
import "../../../components/ha-filter-devices";
|
import "../../../components/ha-filter-devices";
|
||||||
import "../../../components/ha-filter-domains";
|
import "../../../components/ha-filter-domains";
|
||||||
import "../../../components/ha-filter-floor-areas";
|
import "../../../components/ha-filter-floor-areas";
|
||||||
@@ -65,9 +67,6 @@ import "../../../components/ha-filter-labels";
|
|||||||
import "../../../components/ha-filter-states";
|
import "../../../components/ha-filter-states";
|
||||||
import "../../../components/ha-icon";
|
import "../../../components/ha-icon";
|
||||||
import "../../../components/ha-icon-button";
|
import "../../../components/ha-icon-button";
|
||||||
import "../../../components/ha-md-divider";
|
|
||||||
import "../../../components/ha-md-menu-item";
|
|
||||||
import "../../../components/ha-sub-menu";
|
|
||||||
import "../../../components/ha-svg-icon";
|
import "../../../components/ha-svg-icon";
|
||||||
import "../../../components/ha-tooltip";
|
import "../../../components/ha-tooltip";
|
||||||
import type { ConfigEntry, SubEntry } from "../../../data/config_entries";
|
import type { ConfigEntry, SubEntry } from "../../../data/config_entries";
|
||||||
@@ -114,7 +113,6 @@ import { isHelperDomain } from "../helpers/const";
|
|||||||
import "../integrations/ha-integration-overflow-menu";
|
import "../integrations/ha-integration-overflow-menu";
|
||||||
import { showAddIntegrationDialog } from "../integrations/show-add-integration-dialog";
|
import { showAddIntegrationDialog } from "../integrations/show-add-integration-dialog";
|
||||||
import { showLabelDetailDialog } from "../labels/show-dialog-label-detail";
|
import { showLabelDetailDialog } from "../labels/show-dialog-label-detail";
|
||||||
import { slugify } from "../../../common/string/slugify";
|
|
||||||
|
|
||||||
export interface StateEntity extends Omit<
|
export interface StateEntity extends Omit<
|
||||||
EntityRegistryEntry,
|
EntityRegistryEntry,
|
||||||
@@ -748,6 +746,48 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _renderLabelItems = (submenu = false) =>
|
||||||
|
html` ${this._labels?.map((label) => {
|
||||||
|
const color = label.color ? computeCssColor(label.color) : undefined;
|
||||||
|
const selected = this._selected.every((entityId) =>
|
||||||
|
this.hass.entities[entityId]?.labels.includes(label.label_id)
|
||||||
|
);
|
||||||
|
const partial =
|
||||||
|
!selected &&
|
||||||
|
this._selected.some((entityId) =>
|
||||||
|
this.hass.entities[entityId]?.labels.includes(label.label_id)
|
||||||
|
);
|
||||||
|
return html`<ha-dropdown-item
|
||||||
|
.slot=${submenu ? "submenu" : ""}
|
||||||
|
.value=${label.label_id}
|
||||||
|
data-action=${selected ? "remove" : "add"}
|
||||||
|
@click=${this._handleLabelMenuSelect}
|
||||||
|
>
|
||||||
|
<ha-checkbox
|
||||||
|
slot="icon"
|
||||||
|
.checked=${selected}
|
||||||
|
.indeterminate=${partial}
|
||||||
|
reducedTouchTarget
|
||||||
|
></ha-checkbox>
|
||||||
|
<ha-label
|
||||||
|
style=${color ? `--color: ${color}` : ""}
|
||||||
|
.description=${label.description}
|
||||||
|
>
|
||||||
|
${label.icon
|
||||||
|
? html`<ha-icon slot="icon" .icon=${label.icon}></ha-icon>`
|
||||||
|
: nothing}
|
||||||
|
${label.name}
|
||||||
|
</ha-label>
|
||||||
|
</ha-dropdown-item>`;
|
||||||
|
})}
|
||||||
|
<wa-divider .slot=${submenu ? "submenu" : ""}></wa-divider>
|
||||||
|
<ha-dropdown-item
|
||||||
|
@click=${this._handleCreateLabel}
|
||||||
|
.slot=${submenu ? "submenu" : ""}
|
||||||
|
>
|
||||||
|
${this.hass.localize("ui.panel.config.labels.add_label")}
|
||||||
|
</ha-dropdown-item>`;
|
||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
if (!this.hass || this._entities === undefined) {
|
if (!this.hass || this._entities === undefined) {
|
||||||
return html` <hass-loading-screen></hass-loading-screen> `;
|
return html` <hass-loading-screen></hass-loading-screen> `;
|
||||||
@@ -772,53 +812,13 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) {
|
|||||||
[...filteredDomains][0]
|
[...filteredDomains][0]
|
||||||
);
|
);
|
||||||
|
|
||||||
const labelItems = html` ${this._labels?.map((label) => {
|
|
||||||
const color = label.color ? computeCssColor(label.color) : undefined;
|
|
||||||
const selected = this._selected.every((entityId) =>
|
|
||||||
this.hass.entities[entityId]?.labels.includes(label.label_id)
|
|
||||||
);
|
|
||||||
const partial =
|
|
||||||
!selected &&
|
|
||||||
this._selected.some((entityId) =>
|
|
||||||
this.hass.entities[entityId]?.labels.includes(label.label_id)
|
|
||||||
);
|
|
||||||
return html`<ha-md-menu-item
|
|
||||||
.value=${label.label_id}
|
|
||||||
.action=${selected ? "remove" : "add"}
|
|
||||||
@click=${this._handleBulkLabel}
|
|
||||||
keep-open
|
|
||||||
>
|
|
||||||
<ha-checkbox
|
|
||||||
slot="start"
|
|
||||||
.checked=${selected}
|
|
||||||
.indeterminate=${partial}
|
|
||||||
reducedTouchTarget
|
|
||||||
></ha-checkbox>
|
|
||||||
<ha-label
|
|
||||||
style=${color ? `--color: ${color}` : ""}
|
|
||||||
.description=${label.description}
|
|
||||||
>
|
|
||||||
${label.icon
|
|
||||||
? html`<ha-icon slot="icon" .icon=${label.icon}></ha-icon>`
|
|
||||||
: nothing}
|
|
||||||
${label.name}
|
|
||||||
</ha-label>
|
|
||||||
</ha-md-menu-item>`;
|
|
||||||
})}
|
|
||||||
<ha-md-divider role="separator" tabindex="-1"></ha-md-divider>
|
|
||||||
<ha-md-menu-item .clickAction=${this._bulkCreateLabel}>
|
|
||||||
<div slot="headline">
|
|
||||||
${this.hass.localize("ui.panel.config.labels.add_label")}
|
|
||||||
</div></ha-md-menu-item
|
|
||||||
>`;
|
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<hass-tabs-subpage-data-table
|
<hass-tabs-subpage-data-table
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.narrow=${this.narrow}
|
.narrow=${this.narrow}
|
||||||
.backPath=${
|
.backPath=${this._searchParms.has("historyBack")
|
||||||
this._searchParms.has("historyBack") ? undefined : "/config"
|
? undefined
|
||||||
}
|
: "/config"}
|
||||||
.route=${this.route}
|
.route=${this.route}
|
||||||
.tabs=${configSections.devices}
|
.tabs=${configSections.devices}
|
||||||
.columns=${this._columns(this.hass.localize)}
|
.columns=${this._columns(this.hass.localize)}
|
||||||
@@ -828,16 +828,14 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) {
|
|||||||
{ number: filteredEntities.length }
|
{ number: filteredEntities.length }
|
||||||
)}
|
)}
|
||||||
has-filters
|
has-filters
|
||||||
.filters=${
|
.filters=${Object.values(this._filters).filter((filter) =>
|
||||||
Object.values(this._filters).filter((filter) =>
|
|
||||||
Array.isArray(filter)
|
Array.isArray(filter)
|
||||||
? filter.length
|
? filter.length
|
||||||
: filter &&
|
: filter &&
|
||||||
Object.values(filter).some((val) =>
|
Object.values(filter).some((val) =>
|
||||||
Array.isArray(val) ? val.length : val
|
Array.isArray(val) ? val.length : val
|
||||||
)
|
)
|
||||||
).length
|
).length}
|
||||||
}
|
|
||||||
selectable
|
selectable
|
||||||
.selected=${this._selected.length}
|
.selected=${this._selected.length}
|
||||||
.initialGroupColumn=${this._activeGrouping ?? "device_full"}
|
.initialGroupColumn=${this._activeGrouping ?? "device_full"}
|
||||||
@@ -864,32 +862,37 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) {
|
|||||||
slot="toolbar-icon"
|
slot="toolbar-icon"
|
||||||
></ha-integration-overflow-menu>
|
></ha-integration-overflow-menu>
|
||||||
|
|
||||||
|
${!this.narrow
|
||||||
${
|
? html`<ha-dropdown slot="selection-bar">
|
||||||
!this.narrow
|
|
||||||
? html`<ha-md-button-menu slot="selection-bar">
|
|
||||||
<ha-assist-chip
|
<ha-assist-chip
|
||||||
slot="trigger"
|
slot="trigger"
|
||||||
.label=${this.hass.localize(
|
.label=${this.hass.localize(
|
||||||
"ui.panel.config.automation.picker.bulk_actions.add_label"
|
"ui.panel.config.automation.picker.bulk_actions.add_label"
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<ha-svg-icon slot="trailing-icon" .path=${mdiMenuDown}></ha-svg-icon>
|
<ha-svg-icon
|
||||||
|
slot="trailing-icon"
|
||||||
|
.path=${mdiMenuDown}
|
||||||
|
></ha-svg-icon>
|
||||||
</ha-assist-chip>
|
</ha-assist-chip>
|
||||||
${labelItems}
|
${this._renderLabelItems()}
|
||||||
</ha-md-button-menu>`
|
</ha-dropdown>`
|
||||||
: nothing
|
: nothing}
|
||||||
}
|
<ha-dropdown
|
||||||
<ha-md-button-menu has-overflow slot="selection-bar">
|
slot="selection-bar"
|
||||||
${
|
@wa-select=${this._handleOverflowMenuSelect}
|
||||||
this.narrow
|
>
|
||||||
|
${this.narrow
|
||||||
? html`<ha-assist-chip
|
? html`<ha-assist-chip
|
||||||
.label=${this.hass.localize(
|
.label=${this.hass.localize(
|
||||||
"ui.panel.config.automation.picker.bulk_action"
|
"ui.panel.config.automation.picker.bulk_action"
|
||||||
)}
|
)}
|
||||||
slot="trigger"
|
slot="trigger"
|
||||||
>
|
>
|
||||||
<ha-svg-icon slot="trailing-icon" .path=${mdiMenuDown}></ha-svg-icon>
|
<ha-svg-icon
|
||||||
|
slot="trailing-icon"
|
||||||
|
.path=${mdiMenuDown}
|
||||||
|
></ha-svg-icon>
|
||||||
</ha-assist-chip>`
|
</ha-assist-chip>`
|
||||||
: html`<ha-icon-button
|
: html`<ha-icon-button
|
||||||
.path=${mdiDotsVertical}
|
.path=${mdiDotsVertical}
|
||||||
@@ -897,105 +900,65 @@ ${
|
|||||||
"ui.panel.config.automation.picker.bulk_action"
|
"ui.panel.config.automation.picker.bulk_action"
|
||||||
)}
|
)}
|
||||||
slot="trigger"
|
slot="trigger"
|
||||||
></ha-icon-button>`
|
></ha-icon-button>`}
|
||||||
}
|
${this.narrow
|
||||||
<ha-svg-icon
|
? html`<ha-dropdown-item>
|
||||||
slot="trailing-icon"
|
|
||||||
.path=${mdiMenuDown}
|
|
||||||
></ha-svg-icon
|
|
||||||
></ha-assist-chip>
|
|
||||||
${
|
|
||||||
this.narrow
|
|
||||||
? html`<ha-sub-menu>
|
|
||||||
<ha-md-menu-item slot="item">
|
|
||||||
<div slot="headline">
|
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.automation.picker.bulk_actions.add_label"
|
"ui.panel.config.automation.picker.bulk_actions.add_label"
|
||||||
)}
|
)}
|
||||||
</div>
|
${this._renderLabelItems(true)}
|
||||||
<ha-svg-icon slot="end" .path=${mdiChevronRight}></ha-svg-icon>
|
</ha-dropdown-item>`
|
||||||
</ha-md-menu-item>
|
: nothing}
|
||||||
<ha-md-menu slot="menu">${labelItems}</ha-md-menu>
|
|
||||||
</ha-sub-menu>
|
|
||||||
<ha-md-divider role="separator" tabindex="-1"></ha-md-divider>`
|
|
||||||
: nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
<ha-md-menu-item .clickAction=${this._enableSelected}>
|
<ha-dropdown-item value="enable">
|
||||||
<ha-svg-icon slot="start" .path=${mdiToggleSwitch}></ha-svg-icon>
|
<ha-svg-icon slot="icon" .path=${mdiToggleSwitch}></ha-svg-icon>
|
||||||
<div slot="headline">
|
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.entities.picker.enable_selected.button"
|
"ui.panel.config.entities.picker.enable_selected.button"
|
||||||
)}
|
)}
|
||||||
</div>
|
</ha-dropdown-item>
|
||||||
</ha-md-menu-item>
|
<ha-dropdown-item value="disable">
|
||||||
<ha-md-menu-item .clickAction=${this._disableSelected}>
|
|
||||||
<ha-svg-icon
|
<ha-svg-icon
|
||||||
slot="start"
|
slot="icon"
|
||||||
.path=${mdiToggleSwitchOffOutline}
|
.path=${mdiToggleSwitchOffOutline}
|
||||||
></ha-svg-icon>
|
></ha-svg-icon>
|
||||||
<div slot="headline">
|
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.entities.picker.disable_selected.button"
|
"ui.panel.config.entities.picker.disable_selected.button"
|
||||||
)}
|
)}
|
||||||
</div>
|
</ha-dropdown-item>
|
||||||
</ha-md-menu-item>
|
<wa-divider></wa-divider>
|
||||||
<ha-md-divider role="separator" tabindex="-1"></ha-md-divider>
|
|
||||||
|
|
||||||
<ha-md-menu-item .clickAction=${this._unhideSelected}>
|
<ha-dropdown-item value="unhide">
|
||||||
<ha-svg-icon
|
<ha-svg-icon slot="icon" .path=${mdiEye}></ha-svg-icon>
|
||||||
slot="start"
|
|
||||||
.path=${mdiEye}
|
|
||||||
></ha-svg-icon>
|
|
||||||
<div slot="headline">
|
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.entities.picker.unhide_selected.button"
|
"ui.panel.config.entities.picker.unhide_selected.button"
|
||||||
)}
|
)}
|
||||||
</div>
|
</ha-dropdown-item>
|
||||||
</ha-md-menu-item>
|
<ha-dropdown-item value="hide">
|
||||||
<ha-md-menu-item .clickAction=${this._hideSelected}>
|
<ha-svg-icon slot="icon" .path=${mdiEyeOff}></ha-svg-icon>
|
||||||
<ha-svg-icon
|
|
||||||
slot="start"
|
|
||||||
.path=${mdiEyeOff}
|
|
||||||
></ha-svg-icon>
|
|
||||||
<div slot="headline">
|
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.entities.picker.hide_selected.button"
|
"ui.panel.config.entities.picker.hide_selected.button"
|
||||||
)}
|
)}
|
||||||
</div>
|
</ha-dropdown-item>
|
||||||
</ha-md-menu-item>
|
|
||||||
|
|
||||||
<ha-md-divider role="separator" tabindex="-1"></ha-md-divider>
|
<wa-divider></wa-divider>
|
||||||
|
|
||||||
<ha-md-menu-item .clickAction=${this._restoreEntityIdSelected}>
|
<ha-dropdown-item value="restore_entity_id">
|
||||||
<ha-svg-icon
|
<ha-svg-icon slot="icon" .path=${mdiRestore}></ha-svg-icon>
|
||||||
slot="start"
|
|
||||||
.path=${mdiRestore}
|
|
||||||
></ha-svg-icon>
|
|
||||||
<div slot="headline">
|
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.entities.picker.restore_entity_id_selected.button"
|
"ui.panel.config.entities.picker.restore_entity_id_selected.button"
|
||||||
)}
|
)}
|
||||||
</div>
|
</ha-dropdown-item>
|
||||||
</ha-md-menu-item>
|
|
||||||
|
|
||||||
<ha-md-divider role="separator" tabindex="-1"></ha-md-divider>
|
<wa-divider></wa-divider>
|
||||||
|
|
||||||
<ha-md-menu-item .clickAction=${this._removeSelected} class="warning">
|
<ha-dropdown-item value="remove" variant="danger">
|
||||||
<ha-svg-icon
|
<ha-svg-icon slot="icon" .path=${mdiDelete}></ha-svg-icon>
|
||||||
slot="start"
|
|
||||||
.path=${mdiDelete}
|
|
||||||
></ha-svg-icon>
|
|
||||||
<div slot="headline">
|
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.entities.picker.delete_selected.button"
|
"ui.panel.config.entities.picker.delete_selected.button"
|
||||||
)}
|
)}
|
||||||
</div>
|
</ha-dropdown-item>
|
||||||
</ha-md-menu-item>
|
</ha-dropdown>
|
||||||
|
${Array.isArray(this._filters.config_entry) &&
|
||||||
</ha-md-button-menu>
|
|
||||||
${
|
|
||||||
Array.isArray(this._filters.config_entry) &&
|
|
||||||
this._filters.config_entry.length
|
this._filters.config_entry.length
|
||||||
? html`<ha-alert slot="filter-pane">
|
? html`<ha-alert slot="filter-pane">
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
@@ -1008,13 +971,11 @@ ${
|
|||||||
Array.isArray(this._filters.sub_entry) &&
|
Array.isArray(this._filters.sub_entry) &&
|
||||||
this._filters.sub_entry.length
|
this._filters.sub_entry.length
|
||||||
? html` (${this._subEntries?.find(
|
? html` (${this._subEntries?.find(
|
||||||
(entry) =>
|
(entry) => entry.subentry_id === this._filters.sub_entry![0]
|
||||||
entry.subentry_id === this._filters.sub_entry![0]
|
|
||||||
)?.title || this._filters.sub_entry[0]})`
|
)?.title || this._filters.sub_entry[0]})`
|
||||||
: nothing}
|
: nothing}
|
||||||
</ha-alert>`
|
</ha-alert>`
|
||||||
: nothing
|
: nothing}
|
||||||
}
|
|
||||||
<ha-filter-floor-areas
|
<ha-filter-floor-areas
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
type="entity"
|
type="entity"
|
||||||
@@ -1075,20 +1036,16 @@ ${
|
|||||||
.narrow=${this.narrow}
|
.narrow=${this.narrow}
|
||||||
@expanded-changed=${this._filterExpanded}
|
@expanded-changed=${this._filterExpanded}
|
||||||
></ha-filter-labels>
|
></ha-filter-labels>
|
||||||
${
|
${includeAddDeviceFab
|
||||||
includeAddDeviceFab
|
|
||||||
? html`<ha-fab
|
? html`<ha-fab
|
||||||
.label=${this.hass.localize(
|
.label=${this.hass.localize("ui.panel.config.devices.add_device")}
|
||||||
"ui.panel.config.devices.add_device"
|
|
||||||
)}
|
|
||||||
extended
|
extended
|
||||||
@click=${this._addDevice}
|
@click=${this._addDevice}
|
||||||
slot="fab"
|
slot="fab"
|
||||||
>
|
>
|
||||||
<ha-svg-icon slot="icon" .path=${mdiPlus}></ha-svg-icon>
|
<ha-svg-icon slot="icon" .path=${mdiPlus}></ha-svg-icon>
|
||||||
</ha-fab>`
|
</ha-fab>`
|
||||||
: nothing
|
: nothing}
|
||||||
}
|
|
||||||
</hass-tabs-subpage-data-table>
|
</hass-tabs-subpage-data-table>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
@@ -1222,6 +1179,44 @@ ${
|
|||||||
this._selected = ev.detail.value;
|
this._selected = ev.detail.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _handleLabelMenuSelect(ev: CustomEvent) {
|
||||||
|
ev.stopPropagation();
|
||||||
|
const item = ev.currentTarget as HaDropdownItem;
|
||||||
|
|
||||||
|
const label = item.value as string;
|
||||||
|
const action = (item as HTMLElement).dataset.action as "add" | "remove";
|
||||||
|
this._bulkLabel(label, action);
|
||||||
|
}
|
||||||
|
|
||||||
|
private _handleCreateLabel() {
|
||||||
|
this._bulkCreateLabel();
|
||||||
|
}
|
||||||
|
|
||||||
|
private _handleOverflowMenuSelect(ev: CustomEvent) {
|
||||||
|
const item = ev.detail.item as HaDropdownItem;
|
||||||
|
|
||||||
|
switch (item.value) {
|
||||||
|
case "enable":
|
||||||
|
this._enableSelected();
|
||||||
|
break;
|
||||||
|
case "disable":
|
||||||
|
this._disableSelected();
|
||||||
|
break;
|
||||||
|
case "unhide":
|
||||||
|
this._unhideSelected();
|
||||||
|
break;
|
||||||
|
case "hide":
|
||||||
|
this._hideSelected();
|
||||||
|
break;
|
||||||
|
case "remove":
|
||||||
|
this._removeSelected();
|
||||||
|
break;
|
||||||
|
case "restore_entity_id":
|
||||||
|
this._restoreEntityIdSelected();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private _enableSelected = async () => {
|
private _enableSelected = async () => {
|
||||||
showConfirmationDialog(this, {
|
showConfirmationDialog(this, {
|
||||||
title: this.hass.localize(
|
title: this.hass.localize(
|
||||||
@@ -1345,12 +1340,6 @@ ${
|
|||||||
this._clearSelection();
|
this._clearSelection();
|
||||||
};
|
};
|
||||||
|
|
||||||
private async _handleBulkLabel(ev) {
|
|
||||||
const label = ev.currentTarget.value;
|
|
||||||
const action = ev.currentTarget.action;
|
|
||||||
await this._bulkLabel(label, action);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async _bulkLabel(label: string, action: "add" | "remove") {
|
private async _bulkLabel(label: string, action: "add" | "remove") {
|
||||||
const promises: Promise<UpdateEntityRegistryEntryResult>[] = [];
|
const promises: Promise<UpdateEntityRegistryEntryResult>[] = [];
|
||||||
this._selected.forEach((entityId) => {
|
this._selected.forEach((entityId) => {
|
||||||
@@ -1612,7 +1601,7 @@ ${rejected
|
|||||||
ha-assist-chip {
|
ha-assist-chip {
|
||||||
--ha-assist-chip-container-shape: 10px;
|
--ha-assist-chip-container-shape: 10px;
|
||||||
}
|
}
|
||||||
ha-md-button-menu ha-assist-chip {
|
ha-dropdown ha-assist-chip {
|
||||||
--md-assist-chip-trailing-space: 8px;
|
--md-assist-chip-trailing-space: 8px;
|
||||||
}
|
}
|
||||||
ha-label {
|
ha-label {
|
||||||
|
|||||||
@@ -1,37 +1,39 @@
|
|||||||
import { consume } from "@lit/context";
|
import "@home-assistant/webawesome/dist/components/divider/divider";
|
||||||
import { ResizeController } from "@lit-labs/observers/resize-controller";
|
import { ResizeController } from "@lit-labs/observers/resize-controller";
|
||||||
|
import { consume } from "@lit/context";
|
||||||
import {
|
import {
|
||||||
mdiAlertCircle,
|
mdiAlertCircle,
|
||||||
mdiCancel,
|
mdiCancel,
|
||||||
mdiChevronRight,
|
|
||||||
mdiCog,
|
mdiCog,
|
||||||
mdiDelete,
|
mdiDelete,
|
||||||
mdiDotsVertical,
|
mdiDotsVertical,
|
||||||
|
mdiDownload,
|
||||||
mdiMenuDown,
|
mdiMenuDown,
|
||||||
mdiPencilOff,
|
mdiPencilOff,
|
||||||
mdiProgressHelper,
|
|
||||||
mdiPlus,
|
mdiPlus,
|
||||||
|
mdiProgressHelper,
|
||||||
mdiTag,
|
mdiTag,
|
||||||
mdiTrashCan,
|
mdiTrashCan,
|
||||||
mdiDownload,
|
|
||||||
} from "@mdi/js";
|
} from "@mdi/js";
|
||||||
import type { HassEntity } from "home-assistant-js-websocket";
|
import type { HassEntity } from "home-assistant-js-websocket";
|
||||||
import type { CSSResultGroup, PropertyValues, TemplateResult } from "lit";
|
import type { CSSResultGroup, PropertyValues, TemplateResult } from "lit";
|
||||||
import { LitElement, css, html, nothing } from "lit";
|
import { LitElement, css, html, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
import { debounce } from "../../../common/util/debounce";
|
|
||||||
import { computeCssColor } from "../../../common/color/compute-color";
|
import { computeCssColor } from "../../../common/color/compute-color";
|
||||||
|
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
|
||||||
import { storage } from "../../../common/decorators/storage";
|
import { storage } from "../../../common/decorators/storage";
|
||||||
import type { HASSDomEvent } from "../../../common/dom/fire_event";
|
import type { HASSDomEvent } from "../../../common/dom/fire_event";
|
||||||
import { computeStateDomain } from "../../../common/entity/compute_state_domain";
|
|
||||||
import { computeAreaName } from "../../../common/entity/compute_area_name";
|
import { computeAreaName } from "../../../common/entity/compute_area_name";
|
||||||
|
import { computeStateDomain } from "../../../common/entity/compute_state_domain";
|
||||||
import { navigate } from "../../../common/navigate";
|
import { navigate } from "../../../common/navigate";
|
||||||
|
import { slugify } from "../../../common/string/slugify";
|
||||||
import type {
|
import type {
|
||||||
LocalizeFunc,
|
LocalizeFunc,
|
||||||
LocalizeKeys,
|
LocalizeKeys,
|
||||||
} from "../../../common/translations/localize";
|
} from "../../../common/translations/localize";
|
||||||
import { extractSearchParam } from "../../../common/url/search-params";
|
import { extractSearchParam } from "../../../common/url/search-params";
|
||||||
|
import { debounce } from "../../../common/util/debounce";
|
||||||
import {
|
import {
|
||||||
hasRejectedItems,
|
hasRejectedItems,
|
||||||
rejectedItems,
|
rejectedItems,
|
||||||
@@ -43,6 +45,9 @@ import type {
|
|||||||
SortingChangedEvent,
|
SortingChangedEvent,
|
||||||
} from "../../../components/data-table/ha-data-table";
|
} from "../../../components/data-table/ha-data-table";
|
||||||
import "../../../components/data-table/ha-data-table-labels";
|
import "../../../components/data-table/ha-data-table-labels";
|
||||||
|
import "../../../components/ha-dropdown";
|
||||||
|
import "../../../components/ha-dropdown-item";
|
||||||
|
import type { HaDropdownItem } from "../../../components/ha-dropdown-item";
|
||||||
import "../../../components/ha-fab";
|
import "../../../components/ha-fab";
|
||||||
import "../../../components/ha-filter-categories";
|
import "../../../components/ha-filter-categories";
|
||||||
import "../../../components/ha-filter-devices";
|
import "../../../components/ha-filter-devices";
|
||||||
@@ -51,10 +56,12 @@ import "../../../components/ha-filter-floor-areas";
|
|||||||
import "../../../components/ha-filter-labels";
|
import "../../../components/ha-filter-labels";
|
||||||
import "../../../components/ha-icon";
|
import "../../../components/ha-icon";
|
||||||
import "../../../components/ha-icon-overflow-menu";
|
import "../../../components/ha-icon-overflow-menu";
|
||||||
import "../../../components/ha-md-divider";
|
import "../../../components/ha-md-menu";
|
||||||
import "../../../components/ha-state-icon";
|
import "../../../components/ha-state-icon";
|
||||||
|
import "../../../components/ha-sub-menu";
|
||||||
import "../../../components/ha-svg-icon";
|
import "../../../components/ha-svg-icon";
|
||||||
import "../../../components/ha-tooltip";
|
import "../../../components/ha-tooltip";
|
||||||
|
import { getSignedPath } from "../../../data/auth";
|
||||||
import type { CategoryRegistryEntry } from "../../../data/category_registry";
|
import type { CategoryRegistryEntry } from "../../../data/category_registry";
|
||||||
import {
|
import {
|
||||||
createCategoryRegistryEntry,
|
createCategoryRegistryEntry,
|
||||||
@@ -72,6 +79,10 @@ import type {
|
|||||||
DataTableFiltersItems,
|
DataTableFiltersItems,
|
||||||
DataTableFiltersValues,
|
DataTableFiltersValues,
|
||||||
} from "../../../data/data_table_filters";
|
} from "../../../data/data_table_filters";
|
||||||
|
import {
|
||||||
|
fetchDiagnosticHandlers,
|
||||||
|
getConfigEntryDiagnosticsDownloadUrl,
|
||||||
|
} from "../../../data/diagnostics";
|
||||||
import type {
|
import type {
|
||||||
EntityRegistryEntry,
|
EntityRegistryEntry,
|
||||||
UpdateEntityRegistryEntryResult,
|
UpdateEntityRegistryEntryResult,
|
||||||
@@ -82,6 +93,7 @@ import {
|
|||||||
updateEntityRegistryEntry,
|
updateEntityRegistryEntry,
|
||||||
} from "../../../data/entity_registry";
|
} from "../../../data/entity_registry";
|
||||||
import { fetchEntitySourcesWithCache } from "../../../data/entity_sources";
|
import { fetchEntitySourcesWithCache } from "../../../data/entity_sources";
|
||||||
|
import { HELPERS_CRUD } from "../../../data/helpers_crud";
|
||||||
import type { IntegrationManifest } from "../../../data/integration";
|
import type { IntegrationManifest } from "../../../data/integration";
|
||||||
import {
|
import {
|
||||||
domainToName,
|
domainToName,
|
||||||
@@ -105,23 +117,15 @@ import "../../../layouts/hass-tabs-subpage-data-table";
|
|||||||
import { SubscribeMixin } from "../../../mixins/subscribe-mixin";
|
import { SubscribeMixin } from "../../../mixins/subscribe-mixin";
|
||||||
import { haStyle } from "../../../resources/styles";
|
import { haStyle } from "../../../resources/styles";
|
||||||
import type { HomeAssistant, Route } from "../../../types";
|
import type { HomeAssistant, Route } from "../../../types";
|
||||||
|
import { fileDownload } from "../../../util/file_download";
|
||||||
import { showAssignCategoryDialog } from "../category/show-dialog-assign-category";
|
import { showAssignCategoryDialog } from "../category/show-dialog-assign-category";
|
||||||
import { showCategoryRegistryDetailDialog } from "../category/show-dialog-category-registry-detail";
|
import { showCategoryRegistryDetailDialog } from "../category/show-dialog-category-registry-detail";
|
||||||
import { configSections } from "../ha-panel-config";
|
import { configSections } from "../ha-panel-config";
|
||||||
import "../integrations/ha-integration-overflow-menu";
|
|
||||||
import { renderConfigEntryError } from "../integrations/ha-config-integration-page";
|
import { renderConfigEntryError } from "../integrations/ha-config-integration-page";
|
||||||
|
import "../integrations/ha-integration-overflow-menu";
|
||||||
import { showLabelDetailDialog } from "../labels/show-dialog-label-detail";
|
import { showLabelDetailDialog } from "../labels/show-dialog-label-detail";
|
||||||
import { isHelperDomain, type HelperDomain } from "./const";
|
import { isHelperDomain, type HelperDomain } from "./const";
|
||||||
import { showHelperDetailDialog } from "./show-dialog-helper-detail";
|
import { showHelperDetailDialog } from "./show-dialog-helper-detail";
|
||||||
import { slugify } from "../../../common/string/slugify";
|
|
||||||
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
|
|
||||||
import { HELPERS_CRUD } from "../../../data/helpers_crud";
|
|
||||||
import {
|
|
||||||
fetchDiagnosticHandlers,
|
|
||||||
getConfigEntryDiagnosticsDownloadUrl,
|
|
||||||
} from "../../../data/diagnostics";
|
|
||||||
import { getSignedPath } from "../../../data/auth";
|
|
||||||
import { fileDownload } from "../../../util/file_download";
|
|
||||||
|
|
||||||
interface HelperItem {
|
interface HelperItem {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -606,42 +610,35 @@ export class HaConfigHelpers extends SubscribeMixin(LitElement) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
private _renderCategoryItems = (submenu = false) =>
|
||||||
if (
|
html`${this._categories?.map(
|
||||||
!this.hass ||
|
|
||||||
this._stateItems === undefined ||
|
|
||||||
this._entityEntries === undefined ||
|
|
||||||
this._configEntries === undefined
|
|
||||||
) {
|
|
||||||
return html`<hass-loading-screen></hass-loading-screen>`;
|
|
||||||
}
|
|
||||||
|
|
||||||
const categoryItems = html`${this._categories?.map(
|
|
||||||
(category) =>
|
(category) =>
|
||||||
html`<ha-md-menu-item
|
html`<ha-dropdown-item
|
||||||
.value=${category.category_id}
|
.slot=${submenu ? "submenu" : ""}
|
||||||
.clickAction=${this._handleBulkCategory}
|
value="move_category"
|
||||||
|
data-category=${category.category_id}
|
||||||
>
|
>
|
||||||
${category.icon
|
${category.icon
|
||||||
? html`<ha-icon slot="start" .icon=${category.icon}></ha-icon>`
|
? html`<ha-icon slot="icon" .icon=${category.icon}></ha-icon>`
|
||||||
: html`<ha-svg-icon slot="start" .path=${mdiTag}></ha-svg-icon>`}
|
: html`<ha-svg-icon slot="icon" .path=${mdiTag}></ha-svg-icon>`}
|
||||||
<div slot="headline">${category.name}</div>
|
${category.name}
|
||||||
</ha-md-menu-item>`
|
</ha-dropdown-item>`
|
||||||
)}
|
)}
|
||||||
<ha-md-menu-item .value=${null} .clickAction=${this._handleBulkCategory}>
|
<ha-dropdown-item .slot=${submenu ? "submenu" : ""} value="no_category">
|
||||||
<div slot="headline">
|
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.automation.picker.bulk_actions.no_category"
|
"ui.panel.config.automation.picker.bulk_actions.no_category"
|
||||||
)}
|
)}
|
||||||
</div>
|
</ha-dropdown-item>
|
||||||
</ha-md-menu-item>
|
<wa-divider .slot=${submenu ? "submenu" : ""}></wa-divider>
|
||||||
<ha-md-divider role="separator" tabindex="-1"></ha-md-divider>
|
<ha-dropdown-item
|
||||||
<ha-md-menu-item .clickAction=${this._bulkCreateCategory}>
|
.slot=${submenu ? "submenu" : ""}
|
||||||
<div slot="headline">
|
value="create_category"
|
||||||
|
>
|
||||||
${this.hass.localize("ui.panel.config.category.editor.add")}
|
${this.hass.localize("ui.panel.config.category.editor.add")}
|
||||||
</div>
|
</ha-dropdown-item>`;
|
||||||
</ha-md-menu-item>`;
|
|
||||||
const labelItems = html`${this._labels?.map((label) => {
|
private _renderLabelItems = (submenu = false) =>
|
||||||
|
html`${this._labels?.map((label) => {
|
||||||
const color = label.color ? computeCssColor(label.color) : undefined;
|
const color = label.color ? computeCssColor(label.color) : undefined;
|
||||||
const selected = this._selected.every((entityId) =>
|
const selected = this._selected.every((entityId) =>
|
||||||
this._labelsForEntity(entityId).includes(label.label_id)
|
this._labelsForEntity(entityId).includes(label.label_id)
|
||||||
@@ -651,14 +648,14 @@ export class HaConfigHelpers extends SubscribeMixin(LitElement) {
|
|||||||
this._selected.some((entityId) =>
|
this._selected.some((entityId) =>
|
||||||
this._labelsForEntity(entityId).includes(label.label_id)
|
this._labelsForEntity(entityId).includes(label.label_id)
|
||||||
);
|
);
|
||||||
return html`<ha-md-menu-item
|
return html`<ha-dropdown-item
|
||||||
|
@click=${this._handleLabelMenuSelect}
|
||||||
|
.slot=${submenu ? "submenu" : ""}
|
||||||
.value=${label.label_id}
|
.value=${label.label_id}
|
||||||
.action=${selected ? "remove" : "add"}
|
data-action=${selected ? "remove" : "add"}
|
||||||
@click=${this._handleBulkLabel}
|
|
||||||
keep-open
|
|
||||||
>
|
>
|
||||||
<ha-checkbox
|
<ha-checkbox
|
||||||
slot="start"
|
slot="icon"
|
||||||
.checked=${selected}
|
.checked=${selected}
|
||||||
.indeterminate=${partial}
|
.indeterminate=${partial}
|
||||||
reducedTouchTarget
|
reducedTouchTarget
|
||||||
@@ -672,13 +669,25 @@ export class HaConfigHelpers extends SubscribeMixin(LitElement) {
|
|||||||
: nothing}
|
: nothing}
|
||||||
${label.name}
|
${label.name}
|
||||||
</ha-label>
|
</ha-label>
|
||||||
</ha-md-menu-item> `;
|
</ha-dropdown-item>`;
|
||||||
})}<ha-md-divider role="separator" tabindex="-1"></ha-md-divider>
|
})}<wa-divider .slot=${submenu ? "submenu" : ""}></wa-divider>
|
||||||
<ha-md-menu-item .clickAction=${this._bulkCreateLabel}>
|
<ha-dropdown-item
|
||||||
<div slot="headline">
|
@click=${this._bulkCreateLabel}
|
||||||
|
.slot=${submenu ? "submenu" : ""}
|
||||||
|
>
|
||||||
${this.hass.localize("ui.panel.config.labels.add_label")}
|
${this.hass.localize("ui.panel.config.labels.add_label")}
|
||||||
</div>
|
</ha-dropdown-item>`;
|
||||||
</ha-md-menu-item>`;
|
|
||||||
|
protected render(): TemplateResult {
|
||||||
|
if (
|
||||||
|
!this.hass ||
|
||||||
|
this._stateItems === undefined ||
|
||||||
|
this._entityEntries === undefined ||
|
||||||
|
this._configEntries === undefined
|
||||||
|
) {
|
||||||
|
return html`<hass-loading-screen></hass-loading-screen>`;
|
||||||
|
}
|
||||||
|
|
||||||
const labelsInOverflow =
|
const labelsInOverflow =
|
||||||
(this._sizeController.value && this._sizeController.value < 700) ||
|
(this._sizeController.value && this._sizeController.value < 700) ||
|
||||||
(!this._sizeController.value && this.hass.dockedSidebar === "docked");
|
(!this._sizeController.value && this.hass.dockedSidebar === "docked");
|
||||||
@@ -780,7 +789,10 @@ export class HaConfigHelpers extends SubscribeMixin(LitElement) {
|
|||||||
></ha-filter-categories>
|
></ha-filter-categories>
|
||||||
|
|
||||||
${!this.narrow
|
${!this.narrow
|
||||||
? html`<ha-md-button-menu slot="selection-bar">
|
? html`<ha-dropdown
|
||||||
|
slot="selection-bar"
|
||||||
|
@wa-select=${this._handleMenuSelect}
|
||||||
|
>
|
||||||
<ha-assist-chip
|
<ha-assist-chip
|
||||||
slot="trigger"
|
slot="trigger"
|
||||||
.label=${this.hass.localize(
|
.label=${this.hass.localize(
|
||||||
@@ -792,11 +804,11 @@ export class HaConfigHelpers extends SubscribeMixin(LitElement) {
|
|||||||
.path=${mdiMenuDown}
|
.path=${mdiMenuDown}
|
||||||
></ha-svg-icon>
|
></ha-svg-icon>
|
||||||
</ha-assist-chip>
|
</ha-assist-chip>
|
||||||
${categoryItems}
|
${this._renderCategoryItems()}
|
||||||
</ha-md-button-menu>
|
</ha-dropdown>
|
||||||
${labelsInOverflow
|
${labelsInOverflow
|
||||||
? nothing
|
? nothing
|
||||||
: html`<ha-md-button-menu slot="selection-bar">
|
: html`<ha-dropdown slot="selection-bar">
|
||||||
<ha-assist-chip
|
<ha-assist-chip
|
||||||
slot="trigger"
|
slot="trigger"
|
||||||
.label=${this.hass.localize(
|
.label=${this.hass.localize(
|
||||||
@@ -808,14 +820,15 @@ export class HaConfigHelpers extends SubscribeMixin(LitElement) {
|
|||||||
.path=${mdiMenuDown}
|
.path=${mdiMenuDown}
|
||||||
></ha-svg-icon>
|
></ha-svg-icon>
|
||||||
</ha-assist-chip>
|
</ha-assist-chip>
|
||||||
${labelItems}
|
${this._renderLabelItems()}
|
||||||
</ha-md-button-menu>`}`
|
</ha-dropdown>`}`
|
||||||
: nothing}
|
: nothing}
|
||||||
${this.narrow || labelsInOverflow
|
${this.narrow || labelsInOverflow
|
||||||
? html`
|
? html`<ha-dropdown
|
||||||
<ha-md-button-menu has-overflow slot="selection-bar">
|
slot="selection-bar"
|
||||||
${
|
@wa-select=${this._handleMenuSelect}
|
||||||
this.narrow
|
>
|
||||||
|
${this.narrow
|
||||||
? html`<ha-assist-chip
|
? html`<ha-assist-chip
|
||||||
.label=${this.hass.localize(
|
.label=${this.hass.localize(
|
||||||
"ui.panel.config.automation.picker.bulk_action"
|
"ui.panel.config.automation.picker.bulk_action"
|
||||||
@@ -833,50 +846,24 @@ export class HaConfigHelpers extends SubscribeMixin(LitElement) {
|
|||||||
"ui.panel.config.automation.picker.bulk_action"
|
"ui.panel.config.automation.picker.bulk_action"
|
||||||
)}
|
)}
|
||||||
slot="trigger"
|
slot="trigger"
|
||||||
></ha-icon-button>`
|
></ha-icon-button>`}
|
||||||
}
|
${this.narrow
|
||||||
<ha-svg-icon
|
? html`<ha-dropdown-item>
|
||||||
slot="trailing-icon"
|
|
||||||
.path=${mdiMenuDown}
|
|
||||||
></ha-svg-icon
|
|
||||||
></ha-assist-chip>
|
|
||||||
${
|
|
||||||
this.narrow
|
|
||||||
? html`<ha-sub-menu>
|
|
||||||
<ha-md-menu-item slot="item">
|
|
||||||
<div slot="headline">
|
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.automation.picker.bulk_actions.move_category"
|
"ui.panel.config.automation.picker.bulk_actions.move_category"
|
||||||
)}
|
)}
|
||||||
</div>
|
${this._renderCategoryItems(true)}
|
||||||
<ha-svg-icon
|
</ha-dropdown-item>`
|
||||||
slot="end"
|
: nothing}
|
||||||
.path=${mdiChevronRight}
|
${this.narrow || this.hass.dockedSidebar === "docked"
|
||||||
></ha-svg-icon>
|
? html`<ha-dropdown-item>
|
||||||
</ha-md-menu-item>
|
|
||||||
<ha-md-menu slot="menu">${categoryItems}</ha-md-menu>
|
|
||||||
</ha-sub-menu>`
|
|
||||||
: nothing
|
|
||||||
}
|
|
||||||
${
|
|
||||||
this.narrow || this.hass.dockedSidebar === "docked"
|
|
||||||
? html` <ha-sub-menu>
|
|
||||||
<ha-md-menu-item slot="item">
|
|
||||||
<div slot="headline">
|
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.automation.picker.bulk_actions.add_label"
|
"ui.panel.config.automation.picker.bulk_actions.add_label"
|
||||||
)}
|
)}
|
||||||
</div>
|
${this._renderLabelItems(true)}
|
||||||
<ha-svg-icon
|
</ha-dropdown-item>`
|
||||||
slot="end"
|
: nothing}
|
||||||
.path=${mdiChevronRight}
|
</ha-dropdown>`
|
||||||
></ha-svg-icon>
|
|
||||||
</ha-md-menu-item>
|
|
||||||
<ha-md-menu slot="menu">${labelItems}</ha-md-menu>
|
|
||||||
</ha-sub-menu>`
|
|
||||||
: nothing
|
|
||||||
}
|
|
||||||
</ha-md-button-menu>`
|
|
||||||
: nothing}
|
: nothing}
|
||||||
|
|
||||||
<ha-integration-overflow-menu
|
<ha-integration-overflow-menu
|
||||||
@@ -1019,12 +1006,7 @@ export class HaConfigHelpers extends SubscribeMixin(LitElement) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private _handleBulkCategory = (item) => {
|
private async _bulkAddCategory(category: string | null) {
|
||||||
const category = item.value;
|
|
||||||
this._bulkAddCategory(category);
|
|
||||||
};
|
|
||||||
|
|
||||||
private async _bulkAddCategory(category: string) {
|
|
||||||
const promises: Promise<UpdateEntityRegistryEntryResult>[] = [];
|
const promises: Promise<UpdateEntityRegistryEntryResult>[] = [];
|
||||||
this._selected.forEach((entityId) => {
|
this._selected.forEach((entityId) => {
|
||||||
promises.push(
|
promises.push(
|
||||||
@@ -1049,12 +1031,6 @@ ${rejected
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _handleBulkLabel(ev) {
|
|
||||||
const label = ev.currentTarget.value;
|
|
||||||
const action = ev.currentTarget.action;
|
|
||||||
this._bulkLabel(label, action);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async _bulkLabel(label: string, action: "add" | "remove") {
|
private async _bulkLabel(label: string, action: "add" | "remove") {
|
||||||
const promises: Promise<UpdateEntityRegistryEntryResult>[] = [];
|
const promises: Promise<UpdateEntityRegistryEntryResult>[] = [];
|
||||||
this._selected.forEach((entityId) => {
|
this._selected.forEach((entityId) => {
|
||||||
@@ -1090,6 +1066,32 @@ ${rejected
|
|||||||
this._selected = ev.detail.value;
|
this._selected = ev.detail.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _handleMenuSelect(ev: CustomEvent) {
|
||||||
|
const item = ev.detail.item as HaDropdownItem;
|
||||||
|
switch (item.value) {
|
||||||
|
case "no_category":
|
||||||
|
this._bulkAddCategory(null);
|
||||||
|
break;
|
||||||
|
case "create_category":
|
||||||
|
this._bulkCreateCategory();
|
||||||
|
break;
|
||||||
|
case "move_category":
|
||||||
|
if (item.dataset.category) {
|
||||||
|
this._bulkAddCategory(item.dataset.category);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private _handleLabelMenuSelect(ev: CustomEvent) {
|
||||||
|
ev.stopPropagation();
|
||||||
|
const item = ev.currentTarget as HaDropdownItem;
|
||||||
|
|
||||||
|
const label = item.value as string;
|
||||||
|
const action = (item as HTMLElement).dataset.action as "add" | "remove";
|
||||||
|
this._bulkLabel(label, action);
|
||||||
|
}
|
||||||
|
|
||||||
protected firstUpdated(changedProps: PropertyValues) {
|
protected firstUpdated(changedProps: PropertyValues) {
|
||||||
super.firstUpdated(changedProps);
|
super.firstUpdated(changedProps);
|
||||||
|
|
||||||
@@ -1430,7 +1432,7 @@ ${rejected
|
|||||||
ha-assist-chip {
|
ha-assist-chip {
|
||||||
--ha-assist-chip-container-shape: 10px;
|
--ha-assist-chip-container-shape: 10px;
|
||||||
}
|
}
|
||||||
ha-md-button-menu ha-assist-chip {
|
ha-dropdown ha-assist-chip {
|
||||||
--md-assist-chip-trailing-space: 8px;
|
--md-assist-chip-trailing-space: 8px;
|
||||||
}
|
}
|
||||||
ha-label {
|
ha-label {
|
||||||
|
|||||||
@@ -4,8 +4,10 @@ import { customElement, property, state } from "lit/decorators";
|
|||||||
import { cache } from "lit/directives/cache";
|
import { cache } from "lit/directives/cache";
|
||||||
import "../../../components/ha-alert";
|
import "../../../components/ha-alert";
|
||||||
import "../../../components/ha-button";
|
import "../../../components/ha-button";
|
||||||
import "../../../components/ha-button-menu";
|
|
||||||
import "../../../components/ha-card";
|
import "../../../components/ha-card";
|
||||||
|
import "../../../components/ha-dropdown";
|
||||||
|
import "../../../components/ha-dropdown-item";
|
||||||
|
import type { HaDropdownItem } from "../../../components/ha-dropdown-item";
|
||||||
import "../../../components/ha-expansion-panel";
|
import "../../../components/ha-expansion-panel";
|
||||||
import "../../../components/ha-formfield";
|
import "../../../components/ha-formfield";
|
||||||
import "../../../components/ha-icon-button";
|
import "../../../components/ha-icon-button";
|
||||||
@@ -500,15 +502,18 @@ export class HassioNetwork extends LitElement {
|
|||||||
`
|
`
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<ha-button-menu
|
<ha-dropdown
|
||||||
@opened=${this._handleDNSMenuOpened}
|
@wa-show=${this._handleDNSMenuOpened}
|
||||||
@closed=${this._handleDNSMenuClosed}
|
@wa-hide=${this._handleDNSMenuClosed}
|
||||||
|
@wa-select=${this._handleDNSMenuSelect}
|
||||||
.version=${version}
|
.version=${version}
|
||||||
class="add-nameserver"
|
>
|
||||||
|
<ha-button
|
||||||
appearance="filled"
|
appearance="filled"
|
||||||
size="small"
|
size="small"
|
||||||
|
slot="trigger"
|
||||||
|
class="add-nameserver"
|
||||||
>
|
>
|
||||||
<ha-button appearance="filled" size="small" slot="trigger">
|
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.network.supervisor.add_dns_server"
|
"ui.panel.config.network.supervisor.add_dns_server"
|
||||||
)}
|
)}
|
||||||
@@ -519,21 +524,21 @@ export class HassioNetwork extends LitElement {
|
|||||||
</ha-button>
|
</ha-button>
|
||||||
${Object.entries(PREDEFINED_DNS[version]).map(
|
${Object.entries(PREDEFINED_DNS[version]).map(
|
||||||
([name, addresses]) => html`
|
([name, addresses]) => html`
|
||||||
<ha-list-item
|
<ha-dropdown-item
|
||||||
@click=${this._addPredefinedDNS}
|
value="predefined"
|
||||||
.version=${version}
|
.version=${version}
|
||||||
.addresses=${addresses}
|
.addresses=${addresses}
|
||||||
>
|
>
|
||||||
${name}
|
${name}
|
||||||
</ha-list-item>
|
</ha-dropdown-item>
|
||||||
`
|
`
|
||||||
)}
|
)}
|
||||||
<ha-list-item @click=${this._addCustomDNS} .version=${version}>
|
<ha-dropdown-item value="custom" .version=${version}>
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.network.supervisor.custom_dns"
|
"ui.panel.config.network.supervisor.custom_dns"
|
||||||
)}
|
)}
|
||||||
</ha-list-item>
|
</ha-dropdown-item>
|
||||||
</ha-button-menu>
|
</ha-dropdown>
|
||||||
`
|
`
|
||||||
: nothing}
|
: nothing}
|
||||||
</ha-expansion-panel>
|
</ha-expansion-panel>
|
||||||
@@ -747,21 +752,23 @@ export class HassioNetwork extends LitElement {
|
|||||||
this._dnsMenuOpen = false;
|
this._dnsMenuOpen = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _addPredefinedDNS(ev: Event) {
|
private _handleDNSMenuSelect(ev: CustomEvent) {
|
||||||
const source = ev.target as any;
|
const item = ev.detail.item as HaDropdownItem & {
|
||||||
const version = source.version as "ipv4" | "ipv6";
|
version: "ipv4" | "ipv6";
|
||||||
const addresses = source.addresses as string[];
|
addresses?: string[];
|
||||||
|
};
|
||||||
|
const version = item.version;
|
||||||
|
|
||||||
|
if (item.value === "predefined" && item.addresses) {
|
||||||
if (!this._interface![version]!.nameservers) {
|
if (!this._interface![version]!.nameservers) {
|
||||||
this._interface![version]!.nameservers = [];
|
this._interface![version]!.nameservers = [];
|
||||||
}
|
}
|
||||||
this._interface![version]!.nameservers!.push(...addresses);
|
this._interface![version]!.nameservers!.push(...item.addresses);
|
||||||
this._dirty = true;
|
this._dirty = true;
|
||||||
this.requestUpdate("_interface");
|
this.requestUpdate("_interface");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
if (item.value === "custom") {
|
||||||
private _addCustomDNS(ev: Event) {
|
|
||||||
const source = ev.target as any;
|
|
||||||
const version = source.version as "ipv4" | "ipv6";
|
|
||||||
if (!this._interface![version]!.nameservers) {
|
if (!this._interface![version]!.nameservers) {
|
||||||
this._interface![version]!.nameservers = [];
|
this._interface![version]!.nameservers = [];
|
||||||
}
|
}
|
||||||
@@ -769,6 +776,7 @@ export class HassioNetwork extends LitElement {
|
|||||||
this._dirty = true;
|
this._dirty = true;
|
||||||
this.requestUpdate("_interface");
|
this.requestUpdate("_interface");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private _removeNameserver(ev: Event): void {
|
private _removeNameserver(ev: Event): void {
|
||||||
const source = ev.target as any;
|
const source = ev.target as any;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
import "@home-assistant/webawesome/dist/components/divider/divider";
|
||||||
import { ResizeController } from "@lit-labs/observers/resize-controller";
|
import { ResizeController } from "@lit-labs/observers/resize-controller";
|
||||||
import { consume } from "@lit/context";
|
import { consume } from "@lit/context";
|
||||||
import {
|
import {
|
||||||
mdiChevronRight,
|
|
||||||
mdiCog,
|
mdiCog,
|
||||||
mdiContentDuplicate,
|
mdiContentDuplicate,
|
||||||
mdiDelete,
|
mdiDelete,
|
||||||
@@ -31,6 +31,7 @@ import type { HASSDomEvent } from "../../../common/dom/fire_event";
|
|||||||
import { fireEvent } from "../../../common/dom/fire_event";
|
import { fireEvent } from "../../../common/dom/fire_event";
|
||||||
import { computeStateName } from "../../../common/entity/compute_state_name";
|
import { computeStateName } from "../../../common/entity/compute_state_name";
|
||||||
import { navigate } from "../../../common/navigate";
|
import { navigate } from "../../../common/navigate";
|
||||||
|
import { slugify } from "../../../common/string/slugify";
|
||||||
import type { LocalizeFunc } from "../../../common/translations/localize";
|
import type { LocalizeFunc } from "../../../common/translations/localize";
|
||||||
import {
|
import {
|
||||||
hasRejectedItems,
|
hasRejectedItems,
|
||||||
@@ -44,6 +45,9 @@ import type {
|
|||||||
} from "../../../components/data-table/ha-data-table";
|
} from "../../../components/data-table/ha-data-table";
|
||||||
import "../../../components/data-table/ha-data-table-labels";
|
import "../../../components/data-table/ha-data-table-labels";
|
||||||
import "../../../components/ha-button";
|
import "../../../components/ha-button";
|
||||||
|
import "../../../components/ha-dropdown";
|
||||||
|
import "../../../components/ha-dropdown-item";
|
||||||
|
import type { HaDropdownItem } from "../../../components/ha-dropdown-item";
|
||||||
import "../../../components/ha-fab";
|
import "../../../components/ha-fab";
|
||||||
import "../../../components/ha-filter-categories";
|
import "../../../components/ha-filter-categories";
|
||||||
import "../../../components/ha-filter-devices";
|
import "../../../components/ha-filter-devices";
|
||||||
@@ -52,11 +56,7 @@ import "../../../components/ha-filter-floor-areas";
|
|||||||
import "../../../components/ha-filter-labels";
|
import "../../../components/ha-filter-labels";
|
||||||
import "../../../components/ha-icon-button";
|
import "../../../components/ha-icon-button";
|
||||||
import "../../../components/ha-icon-overflow-menu";
|
import "../../../components/ha-icon-overflow-menu";
|
||||||
import "../../../components/ha-md-divider";
|
|
||||||
import "../../../components/ha-md-menu";
|
|
||||||
import "../../../components/ha-md-menu-item";
|
|
||||||
import "../../../components/ha-state-icon";
|
import "../../../components/ha-state-icon";
|
||||||
import "../../../components/ha-sub-menu";
|
|
||||||
import "../../../components/ha-svg-icon";
|
import "../../../components/ha-svg-icon";
|
||||||
import "../../../components/ha-tooltip";
|
import "../../../components/ha-tooltip";
|
||||||
import { createAreaRegistryEntry } from "../../../data/area_registry";
|
import { createAreaRegistryEntry } from "../../../data/area_registry";
|
||||||
@@ -106,7 +106,6 @@ import { showAssignCategoryDialog } from "../category/show-dialog-assign-categor
|
|||||||
import { showCategoryRegistryDetailDialog } from "../category/show-dialog-category-registry-detail";
|
import { showCategoryRegistryDetailDialog } from "../category/show-dialog-category-registry-detail";
|
||||||
import { configSections } from "../ha-panel-config";
|
import { configSections } from "../ha-panel-config";
|
||||||
import { showLabelDetailDialog } from "../labels/show-dialog-label-detail";
|
import { showLabelDetailDialog } from "../labels/show-dialog-label-detail";
|
||||||
import { slugify } from "../../../common/string/slugify";
|
|
||||||
|
|
||||||
type SceneItem = SceneEntity & {
|
type SceneItem = SceneEntity & {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -434,34 +433,8 @@ class HaSceneDashboard extends SubscribeMixin(LitElement) {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
private _renderLabelItems = (submenu = false) =>
|
||||||
const categoryItems = html`${this._categories?.map(
|
html` ${this._labels?.map((label) => {
|
||||||
(category) =>
|
|
||||||
html`<ha-md-menu-item
|
|
||||||
.value=${category.category_id}
|
|
||||||
.clickAction=${this._handleBulkCategory}
|
|
||||||
>
|
|
||||||
${category.icon
|
|
||||||
? html`<ha-icon slot="start" .icon=${category.icon}></ha-icon>`
|
|
||||||
: html`<ha-svg-icon slot="start" .path=${mdiTag}></ha-svg-icon>`}
|
|
||||||
<div slot="headline">${category.name}</div>
|
|
||||||
</ha-md-menu-item>`
|
|
||||||
)}
|
|
||||||
<ha-md-menu-item .value=${null} .clickAction=${this._handleBulkCategory}>
|
|
||||||
<div slot="headline">
|
|
||||||
${this.hass.localize(
|
|
||||||
"ui.panel.config.automation.picker.bulk_actions.no_category"
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</ha-md-menu-item>
|
|
||||||
<ha-md-divider role="separator" tabindex="-1"></ha-md-divider>
|
|
||||||
<ha-md-menu-item .clickAction=${this._bulkCreateCategory}>
|
|
||||||
<div slot="headline">
|
|
||||||
${this.hass.localize("ui.panel.config.category.editor.add")}
|
|
||||||
</div>
|
|
||||||
</ha-md-menu-item>`;
|
|
||||||
|
|
||||||
const labelItems = html` ${this._labels?.map((label) => {
|
|
||||||
const color = label.color ? computeCssColor(label.color) : undefined;
|
const color = label.color ? computeCssColor(label.color) : undefined;
|
||||||
const selected = this._selected.every((entityId) =>
|
const selected = this._selected.every((entityId) =>
|
||||||
this.hass.entities[entityId]?.labels.includes(label.label_id)
|
this.hass.entities[entityId]?.labels.includes(label.label_id)
|
||||||
@@ -471,14 +444,14 @@ class HaSceneDashboard extends SubscribeMixin(LitElement) {
|
|||||||
this._selected.some((entityId) =>
|
this._selected.some((entityId) =>
|
||||||
this.hass.entities[entityId]?.labels.includes(label.label_id)
|
this.hass.entities[entityId]?.labels.includes(label.label_id)
|
||||||
);
|
);
|
||||||
return html`<ha-md-menu-item
|
return html`<ha-dropdown-item
|
||||||
.value=${label.label_id}
|
.slot=${submenu ? "submenu" : ""}
|
||||||
.action=${selected ? "remove" : "add"}
|
value=${label.label_id}
|
||||||
@click=${this._handleBulkLabel}
|
data-action=${selected ? "remove" : "add"}
|
||||||
keep-open
|
@click=${this._handleLabelMenuSelect}
|
||||||
>
|
>
|
||||||
<ha-checkbox
|
<ha-checkbox
|
||||||
slot="start"
|
slot="icon"
|
||||||
.checked=${selected}
|
.checked=${selected}
|
||||||
.indeterminate=${partial}
|
.indeterminate=${partial}
|
||||||
reducedTouchTarget
|
reducedTouchTarget
|
||||||
@@ -492,46 +465,74 @@ class HaSceneDashboard extends SubscribeMixin(LitElement) {
|
|||||||
: nothing}
|
: nothing}
|
||||||
${label.name}
|
${label.name}
|
||||||
</ha-label>
|
</ha-label>
|
||||||
</ha-md-menu-item>`;
|
</ha-dropdown-item>`;
|
||||||
})}
|
})}
|
||||||
<ha-md-divider role="separator" tabindex="-1"></ha-md-divider>
|
<wa-divider .slot=${submenu ? "submenu" : ""}></wa-divider>
|
||||||
<ha-md-menu-item .clickAction=${this._bulkCreateLabel}>
|
<ha-dropdown-item
|
||||||
<div slot="headline">
|
@click=${this._handleCreateLabel}
|
||||||
|
.slot=${submenu ? "submenu" : ""}
|
||||||
|
value="create-label"
|
||||||
|
>
|
||||||
${this.hass.localize("ui.panel.config.labels.add_label")}
|
${this.hass.localize("ui.panel.config.labels.add_label")}
|
||||||
</div></ha-md-menu-item
|
</ha-dropdown-item>`;
|
||||||
>`;
|
|
||||||
|
|
||||||
const areaItems = html`${Object.values(this.hass.areas).map(
|
private _renderCategoryItems = (submenu = false) =>
|
||||||
|
html`${this._categories?.map(
|
||||||
|
(category) =>
|
||||||
|
html`<ha-dropdown-item
|
||||||
|
.slot=${submenu ? "submenu" : ""}
|
||||||
|
value="move_category"
|
||||||
|
data-category=${category.category_id}
|
||||||
|
>
|
||||||
|
${category.icon
|
||||||
|
? html`<ha-icon slot="icon" .icon=${category.icon}></ha-icon>`
|
||||||
|
: html`<ha-svg-icon slot="icon" .path=${mdiTag}></ha-svg-icon>`}
|
||||||
|
${category.name}
|
||||||
|
</ha-dropdown-item>`
|
||||||
|
)}
|
||||||
|
<ha-dropdown-item .slot=${submenu ? "submenu" : ""} value="no-category">
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.panel.config.automation.picker.bulk_actions.no_category"
|
||||||
|
)}
|
||||||
|
</ha-dropdown-item>
|
||||||
|
<wa-divider .slot=${submenu ? "submenu" : ""}></wa-divider>
|
||||||
|
<ha-dropdown-item
|
||||||
|
.slot=${submenu ? "submenu" : ""}
|
||||||
|
value="create-category"
|
||||||
|
>
|
||||||
|
${this.hass.localize("ui.panel.config.category.editor.add")}
|
||||||
|
</ha-dropdown-item>`;
|
||||||
|
|
||||||
|
private _renderAreaItems = (submenu = false) =>
|
||||||
|
html`${Object.values(this.hass.areas).map(
|
||||||
(area) =>
|
(area) =>
|
||||||
html`<ha-md-menu-item
|
html`<ha-dropdown-item
|
||||||
.value=${area.area_id}
|
.slot=${submenu ? "submenu" : ""}
|
||||||
.clickAction=${this._handleBulkArea}
|
value="move_area"
|
||||||
|
data-area=${area.area_id}
|
||||||
>
|
>
|
||||||
${area.icon
|
${area.icon
|
||||||
? html`<ha-icon slot="start" .icon=${area.icon}></ha-icon>`
|
? html`<ha-icon slot="icon" .icon=${area.icon}></ha-icon>`
|
||||||
: html`<ha-svg-icon
|
: html`<ha-svg-icon
|
||||||
slot="start"
|
slot="icon"
|
||||||
.path=${mdiTextureBox}
|
.path=${mdiTextureBox}
|
||||||
></ha-svg-icon>`}
|
></ha-svg-icon>`}
|
||||||
<div slot="headline">${area.name}</div>
|
${area.name}
|
||||||
</ha-md-menu-item>`
|
</ha-dropdown-item>`
|
||||||
)}
|
)}
|
||||||
<ha-md-menu-item .value=${null} .clickAction=${this._handleBulkArea}>
|
<ha-dropdown-item .slot=${submenu ? "submenu" : ""} value="no-area">
|
||||||
<div slot="headline">
|
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.devices.picker.bulk_actions.no_area"
|
"ui.panel.config.devices.picker.bulk_actions.no_area"
|
||||||
)}
|
)}
|
||||||
</div>
|
</ha-dropdown-item>
|
||||||
</ha-md-menu-item>
|
<wa-divider .slot=${submenu ? "submenu" : ""}></wa-divider>
|
||||||
<ha-md-divider role="separator" tabindex="-1"></ha-md-divider>
|
<ha-dropdown-item .slot=${submenu ? "submenu" : ""} value="create-area">
|
||||||
<ha-md-menu-item .clickAction=${this._bulkCreateArea}>
|
|
||||||
<div slot="headline">
|
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.devices.picker.bulk_actions.add_area"
|
"ui.panel.config.devices.picker.bulk_actions.add_area"
|
||||||
)}
|
)}
|
||||||
</div>
|
</ha-dropdown-item>`;
|
||||||
</ha-md-menu-item>`;
|
|
||||||
|
|
||||||
|
protected render(): TemplateResult {
|
||||||
const areasInOverflow =
|
const areasInOverflow =
|
||||||
(this._sizeController.value && this._sizeController.value < 900) ||
|
(this._sizeController.value && this._sizeController.value < 900) ||
|
||||||
(!this._sizeController.value && this.hass.dockedSidebar === "docked");
|
(!this._sizeController.value && this.hass.dockedSidebar === "docked");
|
||||||
@@ -654,7 +655,10 @@ class HaSceneDashboard extends SubscribeMixin(LitElement) {
|
|||||||
></ha-filter-categories>
|
></ha-filter-categories>
|
||||||
|
|
||||||
${!this.narrow
|
${!this.narrow
|
||||||
? html`<ha-md-button-menu slot="selection-bar">
|
? html`<ha-dropdown
|
||||||
|
slot="selection-bar"
|
||||||
|
@wa-select=${this._handleOverflowMenuSelect}
|
||||||
|
>
|
||||||
<ha-assist-chip
|
<ha-assist-chip
|
||||||
slot="trigger"
|
slot="trigger"
|
||||||
.label=${this.hass.localize(
|
.label=${this.hass.localize(
|
||||||
@@ -666,11 +670,11 @@ class HaSceneDashboard extends SubscribeMixin(LitElement) {
|
|||||||
.path=${mdiMenuDown}
|
.path=${mdiMenuDown}
|
||||||
></ha-svg-icon>
|
></ha-svg-icon>
|
||||||
</ha-assist-chip>
|
</ha-assist-chip>
|
||||||
${categoryItems}
|
${this._renderCategoryItems()}
|
||||||
</ha-md-button-menu>
|
</ha-dropdown>
|
||||||
${labelsInOverflow
|
${labelsInOverflow
|
||||||
? nothing
|
? nothing
|
||||||
: html`<ha-md-button-menu slot="selection-bar">
|
: html`<ha-dropdown slot="selection-bar">
|
||||||
<ha-assist-chip
|
<ha-assist-chip
|
||||||
slot="trigger"
|
slot="trigger"
|
||||||
.label=${this.hass.localize(
|
.label=${this.hass.localize(
|
||||||
@@ -682,11 +686,14 @@ class HaSceneDashboard extends SubscribeMixin(LitElement) {
|
|||||||
.path=${mdiMenuDown}
|
.path=${mdiMenuDown}
|
||||||
></ha-svg-icon>
|
></ha-svg-icon>
|
||||||
</ha-assist-chip>
|
</ha-assist-chip>
|
||||||
${labelItems}
|
${this._renderLabelItems()}
|
||||||
</ha-md-button-menu>`}
|
</ha-dropdown>`}
|
||||||
${areasInOverflow
|
${areasInOverflow
|
||||||
? nothing
|
? nothing
|
||||||
: html`<ha-md-button-menu slot="selection-bar">
|
: html`<ha-dropdown
|
||||||
|
slot="selection-bar"
|
||||||
|
@wa-select=${this._handleOverflowMenuSelect}
|
||||||
|
>
|
||||||
<ha-assist-chip
|
<ha-assist-chip
|
||||||
slot="trigger"
|
slot="trigger"
|
||||||
.label=${this.hass.localize(
|
.label=${this.hass.localize(
|
||||||
@@ -698,14 +705,15 @@ class HaSceneDashboard extends SubscribeMixin(LitElement) {
|
|||||||
.path=${mdiMenuDown}
|
.path=${mdiMenuDown}
|
||||||
></ha-svg-icon>
|
></ha-svg-icon>
|
||||||
</ha-assist-chip>
|
</ha-assist-chip>
|
||||||
${areaItems}
|
${this._renderAreaItems()}
|
||||||
</ha-md-button-menu>`}`
|
</ha-dropdown>`}`
|
||||||
: nothing}
|
: nothing}
|
||||||
${this.narrow || areasInOverflow
|
${this.narrow || areasInOverflow
|
||||||
? html`
|
? html` <ha-dropdown
|
||||||
<ha-md-button-menu has-overflow slot="selection-bar">
|
slot="selection-bar"
|
||||||
${
|
@wa-select=${this._handleOverflowMenuSelect}
|
||||||
this.narrow
|
>
|
||||||
|
${this.narrow
|
||||||
? html`<ha-assist-chip
|
? html`<ha-assist-chip
|
||||||
.label=${this.hass.localize(
|
.label=${this.hass.localize(
|
||||||
"ui.panel.config.automation.picker.bulk_action"
|
"ui.panel.config.automation.picker.bulk_action"
|
||||||
@@ -723,68 +731,32 @@ class HaSceneDashboard extends SubscribeMixin(LitElement) {
|
|||||||
"ui.panel.config.automation.picker.bulk_action"
|
"ui.panel.config.automation.picker.bulk_action"
|
||||||
)}
|
)}
|
||||||
slot="trigger"
|
slot="trigger"
|
||||||
></ha-icon-button>`
|
></ha-icon-button>`}
|
||||||
}
|
${this.narrow
|
||||||
<ha-svg-icon
|
? html`<ha-dropdown-item>
|
||||||
slot="trailing-icon"
|
|
||||||
.path=${mdiMenuDown}
|
|
||||||
></ha-svg-icon
|
|
||||||
></ha-assist-chip>
|
|
||||||
${
|
|
||||||
this.narrow
|
|
||||||
? html`<ha-sub-menu>
|
|
||||||
<ha-md-menu-item slot="item">
|
|
||||||
<div slot="headline">
|
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.automation.picker.bulk_actions.move_category"
|
"ui.panel.config.automation.picker.bulk_actions.move_category"
|
||||||
)}
|
)}
|
||||||
</div>
|
${this._renderCategoryItems(true)}
|
||||||
<ha-svg-icon
|
</ha-dropdown-item>`
|
||||||
slot="end"
|
: nothing}
|
||||||
.path=${mdiChevronRight}
|
${this.narrow || labelsInOverflow
|
||||||
></ha-svg-icon>
|
? html`<ha-dropdown-item>
|
||||||
</ha-md-menu-item>
|
|
||||||
<ha-md-menu slot="menu">${categoryItems}</ha-md-menu>
|
|
||||||
</ha-sub-menu>`
|
|
||||||
: nothing
|
|
||||||
}
|
|
||||||
${
|
|
||||||
this.narrow || labelsInOverflow
|
|
||||||
? html`<ha-sub-menu>
|
|
||||||
<ha-md-menu-item slot="item">
|
|
||||||
<div slot="headline">
|
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.automation.picker.bulk_actions.add_label"
|
"ui.panel.config.automation.picker.bulk_actions.add_label"
|
||||||
)}
|
)}
|
||||||
</div>
|
${this._renderLabelItems(true)}
|
||||||
<ha-svg-icon
|
</ha-dropdown-item>`
|
||||||
slot="end"
|
: nothing}
|
||||||
.path=${mdiChevronRight}
|
${this.narrow || areasInOverflow
|
||||||
></ha-svg-icon>
|
? html`<ha-dropdown-item>
|
||||||
</ha-md-menu-item>
|
|
||||||
<ha-md-menu slot="menu">${labelItems}</ha-md-menu>
|
|
||||||
</ha-sub-menu>`
|
|
||||||
: nothing
|
|
||||||
}
|
|
||||||
${
|
|
||||||
this.narrow || areasInOverflow
|
|
||||||
? html`<ha-sub-menu>
|
|
||||||
<ha-md-menu-item slot="item">
|
|
||||||
<div slot="headline">
|
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.devices.picker.bulk_actions.move_area"
|
"ui.panel.config.devices.picker.bulk_actions.move_area"
|
||||||
)}
|
)}
|
||||||
</div>
|
${this._renderAreaItems(true)}
|
||||||
<ha-svg-icon
|
</ha-dropdown-item>`
|
||||||
slot="end"
|
: nothing}
|
||||||
.path=${mdiChevronRight}
|
</ha-dropdown>`
|
||||||
></ha-svg-icon>
|
|
||||||
</ha-md-menu-item>
|
|
||||||
<ha-md-menu slot="menu">${areaItems}</ha-md-menu>
|
|
||||||
</ha-sub-menu>`
|
|
||||||
: nothing
|
|
||||||
}
|
|
||||||
</ha-md-button-menu>`
|
|
||||||
: nothing}
|
: nothing}
|
||||||
${!this.scenes.length
|
${!this.scenes.length
|
||||||
? html`<div class="empty" slot="empty">
|
? html`<div class="empty" slot="empty">
|
||||||
@@ -955,12 +927,52 @@ class HaSceneDashboard extends SubscribeMixin(LitElement) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _handleBulkCategory = (item) => {
|
private _handleLabelMenuSelect = (ev: CustomEvent) => {
|
||||||
const category = item.value;
|
ev.stopPropagation();
|
||||||
this._bulkAddCategory(category);
|
const item = ev.currentTarget as HaDropdownItem & {
|
||||||
|
dataset: { action?: string };
|
||||||
|
};
|
||||||
|
const action = item.dataset.action as "add" | "remove";
|
||||||
|
this._bulkLabel(item.value, action);
|
||||||
};
|
};
|
||||||
|
|
||||||
private async _bulkAddCategory(category: string) {
|
private _handleCreateLabel = () => {
|
||||||
|
this._bulkCreateLabel();
|
||||||
|
};
|
||||||
|
|
||||||
|
private _handleOverflowMenuSelect = (ev: CustomEvent) => {
|
||||||
|
const item = ev.detail.item as HaDropdownItem;
|
||||||
|
|
||||||
|
switch (item.value) {
|
||||||
|
case "create-category":
|
||||||
|
this._bulkCreateCategory();
|
||||||
|
break;
|
||||||
|
case "no-category":
|
||||||
|
this._bulkAddCategory(null);
|
||||||
|
break;
|
||||||
|
case "create-label":
|
||||||
|
this._bulkCreateLabel();
|
||||||
|
break;
|
||||||
|
case "create-area":
|
||||||
|
this._bulkCreateArea();
|
||||||
|
break;
|
||||||
|
case "no-area":
|
||||||
|
this._bulkAddArea(null);
|
||||||
|
break;
|
||||||
|
case "move_category":
|
||||||
|
if (item.dataset.category) {
|
||||||
|
this._bulkAddCategory(item.dataset.category);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "move_area":
|
||||||
|
if (item.dataset.area) {
|
||||||
|
this._bulkAddArea(item.dataset.area);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private async _bulkAddCategory(category: string | null) {
|
||||||
const promises: Promise<UpdateEntityRegistryEntryResult>[] = [];
|
const promises: Promise<UpdateEntityRegistryEntryResult>[] = [];
|
||||||
this._selected.forEach((entityId) => {
|
this._selected.forEach((entityId) => {
|
||||||
promises.push(
|
promises.push(
|
||||||
@@ -985,12 +997,6 @@ ${rejected
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _handleBulkLabel(ev) {
|
|
||||||
const label = ev.currentTarget.value;
|
|
||||||
const action = ev.currentTarget.action;
|
|
||||||
this._bulkLabel(label, action);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async _bulkLabel(label: string, action: "add" | "remove") {
|
private async _bulkLabel(label: string, action: "add" | "remove") {
|
||||||
const promises: Promise<UpdateEntityRegistryEntryResult>[] = [];
|
const promises: Promise<UpdateEntityRegistryEntryResult>[] = [];
|
||||||
this._selected.forEach((entityId) => {
|
this._selected.forEach((entityId) => {
|
||||||
@@ -1021,12 +1027,7 @@ ${rejected
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _handleBulkArea = (item) => {
|
private async _bulkAddArea(area: string | null) {
|
||||||
const area = item.value;
|
|
||||||
this._bulkAddArea(area);
|
|
||||||
};
|
|
||||||
|
|
||||||
private async _bulkAddArea(area: string) {
|
|
||||||
const promises: Promise<UpdateEntityRegistryEntryResult>[] = [];
|
const promises: Promise<UpdateEntityRegistryEntryResult>[] = [];
|
||||||
this._selected.forEach((entityId) => {
|
this._selected.forEach((entityId) => {
|
||||||
promises.push(
|
promises.push(
|
||||||
@@ -1231,7 +1232,7 @@ ${rejected
|
|||||||
ha-assist-chip {
|
ha-assist-chip {
|
||||||
--ha-assist-chip-container-shape: 10px;
|
--ha-assist-chip-container-shape: 10px;
|
||||||
}
|
}
|
||||||
ha-md-button-menu ha-assist-chip {
|
ha-dropdown ha-assist-chip {
|
||||||
--md-assist-chip-trailing-space: 8px;
|
--md-assist-chip-trailing-space: 8px;
|
||||||
}
|
}
|
||||||
ha-label {
|
ha-label {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
import "@home-assistant/webawesome/dist/components/divider/divider";
|
||||||
import { consume } from "@lit/context";
|
import { consume } from "@lit/context";
|
||||||
|
|
||||||
import type { ActionDetail } from "@material/mwc-list/mwc-list-foundation";
|
|
||||||
import {
|
import {
|
||||||
mdiCog,
|
mdiCog,
|
||||||
mdiContentDuplicate,
|
mdiContentDuplicate,
|
||||||
@@ -32,8 +32,10 @@ import "../../../components/entity/ha-entities-picker";
|
|||||||
import "../../../components/ha-alert";
|
import "../../../components/ha-alert";
|
||||||
import "../../../components/ha-area-picker";
|
import "../../../components/ha-area-picker";
|
||||||
import "../../../components/ha-button";
|
import "../../../components/ha-button";
|
||||||
import "../../../components/ha-button-menu";
|
|
||||||
import "../../../components/ha-card";
|
import "../../../components/ha-card";
|
||||||
|
import "../../../components/ha-dropdown";
|
||||||
|
import "../../../components/ha-dropdown-item";
|
||||||
|
import type { HaDropdownItem } from "../../../components/ha-dropdown-item";
|
||||||
import "../../../components/ha-fab";
|
import "../../../components/ha-fab";
|
||||||
import "../../../components/ha-icon-button";
|
import "../../../components/ha-icon-button";
|
||||||
import "../../../components/ha-icon-picker";
|
import "../../../components/ha-icon-picker";
|
||||||
@@ -227,78 +229,66 @@ export class HaSceneEditor extends PreventUnsavedMixin(
|
|||||||
? computeStateName(this._scene)
|
? computeStateName(this._scene)
|
||||||
: this.hass.localize("ui.panel.config.scene.editor.default_name")}
|
: this.hass.localize("ui.panel.config.scene.editor.default_name")}
|
||||||
>
|
>
|
||||||
<ha-button-menu
|
<ha-dropdown slot="toolbar-icon" @wa-select=${this._handleMenuAction}>
|
||||||
slot="toolbar-icon"
|
|
||||||
@action=${this._handleMenuAction}
|
|
||||||
activatable
|
|
||||||
>
|
|
||||||
<ha-icon-button
|
<ha-icon-button
|
||||||
slot="trigger"
|
slot="trigger"
|
||||||
.label=${this.hass.localize("ui.common.menu")}
|
.label=${this.hass.localize("ui.common.menu")}
|
||||||
.path=${mdiDotsVertical}
|
.path=${mdiDotsVertical}
|
||||||
></ha-icon-button>
|
></ha-icon-button>
|
||||||
|
|
||||||
<ha-list-item
|
<ha-dropdown-item
|
||||||
graphic="icon"
|
value="apply"
|
||||||
.disabled=${!this.sceneId || this._mode === "live"}
|
.disabled=${!this.sceneId || this._mode === "live"}
|
||||||
>
|
>
|
||||||
|
<ha-svg-icon slot="icon" .path=${mdiPlay}></ha-svg-icon>
|
||||||
${this.hass.localize("ui.panel.config.scene.picker.apply")}
|
${this.hass.localize("ui.panel.config.scene.picker.apply")}
|
||||||
<ha-svg-icon slot="graphic" .path=${mdiPlay}></ha-svg-icon>
|
</ha-dropdown-item>
|
||||||
</ha-list-item>
|
<ha-dropdown-item value="info" .disabled=${!this.sceneId}>
|
||||||
<ha-list-item graphic="icon" .disabled=${!this.sceneId}>
|
|
||||||
${this.hass.localize("ui.panel.config.scene.picker.show_info")}
|
|
||||||
<ha-svg-icon
|
<ha-svg-icon
|
||||||
slot="graphic"
|
slot="icon"
|
||||||
.path=${mdiInformationOutline}
|
.path=${mdiInformationOutline}
|
||||||
></ha-svg-icon>
|
></ha-svg-icon>
|
||||||
</ha-list-item>
|
${this.hass.localize("ui.panel.config.scene.picker.show_info")}
|
||||||
<ha-list-item graphic="icon" .disabled=${!this.sceneId}>
|
</ha-dropdown-item>
|
||||||
|
<ha-dropdown-item value="settings" .disabled=${!this.sceneId}>
|
||||||
|
<ha-svg-icon slot="icon" .path=${mdiCog}></ha-svg-icon>
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.automation.picker.show_settings"
|
"ui.panel.config.automation.picker.show_settings"
|
||||||
)}
|
)}
|
||||||
<ha-svg-icon slot="graphic" .path=${mdiCog}></ha-svg-icon>
|
</ha-dropdown-item>
|
||||||
</ha-list-item>
|
|
||||||
|
|
||||||
<ha-list-item graphic="icon" .disabled=${!this.sceneId}>
|
<ha-dropdown-item value="category" .disabled=${!this.sceneId}>
|
||||||
|
<ha-svg-icon slot="icon" .path=${mdiTag}></ha-svg-icon>
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
`ui.panel.config.scene.picker.${this._getCategory(this._entityRegistryEntries, this._scene?.entity_id) ? "edit_category" : "assign_category"}`
|
`ui.panel.config.scene.picker.${this._getCategory(this._entityRegistryEntries, this._scene?.entity_id) ? "edit_category" : "assign_category"}`
|
||||||
)}
|
)}
|
||||||
<ha-svg-icon slot="graphic" .path=${mdiTag}></ha-svg-icon>
|
</ha-dropdown-item>
|
||||||
</ha-list-item>
|
|
||||||
|
|
||||||
<ha-list-item graphic="icon">
|
<ha-dropdown-item value="toggle_yaml">
|
||||||
|
<ha-svg-icon slot="icon" .path=${mdiPlaylistEdit}></ha-svg-icon>
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
`ui.panel.config.automation.editor.edit_${this._mode !== "yaml" ? "yaml" : "ui"}`
|
`ui.panel.config.automation.editor.edit_${this._mode !== "yaml" ? "yaml" : "ui"}`
|
||||||
)}
|
)}
|
||||||
<ha-svg-icon slot="graphic" .path=${mdiPlaylistEdit}></ha-svg-icon>
|
</ha-dropdown-item>
|
||||||
</ha-list-item>
|
|
||||||
|
|
||||||
<li divider role="separator"></li>
|
<wa-divider></wa-divider>
|
||||||
|
|
||||||
<ha-list-item .disabled=${!this.sceneId} graphic="icon">
|
<ha-dropdown-item value="duplicate" .disabled=${!this.sceneId}>
|
||||||
|
<ha-svg-icon slot="icon" .path=${mdiContentDuplicate}></ha-svg-icon>
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.scene.picker.duplicate_scene"
|
"ui.panel.config.scene.picker.duplicate_scene"
|
||||||
)}
|
)}
|
||||||
<ha-svg-icon
|
</ha-dropdown-item>
|
||||||
slot="graphic"
|
|
||||||
.path=${mdiContentDuplicate}
|
|
||||||
></ha-svg-icon>
|
|
||||||
</ha-list-item>
|
|
||||||
|
|
||||||
<ha-list-item
|
<ha-dropdown-item
|
||||||
|
value="delete"
|
||||||
.disabled=${!this.sceneId}
|
.disabled=${!this.sceneId}
|
||||||
class=${classMap({ warning: Boolean(this.sceneId) })}
|
.variant=${this.sceneId ? "danger" : "default"}
|
||||||
graphic="icon"
|
|
||||||
>
|
>
|
||||||
|
<ha-svg-icon slot="icon" .path=${mdiDelete}></ha-svg-icon>
|
||||||
${this.hass.localize("ui.panel.config.scene.picker.delete_scene")}
|
${this.hass.localize("ui.panel.config.scene.picker.delete_scene")}
|
||||||
<ha-svg-icon
|
</ha-dropdown-item>
|
||||||
class=${classMap({ warning: Boolean(this.sceneId) })}
|
</ha-dropdown>
|
||||||
slot="graphic"
|
|
||||||
.path=${mdiDelete}
|
|
||||||
>
|
|
||||||
</ha-svg-icon>
|
|
||||||
</ha-list-item>
|
|
||||||
</ha-button-menu>
|
|
||||||
${this._errors ? html` <div class="errors">${this._errors}</div> ` : ""}
|
${this._errors ? html` <div class="errors">${this._errors}</div> ` : ""}
|
||||||
${this._mode === "yaml" ? this._renderYamlMode() : this._renderUiMode()}
|
${this._mode === "yaml" ? this._renderYamlMode() : this._renderUiMode()}
|
||||||
<ha-fab
|
<ha-fab
|
||||||
@@ -652,24 +642,25 @@ export class HaSceneEditor extends PreventUnsavedMixin(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _handleMenuAction(ev: CustomEvent<ActionDetail>) {
|
private async _handleMenuAction(ev: CustomEvent) {
|
||||||
switch (ev.detail.index) {
|
const item = ev.detail.item as HaDropdownItem;
|
||||||
case 0:
|
switch (item.value) {
|
||||||
|
case "apply":
|
||||||
activateScene(this.hass, this._scene!.entity_id);
|
activateScene(this.hass, this._scene!.entity_id);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case "info":
|
||||||
fireEvent(this, "hass-more-info", { entityId: this._scene!.entity_id });
|
fireEvent(this, "hass-more-info", { entityId: this._scene!.entity_id });
|
||||||
break;
|
break;
|
||||||
case 2:
|
case "settings":
|
||||||
showMoreInfoDialog(this, {
|
showMoreInfoDialog(this, {
|
||||||
entityId: this._scene!.entity_id,
|
entityId: this._scene!.entity_id,
|
||||||
view: "settings",
|
view: "settings",
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 3:
|
case "category":
|
||||||
this._editCategory(this._scene!);
|
this._editCategory(this._scene!);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case "toggle_yaml":
|
||||||
if (this._mode === "yaml") {
|
if (this._mode === "yaml") {
|
||||||
this._initEntities(this._config!);
|
this._initEntities(this._config!);
|
||||||
this._exitYamlMode();
|
this._exitYamlMode();
|
||||||
@@ -677,10 +668,10 @@ export class HaSceneEditor extends PreventUnsavedMixin(
|
|||||||
this._enterYamlMode();
|
this._enterYamlMode();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 5:
|
case "duplicate":
|
||||||
this._duplicate();
|
this._duplicate();
|
||||||
break;
|
break;
|
||||||
case 6:
|
case "delete":
|
||||||
this._deleteTapped();
|
this._deleteTapped();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
import "@home-assistant/webawesome/dist/components/divider/divider";
|
||||||
import { ResizeController } from "@lit-labs/observers/resize-controller";
|
import { ResizeController } from "@lit-labs/observers/resize-controller";
|
||||||
import { consume } from "@lit/context";
|
import { consume } from "@lit/context";
|
||||||
import {
|
import {
|
||||||
mdiChevronRight,
|
|
||||||
mdiCog,
|
mdiCog,
|
||||||
mdiContentDuplicate,
|
mdiContentDuplicate,
|
||||||
mdiDelete,
|
mdiDelete,
|
||||||
@@ -34,7 +34,6 @@ import { fireEvent } from "../../../common/dom/fire_event";
|
|||||||
import { computeStateName } from "../../../common/entity/compute_state_name";
|
import { computeStateName } from "../../../common/entity/compute_state_name";
|
||||||
import { navigate } from "../../../common/navigate";
|
import { navigate } from "../../../common/navigate";
|
||||||
import { slugify } from "../../../common/string/slugify";
|
import { slugify } from "../../../common/string/slugify";
|
||||||
import "../../../components/ha-tooltip";
|
|
||||||
import type { LocalizeFunc } from "../../../common/translations/localize";
|
import type { LocalizeFunc } from "../../../common/translations/localize";
|
||||||
import {
|
import {
|
||||||
hasRejectedItems,
|
hasRejectedItems,
|
||||||
@@ -47,6 +46,9 @@ import type {
|
|||||||
SortingChangedEvent,
|
SortingChangedEvent,
|
||||||
} from "../../../components/data-table/ha-data-table";
|
} from "../../../components/data-table/ha-data-table";
|
||||||
import "../../../components/data-table/ha-data-table-labels";
|
import "../../../components/data-table/ha-data-table-labels";
|
||||||
|
import "../../../components/ha-dropdown";
|
||||||
|
import "../../../components/ha-dropdown-item";
|
||||||
|
import type { HaDropdownItem } from "../../../components/ha-dropdown-item";
|
||||||
import "../../../components/ha-fab";
|
import "../../../components/ha-fab";
|
||||||
import "../../../components/ha-filter-blueprints";
|
import "../../../components/ha-filter-blueprints";
|
||||||
import "../../../components/ha-filter-categories";
|
import "../../../components/ha-filter-categories";
|
||||||
@@ -56,11 +58,8 @@ import "../../../components/ha-filter-floor-areas";
|
|||||||
import "../../../components/ha-filter-labels";
|
import "../../../components/ha-filter-labels";
|
||||||
import "../../../components/ha-icon-button";
|
import "../../../components/ha-icon-button";
|
||||||
import "../../../components/ha-icon-overflow-menu";
|
import "../../../components/ha-icon-overflow-menu";
|
||||||
import "../../../components/ha-md-divider";
|
|
||||||
import "../../../components/ha-md-menu";
|
|
||||||
import "../../../components/ha-md-menu-item";
|
|
||||||
import "../../../components/ha-sub-menu";
|
|
||||||
import "../../../components/ha-svg-icon";
|
import "../../../components/ha-svg-icon";
|
||||||
|
import "../../../components/ha-tooltip";
|
||||||
import { createAreaRegistryEntry } from "../../../data/area_registry";
|
import { createAreaRegistryEntry } from "../../../data/area_registry";
|
||||||
import type { CategoryRegistryEntry } from "../../../data/category_registry";
|
import type { CategoryRegistryEntry } from "../../../data/category_registry";
|
||||||
import {
|
import {
|
||||||
@@ -419,33 +418,35 @@ class HaScriptPicker extends SubscribeMixin(LitElement) {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
private _renderCategoryItems = (submenu = false) =>
|
||||||
const categoryItems = html`${this._categories?.map(
|
html`${this._categories?.map(
|
||||||
(category) =>
|
(category) =>
|
||||||
html`<ha-md-menu-item
|
html`<ha-dropdown-item
|
||||||
.value=${category.category_id}
|
.slot=${submenu ? "submenu" : ""}
|
||||||
.clickAction=${this._handleBulkCategory}
|
value="move_category"
|
||||||
|
data-category=${category.category_id}
|
||||||
>
|
>
|
||||||
${category.icon
|
${category.icon
|
||||||
? html`<ha-icon slot="start" .icon=${category.icon}></ha-icon>`
|
? html`<ha-icon slot="icon" .icon=${category.icon}></ha-icon>`
|
||||||
: html`<ha-svg-icon slot="start" .path=${mdiTag}></ha-svg-icon>`}
|
: html`<ha-svg-icon slot="icon" .path=${mdiTag}></ha-svg-icon>`}
|
||||||
<div slot="headline">${category.name}</div>
|
${category.name}
|
||||||
</ha-md-menu-item>`
|
</ha-dropdown-item>`
|
||||||
)}
|
)}
|
||||||
<ha-md-menu-item .value=${null} .clickAction=${this._handleBulkCategory}>
|
<ha-dropdown-item .slot=${submenu ? "submenu" : ""} value="no-category">
|
||||||
<div slot="headline">
|
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.automation.picker.bulk_actions.no_category"
|
"ui.panel.config.automation.picker.bulk_actions.no_category"
|
||||||
)}
|
)}
|
||||||
</div> </ha-md-menu-item
|
</ha-dropdown-item>
|
||||||
><ha-md-divider role="separator" tabindex="-1"></ha-md-divider>
|
<wa-divider .slot=${submenu ? "submenu" : ""}></wa-divider>
|
||||||
<ha-md-menu-item .clickAction=${this._bulkCreateCategory}>
|
<ha-dropdown-item
|
||||||
<div slot="headline">
|
.slot=${submenu ? "submenu" : ""}
|
||||||
|
value="create-category"
|
||||||
|
>
|
||||||
${this.hass.localize("ui.panel.config.category.editor.add")}
|
${this.hass.localize("ui.panel.config.category.editor.add")}
|
||||||
</div>
|
</ha-dropdown-item>`;
|
||||||
</ha-md-menu-item>`;
|
|
||||||
|
|
||||||
const labelItems = html`${this._labels?.map((label) => {
|
private _renderLabelItems = (submenu = false) =>
|
||||||
|
html`${this._labels?.map((label) => {
|
||||||
const color = label.color ? computeCssColor(label.color) : undefined;
|
const color = label.color ? computeCssColor(label.color) : undefined;
|
||||||
const selected = this._selected.every((entityId) =>
|
const selected = this._selected.every((entityId) =>
|
||||||
this.hass.entities[entityId]?.labels.includes(label.label_id)
|
this.hass.entities[entityId]?.labels.includes(label.label_id)
|
||||||
@@ -455,15 +456,13 @@ class HaScriptPicker extends SubscribeMixin(LitElement) {
|
|||||||
this._selected.some((entityId) =>
|
this._selected.some((entityId) =>
|
||||||
this.hass.entities[entityId]?.labels.includes(label.label_id)
|
this.hass.entities[entityId]?.labels.includes(label.label_id)
|
||||||
);
|
);
|
||||||
return html`<ha-md-menu-item
|
return html`<ha-dropdown-item
|
||||||
.value=${label.label_id}
|
@click=${this._handleLabelMenuSelect}
|
||||||
.action=${selected ? "remove" : "add"}
|
.slot=${submenu ? "submenu" : ""}
|
||||||
@click=${this._handleBulkLabel}
|
value=${label.label_id}
|
||||||
keep-open
|
data-action=${selected ? "remove" : "add"}
|
||||||
reducedTouchTarget
|
><ha-checkbox
|
||||||
>
|
slot="icon"
|
||||||
<ha-checkbox
|
|
||||||
slot="start"
|
|
||||||
.checked=${selected}
|
.checked=${selected}
|
||||||
.indeterminate=${partial}
|
.indeterminate=${partial}
|
||||||
></ha-checkbox>
|
></ha-checkbox>
|
||||||
@@ -476,46 +475,47 @@ class HaScriptPicker extends SubscribeMixin(LitElement) {
|
|||||||
: nothing}
|
: nothing}
|
||||||
${label.name}
|
${label.name}
|
||||||
</ha-label>
|
</ha-label>
|
||||||
</ha-md-menu-item>`;
|
</ha-dropdown-item>`;
|
||||||
})}
|
})}
|
||||||
<ha-md-divider role="separator" tabindex="-1"></ha-md-divider>
|
<wa-divider .slot=${submenu ? "submenu" : ""}></wa-divider>
|
||||||
<ha-md-menu-item .clickAction=${this._bulkCreateLabel}>
|
<ha-dropdown-item
|
||||||
<div slot="headline">
|
@click=${this._bulkCreateLabel}
|
||||||
|
.slot=${submenu ? "submenu" : ""}
|
||||||
|
value="create-label"
|
||||||
|
>
|
||||||
${this.hass.localize("ui.panel.config.labels.add_label")}
|
${this.hass.localize("ui.panel.config.labels.add_label")}
|
||||||
</div></ha-md-menu-item
|
</ha-dropdown-item>`;
|
||||||
>`;
|
|
||||||
|
|
||||||
const areaItems = html`${Object.values(this.hass.areas).map(
|
private _renderAreaItems = (submenu = false) =>
|
||||||
|
html`${Object.values(this.hass.areas).map(
|
||||||
(area) =>
|
(area) =>
|
||||||
html`<ha-md-menu-item
|
html`<ha-dropdown-item
|
||||||
.value=${area.area_id}
|
.slot=${submenu ? "submenu" : ""}
|
||||||
.clickAction=${this._handleBulkArea}
|
value="move_area"
|
||||||
|
data-area=${area.area_id}
|
||||||
>
|
>
|
||||||
${area.icon
|
${area.icon
|
||||||
? html`<ha-icon slot="start" .icon=${area.icon}></ha-icon>`
|
? html`<ha-icon slot="icon" .icon=${area.icon}></ha-icon>`
|
||||||
: html`<ha-svg-icon
|
: html`<ha-svg-icon
|
||||||
slot="start"
|
slot="icon"
|
||||||
.path=${mdiTextureBox}
|
.path=${mdiTextureBox}
|
||||||
></ha-svg-icon>`}
|
></ha-svg-icon>`}
|
||||||
<div slot="headline">${area.name}</div>
|
${area.name}
|
||||||
</ha-md-menu-item>`
|
</ha-dropdown-item>`
|
||||||
)}
|
)}
|
||||||
<ha-md-menu-item .value=${null} .clickAction=${this._handleBulkArea}>
|
<ha-dropdown-item .slot=${submenu ? "submenu" : ""} value="no-area">
|
||||||
<div slot="headline">
|
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.devices.picker.bulk_actions.no_area"
|
"ui.panel.config.devices.picker.bulk_actions.no_area"
|
||||||
)}
|
)}
|
||||||
</div>
|
</ha-dropdown-item>
|
||||||
</ha-md-menu-item>
|
<wa-divider .slot=${submenu ? "submenu" : ""}></wa-divider>
|
||||||
<ha-md-divider role="separator" tabindex="-1"></ha-md-divider>
|
<ha-dropdown-item .slot=${submenu ? "submenu" : ""} value="create-area">
|
||||||
<ha-md-menu-item .clickAction=${this._bulkCreateArea}>
|
|
||||||
<div slot="headline">
|
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.devices.picker.bulk_actions.add_area"
|
"ui.panel.config.devices.picker.bulk_actions.add_area"
|
||||||
)}
|
)}
|
||||||
</div>
|
</ha-dropdown-item>`;
|
||||||
</ha-md-menu-item>`;
|
|
||||||
|
|
||||||
|
protected render(): TemplateResult {
|
||||||
const areasInOverflow =
|
const areasInOverflow =
|
||||||
(this._sizeController.value && this._sizeController.value < 900) ||
|
(this._sizeController.value && this._sizeController.value < 900) ||
|
||||||
(!this._sizeController.value && this.hass.dockedSidebar === "docked");
|
(!this._sizeController.value && this.hass.dockedSidebar === "docked");
|
||||||
@@ -647,7 +647,10 @@ class HaScriptPicker extends SubscribeMixin(LitElement) {
|
|||||||
></ha-filter-blueprints>
|
></ha-filter-blueprints>
|
||||||
|
|
||||||
${!this.narrow
|
${!this.narrow
|
||||||
? html`<ha-md-button-menu slot="selection-bar">
|
? html`<ha-dropdown
|
||||||
|
slot="selection-bar"
|
||||||
|
@wa-select=${this._handleOverflowMenuSelect}
|
||||||
|
>
|
||||||
<ha-assist-chip
|
<ha-assist-chip
|
||||||
slot="trigger"
|
slot="trigger"
|
||||||
.label=${this.hass.localize(
|
.label=${this.hass.localize(
|
||||||
@@ -659,11 +662,11 @@ class HaScriptPicker extends SubscribeMixin(LitElement) {
|
|||||||
.path=${mdiMenuDown}
|
.path=${mdiMenuDown}
|
||||||
></ha-svg-icon>
|
></ha-svg-icon>
|
||||||
</ha-assist-chip>
|
</ha-assist-chip>
|
||||||
${categoryItems}
|
${this._renderCategoryItems()}
|
||||||
</ha-md-button-menu>
|
</ha-dropdown>
|
||||||
${labelsInOverflow
|
${labelsInOverflow
|
||||||
? nothing
|
? nothing
|
||||||
: html`<ha-md-button-menu slot="selection-bar">
|
: html`<ha-dropdown slot="selection-bar">
|
||||||
<ha-assist-chip
|
<ha-assist-chip
|
||||||
slot="trigger"
|
slot="trigger"
|
||||||
.label=${this.hass.localize(
|
.label=${this.hass.localize(
|
||||||
@@ -675,11 +678,14 @@ class HaScriptPicker extends SubscribeMixin(LitElement) {
|
|||||||
.path=${mdiMenuDown}
|
.path=${mdiMenuDown}
|
||||||
></ha-svg-icon>
|
></ha-svg-icon>
|
||||||
</ha-assist-chip>
|
</ha-assist-chip>
|
||||||
${labelItems}
|
${this._renderLabelItems()}
|
||||||
</ha-md-button-menu>`}
|
</ha-dropdown>`}
|
||||||
${areasInOverflow
|
${areasInOverflow
|
||||||
? nothing
|
? nothing
|
||||||
: html`<ha-md-button-menu slot="selection-bar">
|
: html`<ha-dropdown
|
||||||
|
slot="selection-bar"
|
||||||
|
@wa-select=${this._handleOverflowMenuSelect}
|
||||||
|
>
|
||||||
<ha-assist-chip
|
<ha-assist-chip
|
||||||
slot="trigger"
|
slot="trigger"
|
||||||
.label=${this.hass.localize(
|
.label=${this.hass.localize(
|
||||||
@@ -691,14 +697,15 @@ class HaScriptPicker extends SubscribeMixin(LitElement) {
|
|||||||
.path=${mdiMenuDown}
|
.path=${mdiMenuDown}
|
||||||
></ha-svg-icon>
|
></ha-svg-icon>
|
||||||
</ha-assist-chip>
|
</ha-assist-chip>
|
||||||
${areaItems}
|
${this._renderAreaItems()}
|
||||||
</ha-md-button-menu>`}`
|
</ha-dropdown>`}`
|
||||||
: nothing}
|
: nothing}
|
||||||
${this.narrow || areasInOverflow
|
${this.narrow || areasInOverflow
|
||||||
? html`
|
? html` <ha-dropdown
|
||||||
<ha-md-button-menu has-overflow slot="selection-bar">
|
slot="selection-bar"
|
||||||
${
|
@wa-select=${this._handleOverflowMenuSelect}
|
||||||
this.narrow
|
>
|
||||||
|
${this.narrow
|
||||||
? html`<ha-assist-chip
|
? html`<ha-assist-chip
|
||||||
.label=${this.hass.localize(
|
.label=${this.hass.localize(
|
||||||
"ui.panel.config.automation.picker.bulk_action"
|
"ui.panel.config.automation.picker.bulk_action"
|
||||||
@@ -716,68 +723,32 @@ class HaScriptPicker extends SubscribeMixin(LitElement) {
|
|||||||
"ui.panel.config.automation.picker.bulk_action"
|
"ui.panel.config.automation.picker.bulk_action"
|
||||||
)}
|
)}
|
||||||
slot="trigger"
|
slot="trigger"
|
||||||
></ha-icon-button>`
|
></ha-icon-button>`}
|
||||||
}
|
${this.narrow
|
||||||
<ha-svg-icon
|
? html`<ha-dropdown-item>
|
||||||
slot="trailing-icon"
|
|
||||||
.path=${mdiMenuDown}
|
|
||||||
></ha-svg-icon
|
|
||||||
></ha-assist-chip>
|
|
||||||
${
|
|
||||||
this.narrow
|
|
||||||
? html`<ha-sub-menu>
|
|
||||||
<ha-md-menu-item slot="item">
|
|
||||||
<div slot="headline">
|
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.automation.picker.bulk_actions.move_category"
|
"ui.panel.config.automation.picker.bulk_actions.move_category"
|
||||||
)}
|
)}
|
||||||
</div>
|
${this._renderCategoryItems(true)}
|
||||||
<ha-svg-icon
|
</ha-dropdown-item>`
|
||||||
slot="end"
|
: nothing}
|
||||||
.path=${mdiChevronRight}
|
${this.narrow || labelsInOverflow
|
||||||
></ha-svg-icon>
|
? html`<ha-dropdown-item>
|
||||||
</ha-md-menu-item>
|
|
||||||
<ha-md-menu slot="menu">${categoryItems}</ha-md-menu>
|
|
||||||
</ha-sub-menu>`
|
|
||||||
: nothing
|
|
||||||
}
|
|
||||||
${
|
|
||||||
this.narrow || labelsInOverflow
|
|
||||||
? html`<ha-sub-menu>
|
|
||||||
<ha-md-menu-item slot="item">
|
|
||||||
<div slot="headline">
|
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.automation.picker.bulk_actions.add_label"
|
"ui.panel.config.automation.picker.bulk_actions.add_label"
|
||||||
)}
|
)}
|
||||||
</div>
|
${this._renderLabelItems(true)}
|
||||||
<ha-svg-icon
|
</ha-dropdown-item>`
|
||||||
slot="end"
|
: nothing}
|
||||||
.path=${mdiChevronRight}
|
${this.narrow || areasInOverflow
|
||||||
></ha-svg-icon>
|
? html`<ha-dropdown-item>
|
||||||
</ha-md-menu-item>
|
|
||||||
<ha-md-menu slot="menu">${labelItems}</ha-md-menu>
|
|
||||||
</ha-sub-menu>`
|
|
||||||
: nothing
|
|
||||||
}
|
|
||||||
${
|
|
||||||
this.narrow || areasInOverflow
|
|
||||||
? html`<ha-sub-menu>
|
|
||||||
<ha-md-menu-item slot="item">
|
|
||||||
<div slot="headline">
|
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.devices.picker.bulk_actions.move_area"
|
"ui.panel.config.devices.picker.bulk_actions.move_area"
|
||||||
)}
|
)}
|
||||||
</div>
|
${this._renderAreaItems(true)}
|
||||||
<ha-svg-icon
|
</ha-dropdown-item>`
|
||||||
slot="end"
|
: nothing}
|
||||||
.path=${mdiChevronRight}
|
</ha-dropdown>`
|
||||||
></ha-svg-icon>
|
|
||||||
</ha-md-menu-item>
|
|
||||||
<ha-md-menu slot="menu">${areaItems}</ha-md-menu>
|
|
||||||
</ha-sub-menu>`
|
|
||||||
: nothing
|
|
||||||
}
|
|
||||||
</ha-md-button-menu>`
|
|
||||||
: nothing}
|
: nothing}
|
||||||
${!this.scripts.length
|
${!this.scripts.length
|
||||||
? html` <div class="empty" slot="empty">
|
? html` <div class="empty" slot="empty">
|
||||||
@@ -995,9 +966,46 @@ class HaScriptPicker extends SubscribeMixin(LitElement) {
|
|||||||
this._selected = ev.detail.value;
|
this._selected = ev.detail.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _handleBulkCategory = (item) => {
|
private _handleLabelMenuSelect = (ev: CustomEvent) => {
|
||||||
const category = item.value;
|
ev.stopPropagation();
|
||||||
this._bulkAddCategory(category);
|
const item = ev.currentTarget as HaDropdownItem & {
|
||||||
|
dataset: { action?: string };
|
||||||
|
};
|
||||||
|
const action = item.dataset.action as "add" | "remove";
|
||||||
|
this._bulkLabel(item.value, action);
|
||||||
|
};
|
||||||
|
|
||||||
|
private _handleOverflowMenuSelect = (ev: CustomEvent) => {
|
||||||
|
const item = ev.detail.item as HaDropdownItem & {
|
||||||
|
dataset: { action?: string };
|
||||||
|
};
|
||||||
|
switch (item.value) {
|
||||||
|
case "create-category":
|
||||||
|
this._bulkCreateCategory();
|
||||||
|
break;
|
||||||
|
case "no-category":
|
||||||
|
this._bulkAddCategory(null!);
|
||||||
|
break;
|
||||||
|
case "create-label":
|
||||||
|
this._bulkCreateLabel();
|
||||||
|
break;
|
||||||
|
case "create-area":
|
||||||
|
this._bulkCreateArea();
|
||||||
|
break;
|
||||||
|
case "no-area":
|
||||||
|
this._bulkAddArea(null!);
|
||||||
|
break;
|
||||||
|
case "move_area":
|
||||||
|
if (item.dataset.area) {
|
||||||
|
this._bulkAddArea(item.dataset.area);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "move_category":
|
||||||
|
if (item.dataset.category) {
|
||||||
|
this._bulkAddCategory(item.dataset.category);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private async _bulkAddCategory(category: string) {
|
private async _bulkAddCategory(category: string) {
|
||||||
@@ -1025,12 +1033,6 @@ ${rejected
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _handleBulkLabel(ev) {
|
|
||||||
const label = ev.currentTarget.value;
|
|
||||||
const action = ev.currentTarget.action;
|
|
||||||
this._bulkLabel(label, action);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async _bulkLabel(label: string, action: "add" | "remove") {
|
private async _bulkLabel(label: string, action: "add" | "remove") {
|
||||||
const promises: Promise<UpdateEntityRegistryEntryResult>[] = [];
|
const promises: Promise<UpdateEntityRegistryEntryResult>[] = [];
|
||||||
this._selected.forEach((entityId) => {
|
this._selected.forEach((entityId) => {
|
||||||
@@ -1235,11 +1237,6 @@ ${rejected
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
private _handleBulkArea = (item) => {
|
|
||||||
const area = item.value;
|
|
||||||
this._bulkAddArea(area);
|
|
||||||
};
|
|
||||||
|
|
||||||
private async _bulkAddArea(area: string) {
|
private async _bulkAddArea(area: string) {
|
||||||
const promises: Promise<UpdateEntityRegistryEntryResult>[] = [];
|
const promises: Promise<UpdateEntityRegistryEntryResult>[] = [];
|
||||||
this._selected.forEach((entityId) => {
|
this._selected.forEach((entityId) => {
|
||||||
@@ -1322,7 +1319,7 @@ ${rejected
|
|||||||
ha-assist-chip {
|
ha-assist-chip {
|
||||||
--ha-assist-chip-container-shape: 10px;
|
--ha-assist-chip-container-shape: 10px;
|
||||||
}
|
}
|
||||||
ha-md-button-menu ha-assist-chip {
|
ha-dropdown ha-assist-chip {
|
||||||
--md-assist-chip-trailing-space: 8px;
|
--md-assist-chip-trailing-space: 8px;
|
||||||
}
|
}
|
||||||
ha-label {
|
ha-label {
|
||||||
|
|||||||
Reference in New Issue
Block a user