Allow card editors to use card picker again (#5067)

This commit is contained in:
Bram Kragten 2020-03-04 22:04:04 +01:00 committed by GitHub
parent 2b8b9f8311
commit 196540afc7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 1 deletions

View File

@ -12,7 +12,7 @@ import { safeDump, safeLoad } from "js-yaml";
import "@material/mwc-button";
import { HomeAssistant } from "../../../../types";
import { LovelaceCardConfig } from "../../../../data/lovelace";
import { LovelaceCardConfig, LovelaceConfig } from "../../../../data/lovelace";
import { LovelaceCardEditor } from "../../types";
import { computeRTL } from "../../../../common/util/compute_rtl";
@ -45,6 +45,7 @@ export interface UIConfigChangedEvent extends Event {
@customElement("hui-card-editor")
export class HuiCardEditor extends LitElement {
@property() public hass!: HomeAssistant;
@property() public lovelace?: LovelaceConfig;
@property() private _yaml?: string;
@property() private _config?: LovelaceCardConfig;
@ -239,6 +240,7 @@ export class HuiCardEditor extends LitElement {
// Perform final setup
this._configElement!.hass = this.hass;
this._configElement!.lovelace = this.lovelace;
this._configElement!.addEventListener("config-changed", (ev) =>
this._handleUIConfigChanged(ev as UIConfigChangedEvent)
);

View File

@ -109,6 +109,7 @@ export class HuiDialogEditCard extends LitElement {
<div class="element-editor">
<hui-card-editor
.hass=${this.hass}
.lovelace="${this._params.lovelaceConfig}"
.value="${this._cardConfig}"
@config-changed="${this._handleConfigChanged}"
></hui-card-editor>

View File

@ -14,6 +14,7 @@ import { HomeAssistant } from "../../../../types";
import { LovelaceCardEditor } from "../../types";
import { StackCardConfig } from "../../cards/types";
import { fireEvent } from "../../../../common/dom/fire_event";
import { LovelaceConfig } from "../../../../data/lovelace";
const cardConfigStruct = struct({
type: "string",
@ -25,6 +26,7 @@ const cardConfigStruct = struct({
export class HuiStackCardEditor extends LitElement
implements LovelaceCardEditor {
@property() public hass?: HomeAssistant;
@property() public lovelace?: LovelaceConfig;
@property() private _config?: StackCardConfig;
@property() private _selectedCard: number = 0;
@ -102,6 +104,7 @@ export class HuiStackCardEditor extends LitElement
: html`
<hui-card-picker
.hass=${this.hass}
.lovelace=${this.lovelace}
@config-changed="${this._handleCardPicked}"
></hui-card-picker>
`

View File

@ -54,5 +54,6 @@ export interface LovelaceHeaderFooter extends HTMLElement {
export interface LovelaceCardEditor extends HTMLElement {
hass?: HomeAssistant;
lovelace?: LovelaceConfig;
setConfig(config: LovelaceCardConfig): void;
}