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 =
|
||||
this._value?.data && hasTemplate(this._value.data[dataField.key]);
|
||||
|
||||
let selector =
|
||||
const selector =
|
||||
fieldDataHasTemplate &&
|
||||
typeof this._value!.data![dataField.key] === "string"
|
||||
? { template: null }
|
||||
@ -637,16 +637,6 @@ export class HaServiceControl extends LitElement {
|
||||
: (this._stickySelector[dataField.key] ??
|
||||
dataField?.selector ?? { text: null });
|
||||
|
||||
if ("state" in selector) {
|
||||
selector = {
|
||||
...selector,
|
||||
state: {
|
||||
...selector.state,
|
||||
entity_id: targetEntities || undefined,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
if (fieldDataHasTemplate) {
|
||||
// Hold this selector type until the field is cleared
|
||||
this._stickySelector[dataField.key] = selector;
|
||||
@ -685,6 +675,7 @@ export class HaServiceControl extends LitElement {
|
||||
) || dataField?.description}</span
|
||||
>
|
||||
<ha-selector
|
||||
.context=${this._selectorContext(targetEntities)}
|
||||
.disabled=${this.disabled ||
|
||||
(showOptional &&
|
||||
!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) => {
|
||||
if (!this._value?.action) {
|
||||
return "";
|
||||
|
@ -98,7 +98,7 @@ export interface AreasDisplaySelector {
|
||||
|
||||
export interface AttributeSelector {
|
||||
attribute: {
|
||||
entity_id?: string;
|
||||
entity_id?: string | string[];
|
||||
hide_attributes?: readonly string[];
|
||||
} | null;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user