Prevent leaving the editor if there are unsaved changes

This commit is contained in:
Jan-Philipp Benecke
2024-12-05 19:49:27 +01:00
committed by Bram Kragten
parent 0582b8430d
commit 91777d45b0
4 changed files with 90 additions and 4 deletions

View File

@@ -57,8 +57,11 @@ import "./blueprint-script-editor";
import "./manual-script-editor";
import type { HaManualScriptEditor } from "./manual-script-editor";
import { substituteBlueprint } from "../../../data/blueprint";
import { PreventUnsavedMixin } from "../../../mixins/prevent-unsaved-mixin";
export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) {
export class HaScriptEditor extends PreventUnsavedMixin(
KeyboardShortcutMixin(LitElement)
) {
@property({ attribute: false }) public hass!: HomeAssistant;
@property({ attribute: false }) public scriptId: string | null = null;
@@ -813,6 +816,14 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) {
};
}
protected isDirty() {
return this._dirty;
}
protected async promptDiscardChanges() {
return this.confirmUnsavedChanged();
}
static get styles(): CSSResultGroup {
return [
haStyle,