diff --git a/src/panels/lovelace/components/hui-card-options.ts b/src/panels/lovelace/components/hui-card-options.ts
index a40acfda49..4cff932dc7 100644
--- a/src/panels/lovelace/components/hui-card-options.ts
+++ b/src/panels/lovelace/components/hui-card-options.ts
@@ -3,14 +3,15 @@ import "@polymer/paper-button/paper-button";
import "@polymer/paper-menu-button/paper-menu-button";
import "@polymer/paper-icon-button/paper-icon-button";
import "@polymer/paper-listbox/paper-listbox";
-import { showEditCardDialog } from "../editor/card-editor/show-edit-card-dialog";
+import { showEditCardDialog } from "../editor/card-editor/show-edit-card-dialog";
import { hassLocalizeLitMixin } from "../../../mixins/lit-localize-mixin";
import { confDeleteCard } from "../editor/delete-card";
import { HomeAssistant } from "../../../types";
import { LovelaceCardConfig } from "../../../data/lovelace";
import { Lovelace } from "../types";
-import { swapCard, moveCard } from "../editor/config-util";
+import { swapCard } from "../editor/config-util";
+import { showMoveCardViewDialog } from "../editor/card-editor/show-move-card-view-dialog";
export class HuiCardOptions extends hassLocalizeLitMixin(LitElement) {
public cardConfig?: LovelaceCardConfig;
@@ -25,24 +26,40 @@ export class HuiCardOptions extends hassLocalizeLitMixin(LitElement) {
protected render() {
return html`
-
-
${
- this.localize("ui.panel.lovelace.editor.edit_card.edit")
- }
-
-
-
+
+
+
${
+ this.localize("ui.panel.lovelace.editor.edit_card.edit")
+ }
+
+
-
-
- ${
- this.lovelace!.config.views.map((view, index) => {
- if (index === this.path![0]) {
- return;
- }
- return html`
- ${view.title || "Unnamed view"}
- `;
- })
- }
-
-
-
+
+
+
+
+ Move Card
+ ${
+ this.localize("ui.panel.lovelace.editor.edit_card.delete")
+ }
+
+
+
`;
}
@@ -127,12 +140,11 @@ export class HuiCardOptions extends hassLocalizeLitMixin(LitElement) {
);
}
- private _moveCard(ev: MouseEvent): void {
- const lovelace = this.lovelace!;
- const path = this.path!;
- lovelace.saveConfig(
- moveCard(lovelace.config, path, [(ev.currentTarget! as any).index])
- );
+ private _moveCard(): void {
+ showMoveCardViewDialog(this, {
+ path: this.path!,
+ lovelace: this.lovelace!,
+ });
}
private _deleteCard(): void {
diff --git a/src/panels/lovelace/editor/card-editor/hui-dialog-move-card-view.ts b/src/panels/lovelace/editor/card-editor/hui-dialog-move-card-view.ts
new file mode 100644
index 0000000000..7f88c436cf
--- /dev/null
+++ b/src/panels/lovelace/editor/card-editor/hui-dialog-move-card-view.ts
@@ -0,0 +1,106 @@
+import { html, LitElement, PropertyDeclarations } from "@polymer/lit-element";
+import { TemplateResult } from "lit-html";
+import "@polymer/paper-dialog/paper-dialog";
+import "@polymer/paper-item/paper-item";
+// tslint:disable-next-line:no-duplicate-imports
+import { PaperDialogElement } from "@polymer/paper-dialog/paper-dialog";
+
+import { hassLocalizeLitMixin } from "../../../../mixins/lit-localize-mixin";
+import { moveCard } from "../config-util";
+import { MoveCardViewDialogParams } from "./show-move-card-view-dialog";
+
+export class HuiDialogMoveCardView extends hassLocalizeLitMixin(LitElement) {
+ private _params?: MoveCardViewDialogParams;
+
+ static get properties(): PropertyDeclarations {
+ return {
+ _params: {},
+ };
+ }
+
+ public async showDialog(params: MoveCardViewDialogParams): Promise {
+ this._params = params;
+ await this.updateComplete;
+ }
+
+ protected render(): TemplateResult {
+ if (!this._params) {
+ return html``;
+ }
+ return html`
+
+
+ Choose view to move card
+ ${
+ this._params!.lovelace!.config.views.map((view, index) => {
+ return html`
+ ${view.title}
+ `;
+ })
+ }
+
+ `;
+ }
+
+ private get _dialog(): PaperDialogElement {
+ return this.shadowRoot!.querySelector("paper-dialog")!;
+ }
+
+ private _moveCard(e: Event): void {
+ const newView = (e.currentTarget! as any).index;
+ const path = this._params!.path!;
+ if (newView === path[0]) {
+ return;
+ }
+
+ const lovelace = this._params!.lovelace!;
+
+ lovelace.saveConfig(moveCard(lovelace.config, path, [newView!]));
+ this._dialog.close();
+ }
+
+ private _openedChanged(ev: MouseEvent) {
+ if (!(ev.detail as any).value) {
+ this._params = undefined;
+ }
+ }
+}
+
+declare global {
+ interface HTMLElementTagNameMap {
+ "hui-dialog-move-card-view": HuiDialogMoveCardView;
+ }
+}
+
+customElements.define("hui-dialog-move-card-view", HuiDialogMoveCardView);
diff --git a/src/panels/lovelace/editor/card-editor/hui-edit-card.ts b/src/panels/lovelace/editor/card-editor/hui-edit-card.ts
index c793a97376..bd63979d8f 100644
--- a/src/panels/lovelace/editor/card-editor/hui-edit-card.ts
+++ b/src/panels/lovelace/editor/card-editor/hui-edit-card.ts
@@ -160,6 +160,7 @@ export class HuiEditCard extends hassLocalizeLitMixin(LitElement) {
? html`