Small code cleanups, documentation
This commit is contained in:
parent
cb42a4fcc5
commit
085d762bff
4 changed files with 37 additions and 34 deletions
|
@ -8,6 +8,7 @@ import TagRenderingAnswer from "./TagRenderingAnswer";
|
|||
import State from "../../State";
|
||||
import TagRenderingConfig from "../../Customizations/JSON/TagRenderingConfig";
|
||||
import ScrollableFullScreen from "../Base/ScrollableFullScreen";
|
||||
import {Utils} from "../../Utils";
|
||||
|
||||
export default class FeatureInfoBox extends ScrollableFullScreen {
|
||||
private static featureInfoboxCache: Map<LayerConfig, Map<UIEventSource<any>, FeatureInfoBox>> = new Map<LayerConfig, Map<UIEventSource<any>, FeatureInfoBox>>();
|
||||
|
@ -24,18 +25,8 @@ export default class FeatureInfoBox extends ScrollableFullScreen {
|
|||
}
|
||||
|
||||
static construct(tags: UIEventSource<any>, layer: LayerConfig): FeatureInfoBox {
|
||||
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);
|
||||
innerMap.set(tags, featureInfoBox);
|
||||
}
|
||||
return featureInfoBox;
|
||||
let innerMap = Utils.getOrSetDefault(FeatureInfoBox.featureInfoboxCache, layer,() => new Map<UIEventSource<any>, FeatureInfoBox>())
|
||||
return Utils.getOrSetDefault(innerMap, tags, () => new FeatureInfoBox(tags, layer));
|
||||
}
|
||||
|
||||
private static GenerateTitleBar(tags: UIEventSource<any>,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/**
|
||||
* Shows the reviews and scoring base on mangrove.reviesw
|
||||
* Shows the reviews and scoring base on mangrove.reviews
|
||||
* The middle element is some other component shown in the middle, e.g. the review input element
|
||||
*/
|
||||
import {UIEventSource} from "../../Logic/UIEventSource";
|
||||
import {Review} from "../../Logic/Web/Review";
|
||||
|
|
11
Utils.ts
11
Utils.ts
|
@ -152,6 +152,7 @@ export class Utils {
|
|||
head.appendChild(link);
|
||||
console.log("Added custom layout ", location)
|
||||
}
|
||||
|
||||
static Merge(source: any, target: any) {
|
||||
target = JSON.parse(JSON.stringify(target));
|
||||
source = JSON.parse(JSON.stringify(source));
|
||||
|
@ -172,4 +173,14 @@ export class Utils {
|
|||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
static getOrSetDefault<K, V>(dict: Map<K, V>, k: K, v: () => V) {
|
||||
let found = dict.get(k);
|
||||
if (found !== undefined) {
|
||||
return found;
|
||||
}
|
||||
dict.set(k, v());
|
||||
return dict.get(k);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue