Fix service advanced options UI (#21925)

This commit is contained in:
karwosts 2024-09-09 08:19:35 -07:00 committed by GitHub
parent bde2fd8202
commit c7cfbb5b6c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -240,12 +240,24 @@ export class HaServiceControl extends LitElement {
...value,
selector: value.selector as Selector | undefined,
}));
const hasSelector: string[] = [];
fields.forEach((field) => {
if ((field as any).fields) {
Object.entries((field as any).fields).forEach(([key, subField]) => {
if ((subField as any).selector) {
hasSelector.push(key);
}
});
} else if (field.selector) {
hasSelector.push(field.key);
}
});
return {
...serviceDomains[domain][serviceName],
fields,
hasSelector: fields.length
? fields.filter((field) => field.selector).map((field) => field.key)
: [],
hasSelector,
};
}
);