mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Make editing home location more clear (#14636)
This commit is contained in:
parent
9fdef3df6d
commit
2176d4dcea
@ -67,23 +67,28 @@ export class HaLocationsEditor extends LitElement {
|
|||||||
|
|
||||||
private Leaflet?: LeafletModuleType;
|
private Leaflet?: LeafletModuleType;
|
||||||
|
|
||||||
|
private _loadPromise: Promise<boolean | void>;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
import("leaflet").then((module) => {
|
this._loadPromise = import("leaflet").then((module) =>
|
||||||
import("leaflet-draw").then(() => {
|
import("leaflet-draw").then(() => {
|
||||||
this.Leaflet = module.default as LeafletModuleType;
|
this.Leaflet = module.default as LeafletModuleType;
|
||||||
this._updateMarkers();
|
this._updateMarkers();
|
||||||
this.updateComplete.then(() => this.fitMap());
|
return this.updateComplete.then(() => this.fitMap());
|
||||||
});
|
})
|
||||||
});
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public fitMap(): void {
|
public fitMap(): void {
|
||||||
this.map.fitMap();
|
this.map.fitMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
public fitMarker(id: string): void {
|
public async fitMarker(id: string): Promise<void> {
|
||||||
|
if (!this.Leaflet) {
|
||||||
|
await this._loadPromise;
|
||||||
|
}
|
||||||
if (!this.map.leafletMap || !this._locationMarkers) {
|
if (!this.map.leafletMap || !this._locationMarkers) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -391,7 +391,7 @@ class HaConfigSectionGeneral extends LitElement {
|
|||||||
);
|
);
|
||||||
|
|
||||||
private _editLocation() {
|
private _editLocation() {
|
||||||
navigate("/config/zone");
|
navigate("/config/zone/edit/zone.home");
|
||||||
}
|
}
|
||||||
|
|
||||||
static styles = [
|
static styles = [
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { mdiPencil, mdiPencilOff, mdiPlus } from "@mdi/js";
|
import { mdiCog, mdiPencil, mdiPencilOff, mdiPlus } from "@mdi/js";
|
||||||
import "@polymer/paper-item/paper-icon-item";
|
import "@polymer/paper-item/paper-icon-item";
|
||||||
import "@polymer/paper-item/paper-item-body";
|
import "@polymer/paper-item/paper-item-body";
|
||||||
import "@polymer/paper-listbox/paper-listbox";
|
import "@polymer/paper-listbox/paper-listbox";
|
||||||
@ -191,7 +191,7 @@ export class HaConfigZone extends SubscribeMixin(LitElement) {
|
|||||||
!this._canEditCore}
|
!this._canEditCore}
|
||||||
.path=${stateObject.entity_id === "zone.home" &&
|
.path=${stateObject.entity_id === "zone.home" &&
|
||||||
this._canEditCore
|
this._canEditCore
|
||||||
? mdiPencil
|
? mdiCog
|
||||||
: mdiPencilOff}
|
: mdiPencilOff}
|
||||||
.label=${stateObject.entity_id === "zone.home"
|
.label=${stateObject.entity_id === "zone.home"
|
||||||
? hass.localize("ui.panel.config.zone.edit_home")
|
? hass.localize("ui.panel.config.zone.edit_home")
|
||||||
@ -273,6 +273,19 @@ export class HaConfigZone extends SubscribeMixin(LitElement) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected updated() {
|
||||||
|
if (
|
||||||
|
!this.route.path.startsWith("/edit/") ||
|
||||||
|
!this._stateItems ||
|
||||||
|
!this._storageItems
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const id = this.route.path.slice(6);
|
||||||
|
navigate("/config/zone", { replace: true });
|
||||||
|
this._zoomZone(id);
|
||||||
|
}
|
||||||
|
|
||||||
public willUpdate(changedProps: PropertyValues) {
|
public willUpdate(changedProps: PropertyValues) {
|
||||||
super.updated(changedProps);
|
super.updated(changedProps);
|
||||||
const oldHass = changedProps.get("hass") as HomeAssistant | undefined;
|
const oldHass = changedProps.get("hass") as HomeAssistant | undefined;
|
||||||
@ -374,7 +387,7 @@ export class HaConfigZone extends SubscribeMixin(LitElement) {
|
|||||||
this._zoomZone(entityId);
|
this._zoomZone(entityId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _zoomZone(id: string) {
|
private async _zoomZone(id: string) {
|
||||||
this._map?.fitMarker(id);
|
this._map?.fitMarker(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user