Fix gauge editor (#6783)

This commit is contained in:
Bram Kragten 2020-09-04 15:18:01 +02:00 committed by GitHub
parent b7845c318e
commit faee2c3e1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,14 +4,16 @@ import {
CSSResult, CSSResult,
customElement, customElement,
html, html,
internalProperty,
LitElement, LitElement,
property, property,
internalProperty,
TemplateResult, TemplateResult,
} from "lit-element"; } from "lit-element";
import { assert, number, object, optional, string } from "superstruct";
import { fireEvent } from "../../../../common/dom/fire_event"; import { fireEvent } from "../../../../common/dom/fire_event";
import "../../../../components/ha-switch"; import { computeRTLDirection } from "../../../../common/util/compute_rtl";
import "../../../../components/ha-formfield"; import "../../../../components/ha-formfield";
import "../../../../components/ha-switch";
import { HomeAssistant } from "../../../../types"; import { HomeAssistant } from "../../../../types";
import { GaugeCardConfig, SeverityConfig } from "../../cards/types"; import { GaugeCardConfig, SeverityConfig } from "../../cards/types";
import "../../components/hui-entity-editor"; import "../../components/hui-entity-editor";
@ -19,8 +21,6 @@ import "../../components/hui-theme-select-editor";
import { LovelaceCardEditor } from "../../types"; import { LovelaceCardEditor } from "../../types";
import { EditorTarget, EntitiesEditorEvent } from "../types"; import { EditorTarget, EntitiesEditorEvent } from "../types";
import { configElementStyle } from "./config-elements-style"; import { configElementStyle } from "./config-elements-style";
import { computeRTLDirection } from "../../../../common/util/compute_rtl";
import { assert, object, string, optional, number } from "superstruct";
const cardConfigStruct = object({ const cardConfigStruct = object({
type: string(), type: string(),
@ -222,12 +222,16 @@ export class HuiGaugeCardEditor extends LitElement
} }
if ((ev.target as EditorTarget).checked) { if ((ev.target as EditorTarget).checked) {
this._config.severity = { this._config = {
green: 0, ...this._config,
yellow: 0, severity: {
red: 0, green: 0,
yellow: 0,
red: 0,
},
}; };
} else { } else {
this._config = { ...this._config };
delete this._config.severity; delete this._config.severity;
} }
fireEvent(this, "config-changed", { config: this._config }); fireEvent(this, "config-changed", { config: this._config });