mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-28 11:46:42 +00:00
Improve context support
This commit is contained in:
parent
81870d0e7d
commit
be71c0b4fa
@ -627,7 +627,7 @@ export class HaServiceControl extends LitElement {
|
|||||||
const fieldDataHasTemplate =
|
const fieldDataHasTemplate =
|
||||||
this._value?.data && hasTemplate(this._value.data[dataField.key]);
|
this._value?.data && hasTemplate(this._value.data[dataField.key]);
|
||||||
|
|
||||||
let selector =
|
const selector =
|
||||||
fieldDataHasTemplate &&
|
fieldDataHasTemplate &&
|
||||||
typeof this._value!.data![dataField.key] === "string"
|
typeof this._value!.data![dataField.key] === "string"
|
||||||
? { template: null }
|
? { template: null }
|
||||||
@ -637,16 +637,6 @@ export class HaServiceControl extends LitElement {
|
|||||||
: (this._stickySelector[dataField.key] ??
|
: (this._stickySelector[dataField.key] ??
|
||||||
dataField?.selector ?? { text: null });
|
dataField?.selector ?? { text: null });
|
||||||
|
|
||||||
if ("state" in selector) {
|
|
||||||
selector = {
|
|
||||||
...selector,
|
|
||||||
state: {
|
|
||||||
...selector.state,
|
|
||||||
entity_id: targetEntities || undefined,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fieldDataHasTemplate) {
|
if (fieldDataHasTemplate) {
|
||||||
// Hold this selector type until the field is cleared
|
// Hold this selector type until the field is cleared
|
||||||
this._stickySelector[dataField.key] = selector;
|
this._stickySelector[dataField.key] = selector;
|
||||||
@ -685,6 +675,7 @@ export class HaServiceControl extends LitElement {
|
|||||||
) || dataField?.description}</span
|
) || dataField?.description}</span
|
||||||
>
|
>
|
||||||
<ha-selector
|
<ha-selector
|
||||||
|
.context=${this._selectorContext(targetEntities)}
|
||||||
.disabled=${this.disabled ||
|
.disabled=${this.disabled ||
|
||||||
(showOptional &&
|
(showOptional &&
|
||||||
!this._checkedKeys.has(dataField.key) &&
|
!this._checkedKeys.has(dataField.key) &&
|
||||||
@ -704,6 +695,10 @@ export class HaServiceControl extends LitElement {
|
|||||||
: "";
|
: "";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private _selectorContext = memoizeOne((targetEntities: string[] | null) => ({
|
||||||
|
filter_entity: targetEntities || undefined,
|
||||||
|
}));
|
||||||
|
|
||||||
private _localizeValueCallback = (key: string) => {
|
private _localizeValueCallback = (key: string) => {
|
||||||
if (!this._value?.action) {
|
if (!this._value?.action) {
|
||||||
return "";
|
return "";
|
||||||
|
@ -98,7 +98,7 @@ export interface AreasDisplaySelector {
|
|||||||
|
|
||||||
export interface AttributeSelector {
|
export interface AttributeSelector {
|
||||||
attribute: {
|
attribute: {
|
||||||
entity_id?: string;
|
entity_id?: string | string[];
|
||||||
hide_attributes?: readonly string[];
|
hide_attributes?: readonly string[];
|
||||||
} | null;
|
} | null;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user