) {
- if (ev.detail.source !== "interaction") {
- return;
- }
+ private _switchYamlMode() {
this._yamlMode = !this._yamlMode;
}
- static get styles(): CSSResult {
- return css`
- .card-menu {
- position: absolute;
- top: 0;
- right: 0;
- z-index: 3;
- --mdc-theme-text-primary-on-background: var(--primary-text-color);
- }
- .rtl .card-menu {
- right: auto;
- left: 0;
- }
- ha-button-menu {
- margin: 8px;
- }
- mwc-list-item[disabled] {
- --mdc-theme-text-primary-on-background: var(--disabled-text-color);
- }
- .warning {
- color: var(--warning-color);
- margin-bottom: 8px;
- }
- .warning ul {
- margin: 4px 0;
- }
- `;
+ static get styles(): CSSResult[] {
+ return [
+ haStyle,
+ css`
+ .card-menu {
+ float: right;
+ z-index: 3;
+ --mdc-theme-text-primary-on-background: var(--primary-text-color);
+ }
+ .rtl .card-menu {
+ float: left;
+ }
+ mwc-list-item[disabled] {
+ --mdc-theme-text-primary-on-background: var(--disabled-text-color);
+ }
+ .warning {
+ color: var(--warning-color);
+ margin-bottom: 8px;
+ }
+ .warning ul {
+ margin: 4px 0;
+ }
+ `,
+ ];
}
}
diff --git a/src/panels/config/automation/condition/ha-automation-condition-editor.ts b/src/panels/config/automation/condition/ha-automation-condition-editor.ts
index ecc54fdfd1..9f3f0d91f1 100644
--- a/src/panels/config/automation/condition/ha-automation-condition-editor.ts
+++ b/src/panels/config/automation/condition/ha-automation-condition-editor.ts
@@ -2,7 +2,13 @@ import "@polymer/paper-dropdown-menu/paper-dropdown-menu-light";
import "@polymer/paper-item/paper-item";
import "@polymer/paper-listbox/paper-listbox";
import type { PaperListboxElement } from "@polymer/paper-listbox/paper-listbox";
-import { customElement, html, LitElement, property } from "lit-element";
+import {
+ customElement,
+ html,
+ LitElement,
+ property,
+ CSSResult,
+} from "lit-element";
import { dynamicElement } from "../../../../common/dom/dynamic-element-directive";
import { fireEvent } from "../../../../common/dom/fire_event";
import "../../../../components/ha-card";
@@ -19,6 +25,7 @@ import "./types/ha-automation-condition-sun";
import "./types/ha-automation-condition-template";
import "./types/ha-automation-condition-time";
import "./types/ha-automation-condition-zone";
+import { haStyle } from "../../../../resources/styles";
const OPTIONS = [
"device",
@@ -47,21 +54,20 @@ export default class HaAutomationConditionEditor extends LitElement {
return html`
${yamlMode
? html`
-
- ${selected === -1
- ? html`
- ${this.hass.localize(
- "ui.panel.config.automation.editor.conditions.unsupported_condition",
- "condition",
- this.condition.condition
- )}
- `
- : ""}
-
-
+ ${selected === -1
+ ? html`
+ ${this.hass.localize(
+ "ui.panel.config.automation.editor.conditions.unsupported_condition",
+ "condition",
+ this.condition.condition
+ )}
+ `
+ : ""}
+ Edit in YAML
+
`
: html`
`
: ""}
-
+
-
+
${this.hass.localize(
this._showIgnored
? "ui.panel.config.integrations.ignore.hide_ignored"
diff --git a/src/panels/config/integrations/ha-integration-card.ts b/src/panels/config/integrations/ha-integration-card.ts
index e2d5ea4215..ecb06696b3 100644
--- a/src/panels/config/integrations/ha-integration-card.ts
+++ b/src/panels/config/integrations/ha-integration-card.ts
@@ -28,6 +28,7 @@ import { haStyle } from "../../../resources/styles";
import "../../../components/ha-icon-next";
import { fireEvent } from "../../../common/dom/fire_event";
import { mdiDotsVertical, mdiOpenInNew } from "@mdi/js";
+import { ActionDetail } from "@material/mwc-list/mwc-list-foundation";
export interface ConfigEntryUpdatedEvent {
entry: ConfigEntry;
@@ -223,7 +224,7 @@ export class HaIntegrationCard extends LitElement {
`
: ""}
-
+
-
+
${this.hass.localize(
"ui.panel.config.integrations.config_entry.system_options"
)}
@@ -240,7 +241,6 @@ export class HaIntegrationCard extends LitElement {
? ""
: html`
`}
-
+
${this.hass.localize(
"ui.panel.config.integrations.config_entry.delete"
)}
@@ -308,32 +305,27 @@ export class HaIntegrationCard extends LitElement {
showOptionsFlowDialog(this, ev.target.closest("ha-card").configEntry);
}
- private _showSystemOptions(ev) {
- showConfigEntrySystemOptionsDialog(this, {
- entry: ev.target.closest("ha-card").configEntry,
- });
- }
-
- private async _editEntryName(ev) {
- const configEntry = ev.target.closest("ha-card").configEntry;
- const newName = await showPromptDialog(this, {
- title: this.hass.localize("ui.panel.config.integrations.rename_dialog"),
- defaultValue: configEntry.title,
- inputLabel: this.hass.localize(
- "ui.panel.config.integrations.rename_input_label"
- ),
- });
- if (newName === null) {
- return;
+ private _handleAction(ev: CustomEvent) {
+ const configEntry = ((ev.target as HTMLElement).closest("ha-card") as any)
+ .configEntry;
+ switch (ev.detail.index) {
+ case 0:
+ this._showSystemOptions(configEntry);
+ break;
+ case 1:
+ this._removeIntegration(configEntry);
+ break;
}
- const newEntry = await updateConfigEntry(this.hass, configEntry.entry_id, {
- title: newName,
- });
- fireEvent(this, "entry-updated", { entry: newEntry });
}
- private async _removeIntegration(ev) {
- const entryId = ev.target.closest("ha-card").configEntry.entry_id;
+ private _showSystemOptions(configEntry: ConfigEntry) {
+ showConfigEntrySystemOptionsDialog(this, {
+ entry: configEntry,
+ });
+ }
+
+ private async _removeIntegration(configEntry: ConfigEntry) {
+ const entryId = configEntry.entry_id;
const confirmed = await showConfirmationDialog(this, {
text: this.hass.localize(
@@ -357,6 +349,24 @@ export class HaIntegrationCard extends LitElement {
});
}
+ private async _editEntryName(ev) {
+ const configEntry = ev.target.closest("ha-card").configEntry;
+ const newName = await showPromptDialog(this, {
+ title: this.hass.localize("ui.panel.config.integrations.rename_dialog"),
+ defaultValue: configEntry.title,
+ inputLabel: this.hass.localize(
+ "ui.panel.config.integrations.rename_input_label"
+ ),
+ });
+ if (newName === null) {
+ return;
+ }
+ const newEntry = await updateConfigEntry(this.hass, configEntry.entry_id, {
+ title: newName,
+ });
+ fireEvent(this, "entry-updated", { entry: newEntry });
+ }
+
static get styles(): CSSResult[] {
return [
haStyle,
@@ -389,9 +399,6 @@ export class HaIntegrationCard extends LitElement {
align-items: center;
padding-right: 5px;
}
- .card-actions .documentation {
- color: var(--primary-text-color);
- }
.group-header {
display: flex;
align-items: center;
diff --git a/src/panels/lovelace/components/hui-card-options.ts b/src/panels/lovelace/components/hui-card-options.ts
index cf33b6971f..8191ea54c2 100644
--- a/src/panels/lovelace/components/hui-card-options.ts
+++ b/src/panels/lovelace/components/hui-card-options.ts
@@ -20,6 +20,7 @@ import { confDeleteCard } from "../editor/delete-card";
import { Lovelace, LovelaceCard } from "../types";
import { computeCardSize } from "../common/compute-card-size";
import { mdiDotsVertical, mdiArrowDown, mdiArrowUp } from "@mdi/js";
+import { ActionDetail } from "@material/mwc-list/mwc-list-foundation";
@customElement("hui-card-options")
export class HuiCardOptions extends LitElement {
@@ -65,7 +66,7 @@ export class HuiCardOptions extends LitElement {
?disabled=${this.path![1] === 0}
>
-
+
-
+
${this.hass!.localize(
"ui.panel.lovelace.editor.edit_card.move"
)}
- ${this.hass!.localize(
"ui.panel.lovelace.editor.edit_card.duplicate"
)}
-
+
${this.hass!.localize(
"ui.panel.lovelace.editor.edit_card.delete"
)}) {
+ switch (ev.detail.index) {
+ case 0:
+ this._moveCard();
+ break;
+ case 1:
+ this._duplicateCard();
+ break;
+ case 2:
+ this._deleteCard();
+ break;
+ }
+ }
+
private _duplicateCard(): void {
const path = this.path!;
const cardConfig = this.lovelace!.config.views[path[0]].cards![path[1]];
diff --git a/src/panels/lovelace/hui-root.ts b/src/panels/lovelace/hui-root.ts
index a473d394c0..71ad3488e1 100644
--- a/src/panels/lovelace/hui-root.ts
+++ b/src/panels/lovelace/hui-root.ts
@@ -58,6 +58,8 @@ import type { Lovelace } from "./types";
import "./views/hui-panel-view";
import type { HUIPanelView } from "./views/hui-panel-view";
import { HUIView } from "./views/hui-view";
+import type { RequestSelectedDetail } from "@material/mwc-list/mwc-list-item";
+import { shouldHandleRequestSelectedEvent } from "../../common/mwc/handle-request-selected-event";
class HUIRoot extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;
@@ -133,14 +135,19 @@ class HUIRoot extends LitElement {
-
-
-
+
+
+
+
`}
-
+
${this.hass!.localize(
"ui.panel.lovelace.editor.menu.raw_editor"
)}
@@ -251,7 +256,7 @@ class HUIRoot extends LitElement {
aria-label=${this.hass!.localize(
"ui.panel.lovelace.menu.configure_ui"
)}
- @request-selected=${this._editModeEnable}
+ @request-selected=${this._handleEnableEditMode}
>
${this.hass!.localize(
"ui.panel.lovelace.menu.configure_ui"
@@ -259,14 +264,19 @@ class HUIRoot extends LitElement {
`
: ""}
-
- ${this.hass!.localize("ui.panel.lovelace.menu.help")}
-
+
+ ${this.hass!.localize("ui.panel.lovelace.menu.help")}
+
+
`}
@@ -476,11 +486,17 @@ class HUIRoot extends LitElement {
return this.shadowRoot!.getElementById("view") as HTMLDivElement;
}
- private _handleRefresh(): void {
+ private _handleRefresh(ev: CustomEvent): void {
+ if (!shouldHandleRequestSelectedEvent(ev)) {
+ return;
+ }
fireEvent(this, "config-refresh");
}
- private _handleReloadResources(): void {
+ private _handleReloadResources(ev: CustomEvent): void {
+ if (!shouldHandleRequestSelectedEvent(ev)) {
+ return;
+ }
this.hass.callService("lovelace", "reload_resources");
showConfirmationDialog(this, {
title: this.hass!.localize(
@@ -493,7 +509,17 @@ class HUIRoot extends LitElement {
});
}
- private _handleUnusedEntities(): void {
+ private _handleRawEditor(ev: CustomEvent): void {
+ if (!shouldHandleRequestSelectedEvent(ev)) {
+ return;
+ }
+ this.lovelace!.enableFullEditMode();
+ }
+
+ private _handleUnusedEntities(ev: CustomEvent): void {
+ if (!shouldHandleRequestSelectedEvent(ev)) {
+ return;
+ }
navigate(this, `${this.route?.prefix}/hass-unused-entities`);
}
@@ -501,17 +527,20 @@ class HUIRoot extends LitElement {
showVoiceCommandDialog(this);
}
- private _handleHelp(): void {
- window.open("https://www.home-assistant.io/lovelace/", "_blank");
- }
-
- private _editModeEnable(): void {
+ private _handleEnableEditMode(ev: CustomEvent): void {
+ if (!shouldHandleRequestSelectedEvent(ev)) {
+ return;
+ }
if (this._yamlMode) {
showAlertDialog(this, {
text: "The edit UI is not available when in YAML mode.",
});
return;
}
+ this._enableEditMode();
+ }
+
+ private _enableEditMode(): void {
this.lovelace!.setEditMode(true);
}
@@ -616,7 +645,7 @@ class HUIRoot extends LitElement {
const viewConfig = this.config.views[viewIndex];
if (!viewConfig) {
- this._editModeEnable();
+ this._enableEditMode();
return;
}
diff --git a/src/panels/shopping-list/ha-panel-shopping-list.js b/src/panels/shopping-list/ha-panel-shopping-list.js
index 94644a6e6a..2ee804a311 100644
--- a/src/panels/shopping-list/ha-panel-shopping-list.js
+++ b/src/panels/shopping-list/ha-panel-shopping-list.js
@@ -83,14 +83,14 @@ class HaPanelShoppingList extends LocalizeMixin(PolymerElement) {
icon="hass:microphone"
on-click="_showVoiceCommandDialog"
>
-
+
-
+
[[localize('ui.panel.shopping-list.clear_completed')]]