mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-09 02:49:51 +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) {
|
private _handleExpand(ev) {
|
||||||
const target = ev.currentTarget as any;
|
const target = ev.currentTarget as any;
|
||||||
|
const id = target.id.replace(/^expand-/, "");
|
||||||
const newAreas: string[] = [];
|
const newAreas: string[] = [];
|
||||||
const newDevices: string[] = [];
|
const newDevices: string[] = [];
|
||||||
const newEntities: string[] = [];
|
const newEntities: string[] = [];
|
||||||
@@ -529,7 +530,7 @@ export class HaTargetPicker extends SubscribeMixin(LitElement) {
|
|||||||
if (target.type === "floor_id") {
|
if (target.type === "floor_id") {
|
||||||
Object.values(this.hass.areas).forEach((area) => {
|
Object.values(this.hass.areas).forEach((area) => {
|
||||||
if (
|
if (
|
||||||
area.floor_id === target.id &&
|
area.floor_id === id &&
|
||||||
!this.value!.area_id?.includes(area.area_id) &&
|
!this.value!.area_id?.includes(area.area_id) &&
|
||||||
this._areaMeetsFilter(area)
|
this._areaMeetsFilter(area)
|
||||||
) {
|
) {
|
||||||
@@ -539,7 +540,7 @@ export class HaTargetPicker extends SubscribeMixin(LitElement) {
|
|||||||
} else if (target.type === "area_id") {
|
} else if (target.type === "area_id") {
|
||||||
Object.values(this.hass.devices).forEach((device) => {
|
Object.values(this.hass.devices).forEach((device) => {
|
||||||
if (
|
if (
|
||||||
device.area_id === target.id &&
|
device.area_id === id &&
|
||||||
!this.value!.device_id?.includes(device.id) &&
|
!this.value!.device_id?.includes(device.id) &&
|
||||||
this._deviceMeetsFilter(device)
|
this._deviceMeetsFilter(device)
|
||||||
) {
|
) {
|
||||||
@@ -548,7 +549,7 @@ export class HaTargetPicker extends SubscribeMixin(LitElement) {
|
|||||||
});
|
});
|
||||||
Object.values(this.hass.entities).forEach((entity) => {
|
Object.values(this.hass.entities).forEach((entity) => {
|
||||||
if (
|
if (
|
||||||
entity.area_id === target.id &&
|
entity.area_id === id &&
|
||||||
!this.value!.entity_id?.includes(entity.entity_id) &&
|
!this.value!.entity_id?.includes(entity.entity_id) &&
|
||||||
this._entityRegMeetsFilter(entity)
|
this._entityRegMeetsFilter(entity)
|
||||||
) {
|
) {
|
||||||
@@ -558,7 +559,7 @@ export class HaTargetPicker extends SubscribeMixin(LitElement) {
|
|||||||
} else if (target.type === "device_id") {
|
} else if (target.type === "device_id") {
|
||||||
Object.values(this.hass.entities).forEach((entity) => {
|
Object.values(this.hass.entities).forEach((entity) => {
|
||||||
if (
|
if (
|
||||||
entity.device_id === target.id &&
|
entity.device_id === id &&
|
||||||
!this.value!.entity_id?.includes(entity.entity_id) &&
|
!this.value!.entity_id?.includes(entity.entity_id) &&
|
||||||
this._entityRegMeetsFilter(entity)
|
this._entityRegMeetsFilter(entity)
|
||||||
) {
|
) {
|
||||||
@@ -568,7 +569,7 @@ export class HaTargetPicker extends SubscribeMixin(LitElement) {
|
|||||||
} else if (target.type === "label_id") {
|
} else if (target.type === "label_id") {
|
||||||
Object.values(this.hass.areas).forEach((area) => {
|
Object.values(this.hass.areas).forEach((area) => {
|
||||||
if (
|
if (
|
||||||
area.labels.includes(target.id) &&
|
area.labels.includes(id) &&
|
||||||
!this.value!.area_id?.includes(area.area_id) &&
|
!this.value!.area_id?.includes(area.area_id) &&
|
||||||
this._areaMeetsFilter(area)
|
this._areaMeetsFilter(area)
|
||||||
) {
|
) {
|
||||||
@@ -577,7 +578,7 @@ export class HaTargetPicker extends SubscribeMixin(LitElement) {
|
|||||||
});
|
});
|
||||||
Object.values(this.hass.devices).forEach((device) => {
|
Object.values(this.hass.devices).forEach((device) => {
|
||||||
if (
|
if (
|
||||||
device.labels.includes(target.id) &&
|
device.labels.includes(id) &&
|
||||||
!this.value!.device_id?.includes(device.id) &&
|
!this.value!.device_id?.includes(device.id) &&
|
||||||
this._deviceMeetsFilter(device)
|
this._deviceMeetsFilter(device)
|
||||||
) {
|
) {
|
||||||
@@ -586,7 +587,7 @@ export class HaTargetPicker extends SubscribeMixin(LitElement) {
|
|||||||
});
|
});
|
||||||
Object.values(this.hass.entities).forEach((entity) => {
|
Object.values(this.hass.entities).forEach((entity) => {
|
||||||
if (
|
if (
|
||||||
entity.labels.includes(target.id) &&
|
entity.labels.includes(id) &&
|
||||||
!this.value!.entity_id?.includes(entity.entity_id) &&
|
!this.value!.entity_id?.includes(entity.entity_id) &&
|
||||||
this._entityRegMeetsFilter(entity, true)
|
this._entityRegMeetsFilter(entity, true)
|
||||||
) {
|
) {
|
||||||
@@ -606,14 +607,15 @@ export class HaTargetPicker extends SubscribeMixin(LitElement) {
|
|||||||
if (newAreas.length) {
|
if (newAreas.length) {
|
||||||
value = this._addItems(value, "area_id", newAreas);
|
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 });
|
fireEvent(this, "value-changed", { value });
|
||||||
}
|
}
|
||||||
|
|
||||||
private _handleRemove(ev) {
|
private _handleRemove(ev) {
|
||||||
const target = ev.currentTarget as any;
|
const target = ev.currentTarget as any;
|
||||||
|
const id = target.id.replace(/^remove-/, "");
|
||||||
fireEvent(this, "value-changed", {
|
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