panel toggle for view UI Editor (#2628)

This commit is contained in:
Ian Richardson 2019-01-30 18:10:10 -06:00 committed by Paulus Schoutsen
parent f1f1623d2f
commit 03f7a23540

View File

@ -5,6 +5,7 @@ import {
TemplateResult,
} from "lit-element";
import "@polymer/paper-input/paper-input";
import "@polymer/paper-toggle-button/paper-toggle-button";
import { EditorTarget } from "../types";
import { HomeAssistant } from "../../../../types";
@ -55,6 +56,13 @@ export class HuiViewEditor extends LitElement {
return this._config.theme || "Backend-selected";
}
get _panel(): boolean {
if (!this._config) {
return false;
}
return this._config.panel || false;
}
public hass?: HomeAssistant;
private _config?: LovelaceViewConfig;
@ -94,6 +102,12 @@ export class HuiViewEditor extends LitElement {
.configValue="${"theme"}"
@theme-changed="${this._valueChanged}"
></hui-theme-select-editor>
<paper-toggle-button
?checked="${this._panel !== false}"
.configValue="${"panel"}"
@change="${this._valueChanged}"
>Panel Mode?</paper-toggle-button
>
</div>
`;
}
@ -114,7 +128,8 @@ export class HuiViewEditor extends LitElement {
if (target.configValue) {
newConfig = {
...this._config,
[target.configValue]: target.value,
[target.configValue!]:
target.checked !== undefined ? target.checked : target.value,
};
}