Combine dropped the empty elements, causing them not to be able to update

This commit is contained in:
pietervdvn 2021-02-20 02:25:29 +01:00
parent 5a358a2abc
commit 09599e9f15
3 changed files with 24 additions and 29 deletions

View file

@ -2,7 +2,7 @@ import { Utils } from "../Utils";
export default class Constants { export default class Constants {
public static vNumber = "0.5.0-rc2"; public static vNumber = "0.5.0-rc3";
// The user journey states thresholds when a new feature gets unlocked // The user journey states thresholds when a new feature gets unlocked
public static userJourney = { public static userJourney = {

View file

@ -25,11 +25,7 @@ export default class Combine extends UIElement {
console.error("Not a UI-element", ui); console.error("Not a UI-element", ui);
return ""; return "";
} }
let rendered = ui.Render(); return ui.Render();
if(ui.IsEmpty()){
return "";
}
return rendered;
}).join(""); }).join("");
} }

View file

@ -10,6 +10,7 @@ import TagRenderingConfig from "../../Customizations/JSON/TagRenderingConfig";
import ScrollableFullScreen from "../Base/ScrollableFullScreen"; import ScrollableFullScreen from "../Base/ScrollableFullScreen";
export default class FeatureInfoBox extends UIElement { export default class FeatureInfoBox extends UIElement {
private static featureInfoboxCache: Map<LayerConfig, Map<UIEventSource<any>, FeatureInfoBox>> = new Map<LayerConfig, Map<UIEventSource<any>, FeatureInfoBox>>();
private _component: ScrollableFullScreen; private _component: ScrollableFullScreen;
private constructor( private constructor(
@ -21,13 +22,25 @@ export default class FeatureInfoBox extends UIElement {
if (layerConfig === undefined) { if (layerConfig === undefined) {
throw "Undefined layerconfig" throw "Undefined layerconfig"
} }
const title = FeatureInfoBox.GenerateTitleBar(tags, layerConfig);
const contents = FeatureInfoBox.GenerateContent(tags, layerConfig); const title = FeatureInfoBox.GenerateTitleBar(tags, layerConfig);
this._component = new ScrollableFullScreen(title, contents, onClose) const contents = FeatureInfoBox.GenerateContent(tags, layerConfig);
this._component = new ScrollableFullScreen(title, contents, onClose);
} }
InnerRender(): string { static construct(tags: UIEventSource<any>, layer: LayerConfig, onClose: () => void) {
return this._component.Render(); let innerMap = FeatureInfoBox.featureInfoboxCache.get(layer);
if (innerMap === undefined) {
innerMap = new Map<UIEventSource<any>, FeatureInfoBox>();
FeatureInfoBox.featureInfoboxCache.set(layer, innerMap);
}
let featureInfoBox = innerMap.get(tags);
if (featureInfoBox === undefined) {
featureInfoBox = new FeatureInfoBox(tags, layer, onClose);
innerMap.set(tags, featureInfoBox);
}
return featureInfoBox;
} }
private static GenerateTitleBar(tags: UIEventSource<any>, private static GenerateTitleBar(tags: UIEventSource<any>,
@ -56,8 +69,8 @@ export default class FeatureInfoBox extends UIElement {
let questionBoxIsUsed = false; let questionBoxIsUsed = false;
const renderings = layerConfig.tagRenderings.map(tr => { const renderings = layerConfig.tagRenderings.map(tr => {
if (tr.question === null) { if (tr.question === null) {
questionBoxIsUsed = true;
// This is the question box! // This is the question box!
questionBoxIsUsed = true;
return questionBox; return questionBox;
} }
return new EditableTagRendering(tags, tr); return new EditableTagRendering(tags, tr);
@ -75,21 +88,7 @@ export default class FeatureInfoBox extends UIElement {
} }
InnerRender(): string {
return this._component.Render();
private static featureInfoboxCache : Map<LayerConfig, Map<UIEventSource<any>, FeatureInfoBox>> = new Map<LayerConfig, Map<UIEventSource<any>, FeatureInfoBox>>();
static construct(tags: UIEventSource<any>, layer: LayerConfig, onClose: () => void) {
let innerMap = FeatureInfoBox.featureInfoboxCache.get(layer);
if(innerMap === undefined){
innerMap = new Map<UIEventSource<any>, FeatureInfoBox>();
FeatureInfoBox.featureInfoboxCache.set(layer, innerMap);
}
let featureInfoBox = innerMap.get(tags);
if(featureInfoBox === undefined){
featureInfoBox = new FeatureInfoBox(tags, layer, onClose);
innerMap.set(tags, featureInfoBox);
}
return featureInfoBox;
} }
} }