-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Added migrate dialog when card has no ID #2008
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
fb6c5c9
fd6b6e3
c41875d
a7dfd2b
dd6edc3
cd953c3
1bedb04
c2f5b63
4ca7699
040df0a
6857b19
161a75f
58b585d
a6a973e
896b1bf
299a277
c4540eb
d96c289
a84788f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,17 +2,17 @@ import "@polymer/paper-button/paper-button"; | |
| import { html, LitElement, PropertyDeclarations } from "@polymer/lit-element"; | ||
| import { fireEvent } from "../../../common/dom/fire_event"; | ||
| import { HomeAssistant } from "../../../types"; | ||
| import { LovelaceConfig } from "../types"; | ||
|
|
||
| let registeredDialog = false; | ||
|
|
||
| export class HuiCardOptions extends LitElement { | ||
| public cardId?: string; | ||
| public cardConfig?: LovelaceConfig; | ||
| protected hass?: HomeAssistant; | ||
|
|
||
| static get properties(): PropertyDeclarations { | ||
| return { | ||
| hass: {}, | ||
| }; | ||
| return { hass: {} }; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure why this was changed. I dont think this is "prettier"
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is, small objects will be put on a single line. |
||
| } | ||
|
|
||
| public connectedCallback() { | ||
|
|
@@ -51,7 +51,7 @@ export class HuiCardOptions extends LitElement { | |
| private _editCard() { | ||
| fireEvent(this, "show-edit-card", { | ||
| hass: this.hass, | ||
| cardId: this.cardId, | ||
| cardConfig: this.cardConfig, | ||
| reloadLovelace: () => fireEvent(this, "config-refresh"), | ||
| }); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| import "@polymer/paper-input/paper-textarea"; | ||
|
|
||
| import createCardElement from "../common/create-card-element"; | ||
| import createErrorCardConfig from "../common/create-error-card-config"; | ||
| import { HomeAssistant } from "../../../types"; | ||
| import { LovelaceCard, LovelaceConfig } from "../types"; | ||
| import { ConfigError } from "./types"; | ||
|
|
||
| export class HuiCardPreview extends HTMLElement { | ||
| private _hass?: HomeAssistant; | ||
|
|
||
| set hass(value: HomeAssistant) { | ||
| this._hass = value; | ||
| if (this.lastChild) { | ||
| (this.lastChild as LovelaceCard).hass = value; | ||
| } | ||
| } | ||
|
|
||
| set error(error: ConfigError) { | ||
| const configValue = createErrorCardConfig( | ||
| `${error.type}: ${error.message}`, | ||
| undefined | ||
| ); | ||
|
|
||
| this._createCard(configValue); | ||
| } | ||
|
|
||
| set value(configValue: LovelaceConfig) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can make this |
||
| this._createCard(configValue); | ||
| } | ||
|
|
||
| private _createCard(configValue: LovelaceConfig): void { | ||
| if (this.lastChild) { | ||
| this.removeChild(this.lastChild); | ||
| } | ||
|
|
||
| if (!configValue) { | ||
| return; | ||
| } | ||
|
|
||
| const element = createCardElement(configValue); | ||
|
|
||
| if (this._hass) { | ||
| element.hass = this._hass; | ||
| } | ||
|
|
||
| this.appendChild(element); | ||
| } | ||
| } | ||
|
|
||
| declare global { | ||
| interface HTMLElementTagNameMap { | ||
| "hui-card-preview": HuiCardPreview; | ||
| } | ||
| } | ||
|
|
||
| customElements.define("hui-card-preview", HuiCardPreview); | ||
Uh oh!
There was an error while loading. Please reload this page.