mirror of
https://github.com/home-assistant/frontend.git
synced 2026-04-17 23:54:28 +01:00
Hide behavior selector if no targets are populated (#30219)
This commit is contained in:
@@ -95,7 +95,12 @@ export class HaPlatformCondition extends LitElement {
|
||||
loadDefaults &&
|
||||
field.selector &&
|
||||
field.default !== undefined &&
|
||||
updatedOptions[key] === undefined
|
||||
updatedOptions[key] === undefined &&
|
||||
!(
|
||||
key === "behavior" &&
|
||||
this.description?.target &&
|
||||
!this.condition?.target
|
||||
)
|
||||
) {
|
||||
updatedDefaultValue = true;
|
||||
updatedOptions[key] = field.default;
|
||||
@@ -225,7 +230,13 @@ export class HaPlatformCondition extends LitElement {
|
||||
return nothing;
|
||||
}
|
||||
|
||||
if (fieldName === "behavior" && this._resolvedTargetEntityCount === 1) {
|
||||
if (
|
||||
fieldName === "behavior" &&
|
||||
this.description?.target &&
|
||||
(!this.condition?.target ||
|
||||
(this._resolvedTargetEntityCount !== undefined &&
|
||||
this._resolvedTargetEntityCount <= 1))
|
||||
) {
|
||||
return nothing;
|
||||
}
|
||||
|
||||
@@ -420,7 +431,9 @@ export class HaPlatformCondition extends LitElement {
|
||||
await this._resolveTargetEntityCount(target);
|
||||
|
||||
if (
|
||||
this._resolvedTargetEntityCount === 1 &&
|
||||
(!target ||
|
||||
(this._resolvedTargetEntityCount !== undefined &&
|
||||
this._resolvedTargetEntityCount <= 1)) &&
|
||||
this.condition.options?.behavior !== undefined
|
||||
) {
|
||||
const options = { ...this.condition.options };
|
||||
@@ -433,6 +446,7 @@ export class HaPlatformCondition extends LitElement {
|
||||
},
|
||||
});
|
||||
} else if (
|
||||
target &&
|
||||
this._resolvedTargetEntityCount !== undefined &&
|
||||
this._resolvedTargetEntityCount > 1 &&
|
||||
this.condition.options?.behavior === undefined
|
||||
|
||||
@@ -130,7 +130,12 @@ export class HaPlatformTrigger extends LitElement {
|
||||
loadDefaults &&
|
||||
field.selector &&
|
||||
field.default !== undefined &&
|
||||
updatedOptions[key] === undefined
|
||||
updatedOptions[key] === undefined &&
|
||||
!(
|
||||
key === "behavior" &&
|
||||
this.description?.target &&
|
||||
!this.trigger?.target
|
||||
)
|
||||
) {
|
||||
updatedDefaultValue = true;
|
||||
updatedOptions[key] = field.default;
|
||||
@@ -261,8 +266,13 @@ export class HaPlatformTrigger extends LitElement {
|
||||
return nothing;
|
||||
}
|
||||
|
||||
// Hide behavior when the target is a single direct entity.
|
||||
if (fieldName === "behavior" && this._resolvedTargetEntityCount === 1) {
|
||||
if (
|
||||
fieldName === "behavior" &&
|
||||
this.description?.target &&
|
||||
(!this.trigger?.target ||
|
||||
(this._resolvedTargetEntityCount !== undefined &&
|
||||
this._resolvedTargetEntityCount <= 1))
|
||||
) {
|
||||
return nothing;
|
||||
}
|
||||
|
||||
@@ -457,7 +467,9 @@ export class HaPlatformTrigger extends LitElement {
|
||||
await this._resolveTargetEntityCount(target);
|
||||
|
||||
if (
|
||||
this._resolvedTargetEntityCount === 1 &&
|
||||
(!target ||
|
||||
(this._resolvedTargetEntityCount !== undefined &&
|
||||
this._resolvedTargetEntityCount <= 1)) &&
|
||||
this.trigger.options?.behavior !== undefined
|
||||
) {
|
||||
const options = { ...this.trigger.options };
|
||||
@@ -470,6 +482,7 @@ export class HaPlatformTrigger extends LitElement {
|
||||
},
|
||||
});
|
||||
} else if (
|
||||
target &&
|
||||
this._resolvedTargetEntityCount !== undefined &&
|
||||
this._resolvedTargetEntityCount > 1 &&
|
||||
this.trigger.options?.behavior === undefined
|
||||
|
||||
Reference in New Issue
Block a user