From 2dcc5b21f59cc509a809c293d5de33ec5da2e703 Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Mon, 22 Mar 2021 01:05:01 +0100 Subject: [PATCH] Add debugging-featureswitch which toggles an overview of all tags --- InitUiElements.ts | 6 +++--- State.ts | 7 +++++-- UI/Popup/FeatureInfoBox.ts | 8 +++++++- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/InitUiElements.ts b/InitUiElements.ts index 2b0da0149..a88208098 100644 --- a/InitUiElements.ts +++ b/InitUiElements.ts @@ -390,8 +390,8 @@ export class InitUiElements { if (featuresFreshness === undefined) { return; } - let features = featuresFreshness.map(ff => ff.feature); - features.forEach(feature => { + featuresFreshness.forEach(featureFresh => { + const feature = featureFresh.feature; State.state.allElements.addOrGetElement(feature); if (Hash.hash.data === feature.properties.id) { @@ -399,7 +399,7 @@ export class InitUiElements { } }) - MetaTagging.addMetatags(features); + MetaTagging.addMetatags(featuresFreshness); }) new ShowDataLayer(source.features, State.state.leafletMap, diff --git a/State.ts b/State.ts index 5710ed66c..91912f0a2 100644 --- a/State.ts +++ b/State.ts @@ -1,4 +1,3 @@ -import {UIElement} from "./UI/UIElement"; import {Utils} from "./Utils"; import {ElementStorage} from "./Logic/ElementStorage"; import {Changes} from "./Logic/Osm/Changes"; @@ -8,7 +7,6 @@ import {UIEventSource} from "./Logic/UIEventSource"; import {LocalStorageSource} from "./Logic/Web/LocalStorageSource"; import {QueryParameters} from "./Logic/Web/QueryParameters"; import LayoutConfig from "./Customizations/JSON/LayoutConfig"; -import Hash from "./Logic/Web/Hash"; import {MangroveIdentity} from "./Logic/Web/MangroveReviews"; import InstalledThemes from "./Logic/Actors/InstalledThemes"; import BaseLayer from "./Models/BaseLayer"; @@ -89,6 +87,7 @@ export default class State { public readonly featureSwitchShareScreen: UIEventSource; public readonly featureSwitchGeolocation: UIEventSource; public readonly featureSwitchIsTesting: UIEventSource; + public readonly featureSwitchIsDebugging: UIEventSource; /** @@ -194,6 +193,10 @@ export default class State { this.featureSwitchIsTesting = QueryParameters.GetQueryParameter("test", "false", "If true, 'dryrun' mode is activated. The app will behave as normal, except that changes to OSM will be printed onto the console instead of actually uploaded to osm.org") .map(str => str === "true", [], b => "" + b); + + this.featureSwitchIsDebugging = QueryParameters.GetQueryParameter("debug","false", + "If true, shows some extra debugging help such as all the available tags on every object") + .map(str => str === "true", [], b => "" + b) } diff --git a/UI/Popup/FeatureInfoBox.ts b/UI/Popup/FeatureInfoBox.ts index 5488aeaee..56a8700d5 100644 --- a/UI/Popup/FeatureInfoBox.ts +++ b/UI/Popup/FeatureInfoBox.ts @@ -9,6 +9,7 @@ import State from "../../State"; import TagRenderingConfig from "../../Customizations/JSON/TagRenderingConfig"; import ScrollableFullScreen from "../Base/ScrollableFullScreen"; import {Utils} from "../../Utils"; +import {Tag} from "../../Logic/Tags"; export default class FeatureInfoBox extends ScrollableFullScreen { @@ -54,7 +55,7 @@ export default class FeatureInfoBox extends ScrollableFullScreen { } let questionBoxIsUsed = false; - const renderings = layerConfig.tagRenderings.map((tr,i) => { + const renderings = layerConfig.tagRenderings.map(tr => { if (tr.question === null) { // This is the question box! questionBoxIsUsed = true; @@ -65,6 +66,11 @@ export default class FeatureInfoBox extends ScrollableFullScreen { if (!questionBoxIsUsed) { renderings.push(questionBox); } + + if(State.state.featureSwitchIsDebugging.data){ + const config: TagRenderingConfig = new TagRenderingConfig({render:"{all_tags()}"}, new Tag("id",""), ""); + renderings.push(new TagRenderingAnswer(tags,config )) + } return new Combine(renderings).SetClass("block")