Fix dark switch for map card editor (#3856)

This commit is contained in:
Bram Kragten 2019-10-02 21:26:48 +02:00 committed by GitHub
parent 391b2dcf6a
commit 3622514131
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -161,30 +161,21 @@ export class HuiMapCardEditor extends LitElement implements LovelaceCardEditor {
return; return;
} }
const target = ev.target! as EditorTarget; const target = ev.target! as EditorTarget;
if ( if (target.configValue && this[`_${target.configValue}`] === target.value) {
target.configValue &&
ev.detail &&
this[`_${target.configValue}`] === ev.detail.value
) {
return; return;
} }
if (target.configValue && ev.detail) { let value: any = target.value;
if ( if (target.type === "number") {
ev.detail.value === "" || value = Number(value);
(target.type === "number" && isNaN(Number(ev.detail.value))) }
) { if (target.value === "" || (target.type === "number" && isNaN(value))) {
delete this._config[target.configValue!]; delete this._config[target.configValue!];
} else { } else if (target.configValue) {
let value: any = ev.detail.value; this._config = {
if (target.type === "number") { ...this._config,
value = Number(value); [target.configValue]:
} target.checked !== undefined ? target.checked : value,
this._config = { };
...this._config,
[target.configValue]:
target.checked !== undefined ? target.checked : value,
};
}
} }
fireEvent(this, "config-changed", { config: this._config }); fireEvent(this, "config-changed", { config: this._config });
} }