From bad224865892f95168f30f38b121d39b37a35a80 Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Mon, 15 Mar 2021 16:23:04 +0100 Subject: [PATCH] Let roaming tagrenderings appear together with the questions --- Customizations/JSON/LayerConfig.ts | 20 ++++++++++++++------ Customizations/JSON/TagRenderingConfig.ts | 4 ++++ Models/Constants.ts | 2 +- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/Customizations/JSON/LayerConfig.ts b/Customizations/JSON/LayerConfig.ts index ba3752758..df5a9040c 100644 --- a/Customizations/JSON/LayerConfig.ts +++ b/Customizations/JSON/LayerConfig.ts @@ -48,16 +48,16 @@ export default class LayerConfig { }[]; tagRenderings: TagRenderingConfig []; - - private readonly configuration_warnings : string[] = [] + + private readonly configuration_warnings: string[] = [] constructor(json: LayerConfigJson, context?: string) { context = context + "." + json.id; const self = this; this.id = json.id; - this.name = Translations.T(json.name, context+".name"); - this.description = Translations.T(json.description, context+".description"); + this.name = Translations.T(json.name, context + ".name"); + this.description = Translations.T(json.description, context + ".description"); this.overpassTags = FromJSON.Tag(json.overpassTags, context + ".overpasstags"); this.doNotDownload = json.doNotDownload ?? false, this.passAllFeatures = json.passAllFeatures ?? false; @@ -176,10 +176,18 @@ export default class LayerConfig { iconOverlays: { "if": TagsFilter, then: TagRenderingConfig, badge: boolean }[] }): LayerConfig { - this.tagRenderings.push(...addAll.tagRenderings); + + let insertionPoint = this.tagRenderings.map(tr => tr.IsQuestionBoxElement()).indexOf(true) + if (insertionPoint < 0) { + // No 'questions' defined - we just add them all to the end + insertionPoint = this.tagRenderings.length; + } + this.tagRenderings.splice(insertionPoint, 0, ...addAll.tagRenderings); + + this.iconOverlays.push(...addAll.iconOverlays); for (const icon of addAll.titleIcons) { - this.titleIcons.splice(0,0, icon); + this.titleIcons.splice(0, 0, icon); } return this; } diff --git a/Customizations/JSON/TagRenderingConfig.ts b/Customizations/JSON/TagRenderingConfig.ts index 7ffdf03b8..745576992 100644 --- a/Customizations/JSON/TagRenderingConfig.ts +++ b/Customizations/JSON/TagRenderingConfig.ts @@ -218,6 +218,10 @@ export default class TagRenderingConfig { return false; } + public IsQuestionBoxElement(): boolean{ + return this.question === null && this.condition === null; + } + /** * Gets the correct rendering value (or undefined if not known) * @constructor diff --git a/Models/Constants.ts b/Models/Constants.ts index 0ad7e9b9e..89a633a87 100644 --- a/Models/Constants.ts +++ b/Models/Constants.ts @@ -2,7 +2,7 @@ import { Utils } from "../Utils"; export default class Constants { - public static vNumber = "0.5.11"; + public static vNumber = "0.5.12"; // The user journey states thresholds when a new feature gets unlocked public static userJourney = {