Stuff more or less works

This commit is contained in:
pietervdvn 2021-01-25 04:21:22 +01:00
parent 149e117887
commit e2e48344d6
6 changed files with 38 additions and 38 deletions

View file

@ -28,9 +28,7 @@ export default class LazyElement<T extends UIElement> extends UIElement {
if (this._content === undefined) { if (this._content === undefined) {
return this._loadingContent; return this._loadingContent;
} }
return this._content.InnerRender(); return this._content.Render();
} }
} }

View file

@ -8,21 +8,13 @@ import Ornament from "./Ornament";
*/ */
export default class ScrollableFullScreen extends UIElement { export default class ScrollableFullScreen extends UIElement {
private static _isInited = false; private static _isInited = false;
private title: UIElement;
private content: UIElement;
private _component: UIElement; private _component: UIElement;
constructor(title: UIElement, content: UIElement, onClose: (() => void)) { constructor(title: UIElement, content: UIElement, onClose: (() => void)) {
super(); super();
this.content = content;
this.title = title;
if (!ScrollableFullScreen._isInited) { if (!ScrollableFullScreen._isInited) {
ScrollableFullScreen._isInited = ScrollableFullScreen.PreparePatchesForFullscreen(); ScrollableFullScreen._isInited = ScrollableFullScreen.PreparePatchesForFullscreen();
} }
if (onClose === undefined) {
console.error("ScrollableFullScreen initialized without onClose!")
}
this.dumbMode = false;
const returnToTheMap = const returnToTheMap =
new Combine([ new Combine([
Svg.back_svg().SetClass("block sm:hidden"), Svg.back_svg().SetClass("block sm:hidden"),
@ -54,6 +46,7 @@ export default class ScrollableFullScreen extends UIElement {
]).SetClass("block flex flex-col relative bg-white") ]).SetClass("block flex flex-col relative bg-white")
]).SetClass("fixed top-0 left-0 right-0 h-screen w-screen sm:max-h-65vh sm:w-auto sm:relative"); ]).SetClass("fixed top-0 left-0 right-0 h-screen w-screen sm:max-h-65vh sm:w-auto sm:relative");
this.dumbMode = false;
} }
private static HideClutter(htmlElement: HTMLElement) { private static HideClutter(htmlElement: HTMLElement) {
@ -113,7 +106,7 @@ export default class ScrollableFullScreen extends UIElement {
} }
private static RestoreLeaflet() { public static RestoreLeaflet() {
console.log("Restoring") console.log("Restoring")
const noTransf = document.getElementsByClassName("scrollable-fullscreen-no-transform"); const noTransf = document.getElementsByClassName("scrollable-fullscreen-no-transform");
for (let i = 0; i < noTransf.length; ++i) { for (let i = 0; i < noTransf.length; ++i) {
@ -134,12 +127,6 @@ export default class ScrollableFullScreen extends UIElement {
return this._component.Render(); return this._component.Render();
} }
Update() {
console.log("Updating the scrollableFullScreen")
super.Update();
this._component.Update();
}
public PrepFullscreen(htmlElement = undefined) { public PrepFullscreen(htmlElement = undefined) {
ScrollableFullScreen.PatchLeaflet(htmlElement); ScrollableFullScreen.PatchLeaflet(htmlElement);
@ -149,9 +136,15 @@ export default class ScrollableFullScreen extends UIElement {
} }
protected InnerUpdate(htmlElement: HTMLElement) { protected InnerUpdate(htmlElement: HTMLElement) {
console.log("Inner updating scrollale", this.id)
this.PrepFullscreen(htmlElement) this.PrepFullscreen(htmlElement)
super.InnerUpdate(htmlElement); super.InnerUpdate(htmlElement);
} }
Update() {
console.log("Updating scrollable", this.id)
super.Update();
}
} }

View file

@ -50,9 +50,9 @@ export default class UserBadge extends UIElement {
this._homeButton = new VariableUiElement( this._homeButton = new VariableUiElement(
this._userDetails.map((userinfo) => { this._userDetails.map((userinfo) => {
if (userinfo.home) { if (userinfo.home) {
return Svg.home_svg().Render(); return Svg.home_ui().Render();
} }
return ""; return " ";
}) })
).onClick(() => { ).onClick(() => {
const home = State.state.osmConnection.userDetails.data?.home; const home = State.state.osmConnection.userDetails.data?.home;

View file

@ -9,25 +9,29 @@ import State from "../../State";
import TagRenderingConfig from "../../Customizations/JSON/TagRenderingConfig"; import TagRenderingConfig from "../../Customizations/JSON/TagRenderingConfig";
import ScrollableFullScreen from "../Base/ScrollableFullScreen"; import ScrollableFullScreen from "../Base/ScrollableFullScreen";
export default class FeatureInfoBox extends ScrollableFullScreen { export default class FeatureInfoBox extends UIElement {
private _component: ScrollableFullScreen;
constructor( constructor(
tags: UIEventSource<any>, tags: UIEventSource<any>,
layerConfig: LayerConfig, layerConfig: LayerConfig,
onClose: () => void onClose: () => void
) { ) {
super( super();
FeatureInfoBox.GenerateTitleBar(tags, layerConfig),
FeatureInfoBox.GenerateContent(tags, layerConfig),
onClose
);
if (layerConfig === undefined) { if (layerConfig === undefined) {
throw "Undefined layerconfig" throw "Undefined layerconfig"
} }
const title = FeatureInfoBox.GenerateTitleBar(tags, layerConfig);
const contents = FeatureInfoBox.GenerateContent(tags, layerConfig);
this._component = new ScrollableFullScreen(title, contents, onClose)
} }
private static GenerateTitleBar( tags: UIEventSource<any>, InnerRender(): string {
layerConfig: LayerConfig): UIElement{ return this._component.Render();
}
private static GenerateTitleBar(tags: UIEventSource<any>,
layerConfig: LayerConfig): UIElement {
const title = new TagRenderingAnswer(tags, layerConfig.title ?? new TagRenderingConfig("POI", undefined)) const title = new TagRenderingAnswer(tags, layerConfig.title ?? new TagRenderingConfig("POI", undefined))
.SetClass("text-2xl break-words font-bold p-2"); .SetClass("text-2xl break-words font-bold p-2");
const titleIcons = new Combine( const titleIcons = new Combine(
@ -41,8 +45,7 @@ export default class FeatureInfoBox extends ScrollableFullScreen {
} }
private static GenerateContent(tags: UIEventSource<any>, private static GenerateContent(tags: UIEventSource<any>,
layerConfig: LayerConfig): UIElement{ layerConfig: LayerConfig): UIElement {
let questionBox: UIElement = undefined; let questionBox: UIElement = undefined;
@ -69,8 +72,10 @@ export default class FeatureInfoBox extends ScrollableFullScreen {
...renderings, ...renderings,
tail.SetClass("featureinfobox-tail") tail.SetClass("featureinfobox-tail")
] ]
) ).SetClass("block sm:max-h-65vh")
} }
} }

View file

@ -11,6 +11,9 @@ import Hash from "../Logic/Web/Hash";
import {GeoOperations} from "../Logic/GeoOperations"; import {GeoOperations} from "../Logic/GeoOperations";
import FeatureInfoBox from "./Popup/FeatureInfoBox"; import FeatureInfoBox from "./Popup/FeatureInfoBox";
import LayoutConfig from "../Customizations/JSON/LayoutConfig"; import LayoutConfig from "../Customizations/JSON/LayoutConfig";
import {UIElement} from "./UIElement";
import Combine from "./Base/Combine";
import ScrollableFullScreen from "./Base/ScrollableFullScreen";
export default class ShowDataLayer { export default class ShowDataLayer {
@ -126,15 +129,16 @@ export default class ShowDataLayer {
const tags = State.state.allElements.getEventSourceFor(feature); const tags = State.state.allElements.getEventSourceFor(feature);
const uiElement: LazyElement<FeatureInfoBox> = new LazyElement(() => new FeatureInfoBox(tags, layer, () => { const uiElement: LazyElement<UIElement> = new LazyElement(() =>new Combine([ new FeatureInfoBox(tags, layer, () => {
console.log("Closing the popup!") console.log("Closing the popup!")
State.state.selectedElement.setData(undefined); State.state.selectedElement.setData(undefined);
popup.remove(); popup.remove();
}), })]),
"<div style='height: 90vh'>Rendering</div>"); "<div style='height: 90vh'>Rendering</div>");
popup.setContent(uiElement.Render()); popup.setContent(uiElement.Render());
popup.on('remove', () => { popup.on('remove', () => {
ScrollableFullScreen.RestoreLeaflet(); // Just in case...
if (!popup.isOpen()) { if (!popup.isOpen()) {
return; return;
} }
@ -159,7 +163,7 @@ export default class ShowDataLayer {
return; return;
} }
leafletLayer.openPopup(); leafletLayer.openPopup();
uiElement.Activate(e => e.PrepFullscreen()); uiElement.Activate();
State.state.selectedElement.setData(feature); State.state.selectedElement.setData(feature);
} }
this._onSelectedTrigger[feature.properties.id.replace("/", "_")] = this._onSelectedTrigger[id]; this._onSelectedTrigger[feature.properties.id.replace("/", "_")] = this._onSelectedTrigger[id];
@ -167,7 +171,7 @@ export default class ShowDataLayer {
// This element is in the URL, so this is a share link // This element is in the URL, so this is a share link
// We open the relevant popup straight away // We open the relevant popup straight away
console.log("Opening the popup due to sharelink") console.log("Opening the popup due to sharelink")
uiElement.Activate(e => e.PrepFullscreen()); uiElement.Activate( );
popup.setContent(uiElement.Render()); popup.setContent(uiElement.Render());
const center = GeoOperations.centerpoint(feature).geometry.coordinates; const center = GeoOperations.centerpoint(feature).geometry.coordinates;

View file

@ -55,7 +55,7 @@
<div id="layer-selection" class="absolute bottom-3 left-3 rounded-3xl overflow-hidden clutter"></div> <div id="layer-selection" class="absolute bottom-3 left-3 rounded-3xl overflow-hidden clutter"></div>
<div id="centermessage" class="absolute rounded-3xl h-24 left-24 right-24 top-56 bg-white p-3 pt-5 sm:pt-8 text-xl font-bold text-center"> <div id="centermessage" class="clutter absolute rounded-3xl h-24 left-24 right-24 top-56 bg-white p-3 pt-5 sm:pt-8 text-xl font-bold text-center">
Loading MapComplete, hang on... Loading MapComplete, hang on...
</div> </div>