Skip to content
Merged
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
44 changes: 25 additions & 19 deletions src/panels/lovelace/hui-editor.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
import { LitElement, html, TemplateResult, CSSResult, css } from "lit-element";
import {
customElement,
LitElement,
html,
TemplateResult,
CSSResult,
css,
property,
} from "lit-element";
import { classMap } from "lit-html/directives/class-map";
import { safeDump, safeLoad } from "js-yaml";

Expand Down Expand Up @@ -27,23 +35,15 @@ const lovelaceStruct = struct.interface({
resources: struct.optional(["object"]),
});

@customElement("hui-editor")
class LovelaceFullConfigEditor extends LitElement {
public hass!: HomeAssistant;
public lovelace?: Lovelace;
public closeEditor?: () => void;
private _saving?: boolean;
private _changed?: boolean;
private _generation = 1;
@property() public hass!: HomeAssistant;
@property() public lovelace?: Lovelace;
@property() public closeEditor?: () => void;
@property() private _saving?: boolean;
@property() private _changed?: boolean;

static get properties() {
return {
hass: {},
lovelace: {},
closeEditor: {},
_saving: {},
_changed: {},
};
}
private _generation = 1;

public render(): TemplateResult | void {
return html`
Expand Down Expand Up @@ -73,7 +73,10 @@ class LovelaceFullConfigEditor extends LitElement {
"ui.panel.lovelace.editor.raw_editor.saved"
)}
</div>
<mwc-button raised @click="${this._handleSave}"
<mwc-button
raised
@click="${this._handleSave}"
.disabled=${!this._changed}
>${this.hass!.localize(
"ui.panel.lovelace.editor.raw_editor.save"
)}</mwc-button
Expand Down Expand Up @@ -116,6 +119,11 @@ class LovelaceFullConfigEditor extends LitElement {
color: var(--dark-text-color);
}

mwc-button[disabled] {
background-color: var(--mdc-theme-on-primary);
border-radius: 4px;
}

.comments {
font-size: 16px;
}
Expand Down Expand Up @@ -242,5 +250,3 @@ declare global {
"hui-editor": LovelaceFullConfigEditor;
}
}

customElements.define("hui-editor", LovelaceFullConfigEditor);