Further refactoring fullscreenelement: removal of hash handling from showDataLayer

This commit is contained in:
Pieter Vander Vennet 2021-01-27 01:14:16 +01:00
parent e2e48344d6
commit 593ac5381a
7 changed files with 125 additions and 114 deletions

View file

@ -13,7 +13,6 @@ export default class LazyElement<T extends UIElement> extends UIElement {
this.dumbMode = false;
const self = this;
this.Activate = (onElement?: (element: T) => void) => {
console.log("ACTIVATED")
if (this._content === undefined) {
self._content = content();
}

View file

@ -21,7 +21,6 @@ export default class ScrollableFullScreen extends UIElement {
Svg.close_svg().SetClass("hidden sm:block")
])
.onClick(() => {
console.log("Clicked back!");
ScrollableFullScreen.RestoreLeaflet();
if (onClose !== undefined) {
onClose();
@ -107,7 +106,6 @@ export default class ScrollableFullScreen extends UIElement {
}
public static RestoreLeaflet() {
console.log("Restoring")
const noTransf = document.getElementsByClassName("scrollable-fullscreen-no-transform");
for (let i = 0; i < noTransf.length; ++i) {
noTransf[i].classList.remove("no-transform");
@ -136,13 +134,11 @@ export default class ScrollableFullScreen extends UIElement {
}
protected InnerUpdate(htmlElement: HTMLElement) {
console.log("Inner updating scrollale", this.id)
this.PrepFullscreen(htmlElement)
super.InnerUpdate(htmlElement);
}
Update() {
console.log("Updating scrollable", this.id)
super.Update();
}

View file

@ -72,18 +72,9 @@ export default class ShowDataLayer {
action();
}
});
Hash.hash.addCallbackAndRun(id => {
// This is a bit of an edge case: if the hash becomes an id to search, we have to show the corresponding popup
if (State.state.selectedElement !== undefined) {
return; // Something is already selected, we don't have to apply this fix
}
const action = self._onSelectedTrigger[id];
if (action) {
action();
}
})
update();
}
@ -167,19 +158,6 @@ export default class ShowDataLayer {
State.state.selectedElement.setData(feature);
}
this._onSelectedTrigger[feature.properties.id.replace("/", "_")] = this._onSelectedTrigger[id];
if (feature.properties.id.replace(/\//g, "_") === Hash.hash.data && State.state.selectedElement.data === undefined) {
// This element is in the URL, so this is a share link
// We open the relevant popup straight away
console.log("Opening the popup due to sharelink")
uiElement.Activate( );
popup.setContent(uiElement.Render());
const center = GeoOperations.centerpoint(feature).geometry.coordinates;
popup.setLatLng({lat: center[1], lng: center[0]});
popup.openOn(State.state.leafletMap.data);
State.state.selectedElement.setData(feature);
uiElement.Update();
}
}
private CreateGeojsonLayer(features: any[]): L.Layer {