Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export class HuiDialogEditCard extends LitElement {
<hui-dialog-pick-card
.hass="${this.hass}"
.cardPicked="${this._cardPicked}"
.closeDialog="${this._cancel}"
></hui-dialog-pick-card>
`;
}
Expand Down
13 changes: 12 additions & 1 deletion src/panels/lovelace/editor/card-editor/hui-dialog-pick-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,19 @@ import { LovelaceCardConfig } from "../../../../data/lovelace";
export class HuiDialogPickCard extends hassLocalizeLitMixin(LitElement) {
public hass?: HomeAssistant;
public cardPicked?: (cardConf: LovelaceCardConfig) => void;
public closeDialog?: () => void;

static get properties(): PropertyDeclarations {
return {};
}

protected render(): TemplateResult {
return html`
<paper-dialog with-backdrop opened>
<paper-dialog
with-backdrop
opened
@opened-changed="${this._openedChanged}"
>
<h2>${this.localize("ui.panel.lovelace.editor.edit_card.header")}</h2>
<paper-dialog-scrollable>
<hui-card-picker
Expand All @@ -33,6 +38,12 @@ export class HuiDialogPickCard extends hassLocalizeLitMixin(LitElement) {
`;
}

private _openedChanged(ev) {
if (!ev.detail.value) {
this.closeDialog!();
}
}

private _skipPick() {
this.cardPicked!({ type: "" });
}
Expand Down
12 changes: 11 additions & 1 deletion src/panels/lovelace/editor/card-editor/hui-edit-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,11 @@ export class HuiEditCard extends hassLocalizeLitMixin(LitElement) {

return html`
${this.renderStyle()}
<paper-dialog with-backdrop opened>
<paper-dialog
with-backdrop
opened
@opened-changed="${this._openedChanged}"
>
<h2>${this.localize("ui.panel.lovelace.editor.edit_card.header")}</h2>
<paper-spinner
?active="${this._loading}"
Expand Down Expand Up @@ -436,6 +440,12 @@ export class HuiEditCard extends hassLocalizeLitMixin(LitElement) {
private get _creatingCard(): boolean {
return this.path!.length === 1;
}

private _openedChanged(ev) {
if (!ev.detail.value) {
this.closeDialog!();
}
}
}

declare global {
Expand Down