This commit is contained in:
Zack Arnett 2020-11-12 22:39:34 -06:00
parent 9b279632f8
commit 2fef57f0b2
2 changed files with 18 additions and 7 deletions

View File

@ -38,7 +38,6 @@ export class HuiGridCardOptions extends LitElement {
protected render(): TemplateResult { protected render(): TemplateResult {
return html` return html`
<slot></slot> <slot></slot>
<div class="parent-card-actions"> <div class="parent-card-actions">
<div class="overlay"></div> <div class="overlay"></div>
<div class="card-actions"> <div class="card-actions">
@ -73,18 +72,17 @@ export class HuiGridCardOptions extends LitElement {
aria-label=${this.hass!.localize( aria-label=${this.hass!.localize(
"ui.panel.lovelace.editor.edit_card.options" "ui.panel.lovelace.editor.edit_card.options"
)} )}
title=${this.hass!.localize( .title=${this.hass!.localize(
"ui.panel.lovelace.editor.edit_card.options" "ui.panel.lovelace.editor.edit_card.options"
)} )}
> >
<ha-svg-icon path=${mdiDotsVertical}></ha-svg-icon> <ha-svg-icon .path=${mdiDotsVertical}></ha-svg-icon>
</mwc-icon-button> </mwc-icon-button>
<mwc-list-item> <mwc-list-item>
${this.hass!.localize( ${this.hass!.localize(
"ui.panel.lovelace.editor.edit_card.move" "ui.panel.lovelace.editor.edit_card.move"
)}</mwc-list-item )}
> </mwc-list-item>
</ha-button-menu> </ha-button-menu>
</div> </div>
</div> </div>

View File

@ -26,6 +26,7 @@ import type { HomeAssistant } from "../../../types";
import { computeCardSize } from "../common/compute-card-size"; import { computeCardSize } from "../common/compute-card-size";
import { HuiCardOptions } from "../components/hui-card-options"; import { HuiCardOptions } from "../components/hui-card-options";
import { showCreateCardDialog } from "../editor/card-editor/show-create-card-dialog"; import { showCreateCardDialog } from "../editor/card-editor/show-create-card-dialog";
import { replaceView } from "../editor/config-util";
import type { Lovelace, LovelaceBadge, LovelaceCard } from "../types"; import type { Lovelace, LovelaceBadge, LovelaceCard } from "../types";
import { HuiGridCardOptions } from "./grid/hui-grid-card-options"; import { HuiGridCardOptions } from "./grid/hui-grid-card-options";
@ -113,7 +114,7 @@ export class GridView extends LitElement implements LovelaceViewElement {
.columns=${this._columns} .columns=${this._columns}
.dragDisabled=${!this.lovelace?.editMode} .dragDisabled=${!this.lovelace?.editMode}
.resizeDisabled=${!this.lovelace?.editMode} .resizeDisabled=${!this.lovelace?.editMode}
@layout-changed=${(ev) => console.log(ev.detail)} @item-changed=${this._saveLayout}
></lit-grid-layout> ></lit-grid-layout>
${this.lovelace?.editMode ${this.lovelace?.editMode
? html` ? html`
@ -183,6 +184,18 @@ export class GridView extends LitElement implements LovelaceViewElement {
} }
} }
private async _saveLayout(ev: CustomEvent): Promise<void> {
console.log("save");
const viewConf: LovelaceViewConfig = {
...this._config,
layout: ev.detail.layout,
};
await this.lovelace?.saveConfig(
replaceView(this.lovelace!.config, this.index, viewConf)
);
}
private _itemRenderer = (key: string): TemplateResult => { private _itemRenderer = (key: string): TemplateResult => {
if (!this._cards) { if (!this._cards) {
return html``; return html``;