Add id = 0 handling (#2201)

* Add id = 0 handling

* Add check in view creation
This commit is contained in:
Zack Arnett 2018-12-06 13:16:06 -05:00 committed by Bram Kragten
parent 647a33ea61
commit f600b0522c
3 changed files with 4 additions and 3 deletions

View File

@ -28,7 +28,8 @@ export class HuiViewEditor extends hassLocalizeLitMixin(LitElement) {
if (!this._config) { if (!this._config) {
return ""; return "";
} }
return this._config.id || "";
return "id" in this._config ? this._config.id! : "";
} }
get _title(): string { get _title(): string {

View File

@ -42,7 +42,7 @@ export class HuiDialogEditView extends LitElement {
if ( if (
!this._params.add && !this._params.add &&
this._params.viewConfig && this._params.viewConfig &&
!this._params.viewConfig.id !("id" in this._params.viewConfig)
) { ) {
return html` return html`
<hui-migrate-config <hui-migrate-config

View File

@ -119,7 +119,7 @@ class HUIView extends localizeMixin(EventsMixin(PolymerElement)) {
_addCard() { _addCard() {
showEditCardDialog(this, { showEditCardDialog(this, {
viewId: this.config.id, viewId: "id" in this.config ? String(this.config.id) : undefined,
add: true, add: true,
reloadLovelace: () => { reloadLovelace: () => {
this.fire("config-refresh"); this.fire("config-refresh");