Save columns as string (#2214)

* save columns as string

* set type to number to convert to number before save
This commit is contained in:
Bram Kragten 2018-12-07 14:14:29 +01:00 committed by Paulus Schoutsen
parent 48220b67ed
commit baeda622de
2 changed files with 9 additions and 7 deletions

View File

@ -93,6 +93,7 @@ export class HuiGlanceCardEditor extends hassLocalizeLitMixin(LitElement)
></hui-theme-select-editor>
<paper-input
label="Columns"
type="number"
value="${this._columns}"
.configValue="${"columns"}"
@value-changed="${this._valueChanged}"
@ -127,22 +128,21 @@ export class HuiGlanceCardEditor extends hassLocalizeLitMixin(LitElement)
}
const target = ev.target! as EditorTarget;
if (
(target.configValue! === "title" && target.value === this._title) ||
(target.configValue! === "theme" && target.value === this._theme) ||
(target.configValue! === "columns" && target.value === this._columns)
) {
if (this[`_${target.configValue}`] === target.value) {
return;
}
if (ev.detail && ev.detail.entities) {
this._config.entities = ev.detail.entities;
this._configEntities = processEditorEntities(this._config.entities);
} else if (target.configValue) {
let value: any = target.value;
if (target.type === "number") {
value = Number(value);
}
this._config = {
...this._config,
[target.configValue!]:
target.checked !== undefined ? target.checked : target.value,
target.checked !== undefined ? target.checked : value,
};
}
fireEvent(this, "config-changed", { config: this._config });

View File

@ -1,5 +1,6 @@
import { LovelaceCardConfig, LovelaceViewConfig } from "../../../data/lovelace";
import { EntityConfig } from "../entity-rows/types";
import { InputType } from "zlib";
export interface YamlChangedEvent extends Event {
detail: {
@ -41,6 +42,7 @@ export interface EditorTarget extends EventTarget {
index?: number;
checked?: boolean;
configValue?: string;
type?: InputType;
}
export interface CardPickTarget extends EventTarget {