mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-21 08:16:36 +00:00
Avoid script editor dirty on load (#13619)
This commit is contained in:
parent
66db8c999f
commit
e6862daa38
@ -536,6 +536,12 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _modeChanged(mode) {
|
private _modeChanged(mode) {
|
||||||
|
const curMode = this._config!.mode || MODES[0];
|
||||||
|
|
||||||
|
if (mode === curMode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this._config = { ...this._config!, mode };
|
this._config = { ...this._config!, mode };
|
||||||
if (!isMaxMode(mode)) {
|
if (!isMaxMode(mode)) {
|
||||||
delete this._config.max;
|
delete this._config.max;
|
||||||
@ -575,6 +581,7 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) {
|
|||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
const values = ev.detail.value as any;
|
const values = ev.detail.value as any;
|
||||||
const currentId = this._entityId;
|
const currentId = this._entityId;
|
||||||
|
let changed = false;
|
||||||
|
|
||||||
for (const key of Object.keys(values)) {
|
for (const key of Object.keys(values)) {
|
||||||
if (key === "sequence") {
|
if (key === "sequence") {
|
||||||
@ -590,6 +597,8 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
changed = true;
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case "id":
|
case "id":
|
||||||
this._idChanged(value);
|
this._idChanged(value);
|
||||||
@ -603,14 +612,17 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (values[key] === undefined) {
|
if (values[key] === undefined) {
|
||||||
delete this._config![key];
|
const newConfig = { ...this._config! };
|
||||||
this._config = { ...this._config! };
|
delete newConfig![key];
|
||||||
|
this._config = newConfig;
|
||||||
} else {
|
} else {
|
||||||
this._config = { ...this._config!, [key]: value };
|
this._config = { ...this._config!, [key]: value };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this._dirty = true;
|
if (changed) {
|
||||||
|
this._dirty = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _configChanged(ev) {
|
private _configChanged(ev) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user