Fix alarm card editor (#4592)

This commit is contained in:
Bram Kragten 2020-01-24 15:11:57 +01:00 committed by GitHub
parent db9924bd87
commit 971538e9c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -155,13 +155,14 @@ export class HuiAlarmPanelCardEditor extends LitElement
const target = ev.target! as EditorTarget; const target = ev.target! as EditorTarget;
const index = Number(target.value); const index = Number(target.value);
if (index > -1) { if (index > -1) {
const newStates = this._states; const newStates = [...this._states];
newStates.splice(index, 1); newStates.splice(index, 1);
this._config = { fireEvent(this, "config-changed", {
config: {
...this._config, ...this._config,
states: newStates, states: newStates,
}; },
fireEvent(this, "config-changed", { config: this._config }); });
} }
} }
@ -170,17 +171,18 @@ export class HuiAlarmPanelCardEditor extends LitElement
return; return;
} }
const target = ev.target! as EditorTarget; const target = ev.target! as EditorTarget;
if (!target.value || this._states.indexOf(target.value) >= 0) { if (!target.value || this._states.indexOf(target.value) !== -1) {
return; return;
} }
const newStates = this._states; const newStates = [...this._states];
newStates.push(target.value); newStates.push(target.value);
this._config = { target.value = "";
fireEvent(this, "config-changed", {
config: {
...this._config, ...this._config,
states: newStates, states: newStates,
}; },
target.value = ""; });
fireEvent(this, "config-changed", { config: this._config });
} }
private _valueChanged(ev: EntitiesEditorEvent): void { private _valueChanged(ev: EntitiesEditorEvent): void {