Small refactoring, add 'last edit by'-rendering

This commit is contained in:
Pieter Vander Vennet 2021-04-21 01:26:36 +02:00
parent c6b4ba43fb
commit 95f1bdd797
10 changed files with 76 additions and 29 deletions

View file

@ -47,9 +47,12 @@ export default class LayerSelection extends UIElement {
.SetClass("single-layer-selection-toggle")
.SetStyle("opacity:0.2;");
const name = Translations.WT(layer.layerDef.name).Clone()
.SetStyle("font-size:large;margin-left: 0.5em;");
const name = Translations.WT(layer.layerDef.name)?.Clone()
?.SetStyle("font-size:large;margin-left: 0.5em;");
if(name === undefined){
continue
}
const zoomStatus = new VariableUiElement(State.state.locationControl.map(location => {
if (location.zoom < layer.layerDef.minzoom) {

View file

@ -9,6 +9,8 @@ import State from "../../State";
import TagRenderingConfig from "../../Customizations/JSON/TagRenderingConfig";
import ScrollableFullScreen from "../Base/ScrollableFullScreen";
import {Tag} from "../../Logic/Tags/Tag";
import Constants from "../../Models/Constants";
import SharedTagRenderings from "../../Customizations/SharedTagRenderings";
export default class FeatureInfoBox extends ScrollableFullScreen {
@ -49,7 +51,7 @@ export default class FeatureInfoBox extends ScrollableFullScreen {
private static GenerateContent(tags: UIEventSource<any>,
layerConfig: LayerConfig): UIElement {
let questionBox: UIElement = undefined;
if (State.state.featureSwitchUserbadge.data) {
questionBox = new QuestionBox(tags, layerConfig.tagRenderings);
}
@ -67,6 +69,12 @@ export default class FeatureInfoBox extends ScrollableFullScreen {
renderings.push(questionBox);
}
if (State.state.osmConnection.userDetails.data.csCount >= Constants.userJourney.historyLinkVisible ||
State.state.featureSwitchIsDebugging.data == true ||
State.state.featureSwitchIsTesting.data == true) {
renderings.push(new TagRenderingAnswer( tags, SharedTagRenderings.SharedTagRendering.get("last_edit")))
}
if (State.state.featureSwitchIsDebugging.data) {
const config: TagRenderingConfig = new TagRenderingConfig({render: "{all_tags()}"}, new Tag("id", ""), "");
renderings.push(new TagRenderingAnswer(tags, config))

View file

@ -73,10 +73,18 @@ export class Translation extends UIElement {
let rtext: string = "";
if (typeof (el) === "string") {
rtext = el;
} else if(typeof(el) === "number") {
// HUH? Where did that number come from?
} else if (typeof (el) === "number") {
// HUH? Where did that number come from? It might be a version number or something calculated
rtext = "" + el;
}else {
} else if (el["toISOString"] != undefined) {
// This is a date, probably the timestamp of the object
// @ts-ignore
const date: Date = el;
rtext = date.toLocaleString();
} else if (el.InnerRender === undefined) {
console.error("InnerREnder is not defined", el);
throw "Hmmm, el.InnerRender is not defined?"
} else {
Translation.forcedLanguage = lang; // This is a very dirty hack - it'll bite me one day
rtext = el.InnerRender();