mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-14 12:56:37 +00:00
suggestions
This commit is contained in:
parent
84322a21fe
commit
3436a023f6
@ -24,16 +24,9 @@ import "@polymer/paper-listbox/paper-listbox";
|
||||
import type { UnsubscribeFunc } from "home-assistant-js-websocket";
|
||||
import type { CSSResult, CSSResultGroup, PropertyValues } from "lit";
|
||||
import { LitElement, css, html, nothing } from "lit";
|
||||
import {
|
||||
customElement,
|
||||
eventOptions,
|
||||
property,
|
||||
query,
|
||||
state,
|
||||
} from "lit/decorators";
|
||||
import { customElement, eventOptions, property, state } from "lit/decorators";
|
||||
import { classMap } from "lit/directives/class-map";
|
||||
import memoizeOne from "memoize-one";
|
||||
import type { PaperListboxElement } from "@polymer/paper-listbox";
|
||||
import { storage } from "../common/decorators/storage";
|
||||
import { fireEvent } from "../common/dom/fire_event";
|
||||
import { toggleAttribute } from "../common/dom/toggle_attribute";
|
||||
@ -55,6 +48,7 @@ import "./ha-menu-button";
|
||||
import "./ha-sortable";
|
||||
import "./ha-svg-icon";
|
||||
import "./user/ha-user-badge";
|
||||
import { preventDefault } from "../common/dom/prevent_default";
|
||||
|
||||
const SHOW_AFTER_SPACER = ["config", "developer-tools"];
|
||||
|
||||
@ -203,8 +197,6 @@ class HaSidebar extends SubscribeMixin(LitElement) {
|
||||
|
||||
@state() private _issuesCount = 0;
|
||||
|
||||
@query("paper-listbox", true) private _sidebar!: PaperListboxElement;
|
||||
|
||||
private _mouseLeaveTimeout?: number;
|
||||
|
||||
private _tooltipHideTimeout?: number;
|
||||
@ -296,10 +288,6 @@ class HaSidebar extends SubscribeMixin(LitElement) {
|
||||
protected firstUpdated(changedProps: PropertyValues) {
|
||||
super.firstUpdated(changedProps);
|
||||
this._subscribePersistentNotifications();
|
||||
|
||||
window.addEventListener("hass-reset-sidebar", (ev) => {
|
||||
this._sidebar.selected = ev.detail;
|
||||
});
|
||||
}
|
||||
|
||||
private _subscribePersistentNotifications(): void {
|
||||
@ -417,6 +405,7 @@ class HaSidebar extends SubscribeMixin(LitElement) {
|
||||
@focusout=${this._listboxFocusOut}
|
||||
@scroll=${this._listboxScroll}
|
||||
@keydown=${this._listboxKeydown}
|
||||
@iron-activate=${preventDefault}
|
||||
>
|
||||
${this.editMode
|
||||
? this._renderPanelsEdit(beforeSpacer)
|
||||
@ -1137,8 +1126,4 @@ declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
"ha-sidebar": HaSidebar;
|
||||
}
|
||||
|
||||
interface HASSDomEvents {
|
||||
"hass-reset-sidebar": string;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
import type { LitElement, PropertyValues } from "lit";
|
||||
import type { Constructor } from "../types";
|
||||
import { isNavigationClick } from "../common/dom/is-navigation-click";
|
||||
import { fireEvent } from "../common/dom/fire_event";
|
||||
import type { Constructor } from "../types";
|
||||
|
||||
export const PreventUnsavedMixin = <T extends Constructor<LitElement>>(
|
||||
superClass: T
|
||||
@ -21,8 +20,6 @@ export const PreventUnsavedMixin = <T extends Constructor<LitElement>>(
|
||||
const newEvent = new MouseEvent(e.type, e);
|
||||
target.dispatchEvent(newEvent);
|
||||
}
|
||||
} else {
|
||||
fireEvent(this, "hass-reset-sidebar", this.getPanel());
|
||||
}
|
||||
};
|
||||
|
||||
@ -36,7 +33,7 @@ export const PreventUnsavedMixin = <T extends Constructor<LitElement>>(
|
||||
public willUpdate(changedProperties: PropertyValues): void {
|
||||
super.willUpdate(changedProperties);
|
||||
|
||||
if (this.isDirty()) {
|
||||
if (this.isDirty) {
|
||||
window.addEventListener("click", this._handleClick, true);
|
||||
window.addEventListener("beforeunload", this._handleUnload);
|
||||
} else {
|
||||
@ -50,15 +47,11 @@ export const PreventUnsavedMixin = <T extends Constructor<LitElement>>(
|
||||
this._removeListeners();
|
||||
}
|
||||
|
||||
protected isDirty(): boolean {
|
||||
protected get isDirty(): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected async promptDiscardChanges(): Promise<boolean> {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected getPanel(): string {
|
||||
return "config";
|
||||
}
|
||||
};
|
||||
|
@ -850,7 +850,7 @@ export class HaAutomationEditor extends PreventUnsavedMixin(
|
||||
};
|
||||
}
|
||||
|
||||
protected isDirty() {
|
||||
protected get isDirty() {
|
||||
return this._dirty;
|
||||
}
|
||||
|
||||
|
@ -1226,7 +1226,7 @@ export class HaSceneEditor extends PreventUnsavedMixin(
|
||||
});
|
||||
}
|
||||
|
||||
protected isDirty() {
|
||||
protected get isDirty() {
|
||||
return this._dirty;
|
||||
}
|
||||
|
||||
|
@ -816,7 +816,7 @@ export class HaScriptEditor extends PreventUnsavedMixin(
|
||||
};
|
||||
}
|
||||
|
||||
protected isDirty() {
|
||||
protected get isDirty() {
|
||||
return this._dirty;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user