mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 19:26:36 +00:00
Fix more keyboard menus (devices/helpers/scenes/scripts) (#24037)
* Fix more keyboard menus (devices/helpers/scenes/scripts) * Apply suggestions from code review Co-authored-by: Petar Petrov <MindFreeze@users.noreply.github.com> * less async --------- Co-authored-by: Petar Petrov <MindFreeze@users.noreply.github.com>
This commit is contained in:
parent
67b970fcaa
commit
7d1f8d618a
@ -626,7 +626,7 @@ export class HaConfigDeviceDashboard extends SubscribeMixin(LitElement) {
|
||||
(area) =>
|
||||
html`<ha-md-menu-item
|
||||
.value=${area.area_id}
|
||||
@click=${this._handleBulkArea}
|
||||
.clickAction=${this._handleBulkArea}
|
||||
>
|
||||
${area.icon
|
||||
? html`<ha-icon slot="start" .icon=${area.icon}></ha-icon>`
|
||||
@ -637,7 +637,7 @@ export class HaConfigDeviceDashboard extends SubscribeMixin(LitElement) {
|
||||
<div slot="headline">${area.name}</div>
|
||||
</ha-md-menu-item>`
|
||||
)}
|
||||
<ha-md-menu-item .value=${null} @click=${this._handleBulkArea}>
|
||||
<ha-md-menu-item .value=${null} .clickAction=${this._handleBulkArea}>
|
||||
<div slot="headline">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.devices.picker.bulk_actions.no_area"
|
||||
@ -645,7 +645,7 @@ export class HaConfigDeviceDashboard extends SubscribeMixin(LitElement) {
|
||||
</div>
|
||||
</ha-md-menu-item>
|
||||
<ha-md-divider role="separator" tabindex="-1"></ha-md-divider>
|
||||
<ha-md-menu-item @click=${this._bulkCreateArea}>
|
||||
<ha-md-menu-item .clickAction=${this._bulkCreateArea}>
|
||||
<div slot="headline">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.devices.picker.bulk_actions.add_area"
|
||||
@ -684,7 +684,7 @@ export class HaConfigDeviceDashboard extends SubscribeMixin(LitElement) {
|
||||
</ha-md-menu-item>`;
|
||||
})}
|
||||
<ha-md-divider role="separator" tabindex="-1"></ha-md-divider>
|
||||
<ha-md-menu-item @click=${this._bulkCreateLabel}>
|
||||
<ha-md-menu-item .clickAction=${this._bulkCreateLabel}>
|
||||
<div slot="headline">
|
||||
${this.hass.localize("ui.panel.config.labels.add_label")}
|
||||
</div></ha-md-menu-item
|
||||
@ -969,10 +969,10 @@ export class HaConfigDeviceDashboard extends SubscribeMixin(LitElement) {
|
||||
this._selected = ev.detail.value;
|
||||
}
|
||||
|
||||
private async _handleBulkArea(ev) {
|
||||
const area = ev.currentTarget.value;
|
||||
private _handleBulkArea = (item) => {
|
||||
const area = item.value;
|
||||
this._bulkAddArea(area);
|
||||
}
|
||||
};
|
||||
|
||||
private async _bulkAddArea(area: string) {
|
||||
const promises: Promise<DeviceRegistryEntry>[] = [];
|
||||
@ -999,7 +999,7 @@ ${rejected
|
||||
}
|
||||
}
|
||||
|
||||
private async _bulkCreateArea() {
|
||||
private _bulkCreateArea = () => {
|
||||
showAreaRegistryDetailDialog(this, {
|
||||
createEntry: async (values) => {
|
||||
const area = await createAreaRegistryEntry(this.hass, values);
|
||||
@ -1007,7 +1007,7 @@ ${rejected
|
||||
return area;
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
private async _handleBulkLabel(ev) {
|
||||
const label = ev.currentTarget.value;
|
||||
@ -1045,7 +1045,7 @@ ${rejected
|
||||
}
|
||||
}
|
||||
|
||||
private _bulkCreateLabel() {
|
||||
private _bulkCreateLabel = () => {
|
||||
showLabelDetailDialog(this, {
|
||||
createEntry: async (values) => {
|
||||
const label = await createLabelRegistryEntry(this.hass, values);
|
||||
@ -1053,7 +1053,7 @@ ${rejected
|
||||
return label;
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
private _handleSortingChanged(ev: CustomEvent) {
|
||||
this._activeSorting = ev.detail;
|
||||
|
@ -561,7 +561,7 @@ export class HaConfigHelpers extends SubscribeMixin(LitElement) {
|
||||
(category) =>
|
||||
html`<ha-md-menu-item
|
||||
.value=${category.category_id}
|
||||
@click=${this._handleBulkCategory}
|
||||
.clickAction=${this._handleBulkCategory}
|
||||
>
|
||||
${category.icon
|
||||
? html`<ha-icon slot="start" .icon=${category.icon}></ha-icon>`
|
||||
@ -569,7 +569,7 @@ export class HaConfigHelpers extends SubscribeMixin(LitElement) {
|
||||
<div slot="headline">${category.name}</div>
|
||||
</ha-md-menu-item>`
|
||||
)}
|
||||
<ha-md-menu-item .value=${null} @click=${this._handleBulkCategory}>
|
||||
<ha-md-menu-item .value=${null} .clickAction=${this._handleBulkCategory}>
|
||||
<div slot="headline">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.automation.picker.bulk_actions.no_category"
|
||||
@ -577,7 +577,7 @@ export class HaConfigHelpers extends SubscribeMixin(LitElement) {
|
||||
</div>
|
||||
</ha-md-menu-item>
|
||||
<ha-md-divider role="separator" tabindex="-1"></ha-md-divider>
|
||||
<ha-md-menu-item @click=${this._bulkCreateCategory}>
|
||||
<ha-md-menu-item .clickAction=${this._bulkCreateCategory}>
|
||||
<div slot="headline">
|
||||
${this.hass.localize("ui.panel.config.category.editor.add")}
|
||||
</div>
|
||||
@ -612,7 +612,7 @@ export class HaConfigHelpers extends SubscribeMixin(LitElement) {
|
||||
</ha-label>
|
||||
</ha-md-menu-item> `;
|
||||
})}<ha-md-divider role="separator" tabindex="-1"></ha-md-divider>
|
||||
<ha-md-menu-item @click=${this._bulkCreateLabel}>
|
||||
<ha-md-menu-item .clickAction=${this._bulkCreateLabel}>
|
||||
<div slot="headline">
|
||||
${this.hass.localize("ui.panel.config.labels.add_label")}
|
||||
</div>
|
||||
@ -958,10 +958,10 @@ export class HaConfigHelpers extends SubscribeMixin(LitElement) {
|
||||
});
|
||||
}
|
||||
|
||||
private async _handleBulkCategory(ev) {
|
||||
const category = ev.currentTarget.value;
|
||||
private _handleBulkCategory = (item) => {
|
||||
const category = item.value;
|
||||
this._bulkAddCategory(category);
|
||||
}
|
||||
};
|
||||
|
||||
private async _bulkAddCategory(category: string) {
|
||||
const promises: Promise<UpdateEntityRegistryEntryResult>[] = [];
|
||||
@ -1234,7 +1234,7 @@ ${rejected
|
||||
showHelperDetailDialog(this, {});
|
||||
}
|
||||
|
||||
private async _bulkCreateCategory() {
|
||||
private _bulkCreateCategory = () => {
|
||||
showCategoryRegistryDetailDialog(this, {
|
||||
scope: "helpers",
|
||||
createEntry: async (values) => {
|
||||
@ -1247,9 +1247,9 @@ ${rejected
|
||||
return category;
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
private _bulkCreateLabel() {
|
||||
private _bulkCreateLabel = () => {
|
||||
showLabelDetailDialog(this, {
|
||||
createEntry: async (values) => {
|
||||
const label = await createLabelRegistryEntry(this.hass, values);
|
||||
@ -1257,7 +1257,7 @@ ${rejected
|
||||
return label;
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
private _handleSortingChanged(ev: CustomEvent) {
|
||||
this._activeSorting = ev.detail;
|
||||
|
@ -420,7 +420,7 @@ class HaSceneDashboard extends SubscribeMixin(LitElement) {
|
||||
(category) =>
|
||||
html`<ha-md-menu-item
|
||||
.value=${category.category_id}
|
||||
@click=${this._handleBulkCategory}
|
||||
.clickAction=${this._handleBulkCategory}
|
||||
>
|
||||
${category.icon
|
||||
? html`<ha-icon slot="start" .icon=${category.icon}></ha-icon>`
|
||||
@ -428,7 +428,7 @@ class HaSceneDashboard extends SubscribeMixin(LitElement) {
|
||||
<div slot="headline">${category.name}</div>
|
||||
</ha-md-menu-item>`
|
||||
)}
|
||||
<ha-md-menu-item .value=${null} @click=${this._handleBulkCategory}>
|
||||
<ha-md-menu-item .value=${null} .clickAction=${this._handleBulkCategory}>
|
||||
<div slot="headline">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.automation.picker.bulk_actions.no_category"
|
||||
@ -436,7 +436,7 @@ class HaSceneDashboard extends SubscribeMixin(LitElement) {
|
||||
</div>
|
||||
</ha-md-menu-item>
|
||||
<ha-md-divider role="separator" tabindex="-1"></ha-md-divider>
|
||||
<ha-md-menu-item @click=${this._bulkCreateCategory}>
|
||||
<ha-md-menu-item .clickAction=${this._bulkCreateCategory}>
|
||||
<div slot="headline">
|
||||
${this.hass.localize("ui.panel.config.category.editor.add")}
|
||||
</div>
|
||||
@ -473,7 +473,7 @@ class HaSceneDashboard extends SubscribeMixin(LitElement) {
|
||||
</ha-md-menu-item>`;
|
||||
})}
|
||||
<ha-md-divider role="separator" tabindex="-1"></ha-md-divider>
|
||||
<ha-md-menu-item @click=${this._bulkCreateLabel}>
|
||||
<ha-md-menu-item .clickAction=${this._bulkCreateLabel}>
|
||||
<div slot="headline">
|
||||
${this.hass.localize("ui.panel.config.labels.add_label")}
|
||||
</div></ha-md-menu-item
|
||||
@ -483,7 +483,7 @@ class HaSceneDashboard extends SubscribeMixin(LitElement) {
|
||||
(area) =>
|
||||
html`<ha-md-menu-item
|
||||
.value=${area.area_id}
|
||||
@click=${this._handleBulkArea}
|
||||
.clickAction=${this._handleBulkArea}
|
||||
>
|
||||
${area.icon
|
||||
? html`<ha-icon slot="start" .icon=${area.icon}></ha-icon>`
|
||||
@ -494,7 +494,7 @@ class HaSceneDashboard extends SubscribeMixin(LitElement) {
|
||||
<div slot="headline">${area.name}</div>
|
||||
</ha-md-menu-item>`
|
||||
)}
|
||||
<ha-md-menu-item .value=${null} @click=${this._handleBulkArea}>
|
||||
<ha-md-menu-item .value=${null} .clickAction=${this._handleBulkArea}>
|
||||
<div slot="headline">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.devices.picker.bulk_actions.no_area"
|
||||
@ -502,7 +502,7 @@ class HaSceneDashboard extends SubscribeMixin(LitElement) {
|
||||
</div>
|
||||
</ha-md-menu-item>
|
||||
<ha-md-divider role="separator" tabindex="-1"></ha-md-divider>
|
||||
<ha-md-menu-item @click=${this._bulkCreateArea}>
|
||||
<ha-md-menu-item .clickAction=${this._bulkCreateArea}>
|
||||
<div slot="headline">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.devices.picker.bulk_actions.add_area"
|
||||
@ -932,10 +932,10 @@ class HaSceneDashboard extends SubscribeMixin(LitElement) {
|
||||
}
|
||||
}
|
||||
|
||||
private async _handleBulkCategory(ev) {
|
||||
const category = ev.currentTarget.value;
|
||||
private _handleBulkCategory = (item) => {
|
||||
const category = item.value;
|
||||
this._bulkAddCategory(category);
|
||||
}
|
||||
};
|
||||
|
||||
private async _bulkAddCategory(category: string) {
|
||||
const promises: Promise<UpdateEntityRegistryEntryResult>[] = [];
|
||||
@ -998,10 +998,10 @@ ${rejected
|
||||
}
|
||||
}
|
||||
|
||||
private async _handleBulkArea(ev) {
|
||||
const area = ev.currentTarget.value;
|
||||
private _handleBulkArea = (item) => {
|
||||
const area = item.value;
|
||||
this._bulkAddArea(area);
|
||||
}
|
||||
};
|
||||
|
||||
private async _bulkAddArea(area: string) {
|
||||
const promises: Promise<UpdateEntityRegistryEntryResult>[] = [];
|
||||
@ -1028,7 +1028,7 @@ ${rejected
|
||||
}
|
||||
}
|
||||
|
||||
private async _bulkCreateArea() {
|
||||
private _bulkCreateArea = () => {
|
||||
showAreaRegistryDetailDialog(this, {
|
||||
createEntry: async (values) => {
|
||||
const area = await createAreaRegistryEntry(this.hass, values);
|
||||
@ -1036,7 +1036,7 @@ ${rejected
|
||||
return area;
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
private _editCategory(scene: any) {
|
||||
const entityReg = this._entityReg.find(
|
||||
@ -1133,7 +1133,7 @@ ${rejected
|
||||
});
|
||||
}
|
||||
|
||||
private async _bulkCreateCategory() {
|
||||
private _bulkCreateCategory = () => {
|
||||
showCategoryRegistryDetailDialog(this, {
|
||||
scope: "scene",
|
||||
createEntry: async (values) => {
|
||||
@ -1146,9 +1146,9 @@ ${rejected
|
||||
return category;
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
private _bulkCreateLabel() {
|
||||
private _bulkCreateLabel = () => {
|
||||
showLabelDetailDialog(this, {
|
||||
createEntry: async (values) => {
|
||||
const label = await createLabelRegistryEntry(this.hass, values);
|
||||
@ -1156,7 +1156,7 @@ ${rejected
|
||||
return label;
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
private _handleSortingChanged(ev: CustomEvent) {
|
||||
this._activeSorting = ev.detail;
|
||||
|
@ -410,7 +410,7 @@ class HaScriptPicker extends SubscribeMixin(LitElement) {
|
||||
(category) =>
|
||||
html`<ha-md-menu-item
|
||||
.value=${category.category_id}
|
||||
@click=${this._handleBulkCategory}
|
||||
.clickAction=${this._handleBulkCategory}
|
||||
>
|
||||
${category.icon
|
||||
? html`<ha-icon slot="start" .icon=${category.icon}></ha-icon>`
|
||||
@ -418,14 +418,14 @@ class HaScriptPicker extends SubscribeMixin(LitElement) {
|
||||
<div slot="headline">${category.name}</div>
|
||||
</ha-md-menu-item>`
|
||||
)}
|
||||
<ha-md-menu-item .value=${null} @click=${this._handleBulkCategory}>
|
||||
<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 @click=${this._bulkCreateCategory}>
|
||||
<ha-md-menu-item .clickAction=${this._bulkCreateCategory}>
|
||||
<div slot="headline">
|
||||
${this.hass.localize("ui.panel.config.category.editor.add")}
|
||||
</div>
|
||||
@ -462,7 +462,7 @@ class HaScriptPicker extends SubscribeMixin(LitElement) {
|
||||
</ha-md-menu-item>`;
|
||||
})}
|
||||
<ha-md-divider role="separator" tabindex="-1"></ha-md-divider>
|
||||
<ha-md-menu-item @click=${this._bulkCreateLabel}>
|
||||
<ha-md-menu-item .clickAction=${this._bulkCreateLabel}>
|
||||
<div slot="headline">
|
||||
${this.hass.localize("ui.panel.config.labels.add_label")}
|
||||
</div></ha-md-menu-item
|
||||
@ -472,7 +472,7 @@ class HaScriptPicker extends SubscribeMixin(LitElement) {
|
||||
(area) =>
|
||||
html`<ha-md-menu-item
|
||||
.value=${area.area_id}
|
||||
@click=${this._handleBulkArea}
|
||||
.clickAction=${this._handleBulkArea}
|
||||
>
|
||||
${area.icon
|
||||
? html`<ha-icon slot="start" .icon=${area.icon}></ha-icon>`
|
||||
@ -483,7 +483,7 @@ class HaScriptPicker extends SubscribeMixin(LitElement) {
|
||||
<div slot="headline">${area.name}</div>
|
||||
</ha-md-menu-item>`
|
||||
)}
|
||||
<ha-md-menu-item .value=${null} @click=${this._handleBulkArea}>
|
||||
<ha-md-menu-item .value=${null} .clickAction=${this._handleBulkArea}>
|
||||
<div slot="headline">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.devices.picker.bulk_actions.no_area"
|
||||
@ -491,7 +491,7 @@ class HaScriptPicker extends SubscribeMixin(LitElement) {
|
||||
</div>
|
||||
</ha-md-menu-item>
|
||||
<ha-md-divider role="separator" tabindex="-1"></ha-md-divider>
|
||||
<ha-md-menu-item @click=${this._bulkCreateArea}>
|
||||
<ha-md-menu-item .clickAction=${this._bulkCreateArea}>
|
||||
<div slot="headline">
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.devices.picker.bulk_actions.add_area"
|
||||
@ -977,10 +977,10 @@ class HaScriptPicker extends SubscribeMixin(LitElement) {
|
||||
this._selected = ev.detail.value;
|
||||
}
|
||||
|
||||
private async _handleBulkCategory(ev) {
|
||||
const category = ev.currentTarget.value;
|
||||
private _handleBulkCategory = (item) => {
|
||||
const category = item.value;
|
||||
this._bulkAddCategory(category);
|
||||
}
|
||||
};
|
||||
|
||||
private async _bulkAddCategory(category: string) {
|
||||
const promises: Promise<UpdateEntityRegistryEntryResult>[] = [];
|
||||
@ -1185,7 +1185,7 @@ ${rejected
|
||||
}
|
||||
}
|
||||
|
||||
private async _bulkCreateCategory() {
|
||||
private _bulkCreateCategory = () => {
|
||||
showCategoryRegistryDetailDialog(this, {
|
||||
scope: "script",
|
||||
createEntry: async (values) => {
|
||||
@ -1198,9 +1198,9 @@ ${rejected
|
||||
return category;
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
private _bulkCreateLabel() {
|
||||
private _bulkCreateLabel = () => {
|
||||
showLabelDetailDialog(this, {
|
||||
createEntry: async (values) => {
|
||||
const label = await createLabelRegistryEntry(this.hass, values);
|
||||
@ -1208,12 +1208,12 @@ ${rejected
|
||||
return label;
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
private async _handleBulkArea(ev) {
|
||||
const area = ev.currentTarget.value;
|
||||
private _handleBulkArea = (item) => {
|
||||
const area = item.value;
|
||||
this._bulkAddArea(area);
|
||||
}
|
||||
};
|
||||
|
||||
private async _bulkAddArea(area: string) {
|
||||
const promises: Promise<UpdateEntityRegistryEntryResult>[] = [];
|
||||
@ -1240,7 +1240,7 @@ ${rejected
|
||||
}
|
||||
}
|
||||
|
||||
private async _bulkCreateArea() {
|
||||
private _bulkCreateArea = () => {
|
||||
showAreaRegistryDetailDialog(this, {
|
||||
createEntry: async (values) => {
|
||||
const area = await createAreaRegistryEntry(this.hass, values);
|
||||
@ -1248,7 +1248,7 @@ ${rejected
|
||||
return area;
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
private _handleSortingChanged(ev: CustomEvent) {
|
||||
this._activeSorting = ev.detail;
|
||||
|
Loading…
x
Reference in New Issue
Block a user