mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 15:26:36 +00:00
Set mandatory bool service data without a default value to false (#11094)
This commit is contained in:
parent
abeaa63005
commit
b0b953bfac
@ -130,6 +130,33 @@ export class HaServiceControl extends LitElement {
|
||||
this._value = this.value;
|
||||
}
|
||||
|
||||
if (oldValue?.service !== this.value?.service) {
|
||||
let updatedDefaultValue = false;
|
||||
if (this._value && serviceData) {
|
||||
// Set mandatory bools without a default value to false
|
||||
this._value.data ??= {};
|
||||
serviceData.fields.forEach((field) => {
|
||||
if (
|
||||
field.selector &&
|
||||
field.required &&
|
||||
field.default === undefined &&
|
||||
"boolean" in field.selector &&
|
||||
this._value!.data![field.key] === undefined
|
||||
) {
|
||||
updatedDefaultValue = true;
|
||||
this._value!.data![field.key] = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
if (updatedDefaultValue) {
|
||||
fireEvent(this, "value-changed", {
|
||||
value: {
|
||||
...this._value,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (this._value?.data) {
|
||||
const yamlEditor = this._yamlEditor;
|
||||
if (yamlEditor && yamlEditor.value !== this._value.data) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user