mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-09 19:09:48 +00:00
Fix ha-target-picker remove/expad buttons after tooltip migration (#27134)
This commit is contained in:
@@ -522,6 +522,7 @@ export class HaTargetPicker extends SubscribeMixin(LitElement) {
|
||||
|
||||
private _handleExpand(ev) {
|
||||
const target = ev.currentTarget as any;
|
||||
const id = target.id.replace(/^expand-/, "");
|
||||
const newAreas: string[] = [];
|
||||
const newDevices: string[] = [];
|
||||
const newEntities: string[] = [];
|
||||
@@ -529,7 +530,7 @@ export class HaTargetPicker extends SubscribeMixin(LitElement) {
|
||||
if (target.type === "floor_id") {
|
||||
Object.values(this.hass.areas).forEach((area) => {
|
||||
if (
|
||||
area.floor_id === target.id &&
|
||||
area.floor_id === id &&
|
||||
!this.value!.area_id?.includes(area.area_id) &&
|
||||
this._areaMeetsFilter(area)
|
||||
) {
|
||||
@@ -539,7 +540,7 @@ export class HaTargetPicker extends SubscribeMixin(LitElement) {
|
||||
} else if (target.type === "area_id") {
|
||||
Object.values(this.hass.devices).forEach((device) => {
|
||||
if (
|
||||
device.area_id === target.id &&
|
||||
device.area_id === id &&
|
||||
!this.value!.device_id?.includes(device.id) &&
|
||||
this._deviceMeetsFilter(device)
|
||||
) {
|
||||
@@ -548,7 +549,7 @@ export class HaTargetPicker extends SubscribeMixin(LitElement) {
|
||||
});
|
||||
Object.values(this.hass.entities).forEach((entity) => {
|
||||
if (
|
||||
entity.area_id === target.id &&
|
||||
entity.area_id === id &&
|
||||
!this.value!.entity_id?.includes(entity.entity_id) &&
|
||||
this._entityRegMeetsFilter(entity)
|
||||
) {
|
||||
@@ -558,7 +559,7 @@ export class HaTargetPicker extends SubscribeMixin(LitElement) {
|
||||
} else if (target.type === "device_id") {
|
||||
Object.values(this.hass.entities).forEach((entity) => {
|
||||
if (
|
||||
entity.device_id === target.id &&
|
||||
entity.device_id === id &&
|
||||
!this.value!.entity_id?.includes(entity.entity_id) &&
|
||||
this._entityRegMeetsFilter(entity)
|
||||
) {
|
||||
@@ -568,7 +569,7 @@ export class HaTargetPicker extends SubscribeMixin(LitElement) {
|
||||
} else if (target.type === "label_id") {
|
||||
Object.values(this.hass.areas).forEach((area) => {
|
||||
if (
|
||||
area.labels.includes(target.id) &&
|
||||
area.labels.includes(id) &&
|
||||
!this.value!.area_id?.includes(area.area_id) &&
|
||||
this._areaMeetsFilter(area)
|
||||
) {
|
||||
@@ -577,7 +578,7 @@ export class HaTargetPicker extends SubscribeMixin(LitElement) {
|
||||
});
|
||||
Object.values(this.hass.devices).forEach((device) => {
|
||||
if (
|
||||
device.labels.includes(target.id) &&
|
||||
device.labels.includes(id) &&
|
||||
!this.value!.device_id?.includes(device.id) &&
|
||||
this._deviceMeetsFilter(device)
|
||||
) {
|
||||
@@ -586,7 +587,7 @@ export class HaTargetPicker extends SubscribeMixin(LitElement) {
|
||||
});
|
||||
Object.values(this.hass.entities).forEach((entity) => {
|
||||
if (
|
||||
entity.labels.includes(target.id) &&
|
||||
entity.labels.includes(id) &&
|
||||
!this.value!.entity_id?.includes(entity.entity_id) &&
|
||||
this._entityRegMeetsFilter(entity, true)
|
||||
) {
|
||||
@@ -606,14 +607,15 @@ export class HaTargetPicker extends SubscribeMixin(LitElement) {
|
||||
if (newAreas.length) {
|
||||
value = this._addItems(value, "area_id", newAreas);
|
||||
}
|
||||
value = this._removeItem(value, target.type, target.id);
|
||||
value = this._removeItem(value, target.type, id);
|
||||
fireEvent(this, "value-changed", { value });
|
||||
}
|
||||
|
||||
private _handleRemove(ev) {
|
||||
const target = ev.currentTarget as any;
|
||||
const id = target.id.replace(/^remove-/, "");
|
||||
fireEvent(this, "value-changed", {
|
||||
value: this._removeItem(this.value, target.type, target.id),
|
||||
value: this._removeItem(this.value, target.type, id),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user