From 8b59f1208e0b678e22d4dfe05e68d04c309511df Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Tue, 14 Jun 2022 18:44:24 +0200 Subject: [PATCH] Change type of query-parameter-documention to Map instead of an object --- Logic/Web/QueryParameters.ts | 4 ++-- Models/ThemeConfig/Json/DeleteConfigJson.ts | 2 +- UI/QueryParameterDocumentation.ts | 17 ++++++++++------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Logic/Web/QueryParameters.ts b/Logic/Web/QueryParameters.ts index 02a76dce5..48417b325 100644 --- a/Logic/Web/QueryParameters.ts +++ b/Logic/Web/QueryParameters.ts @@ -8,7 +8,7 @@ import {Utils} from "../../Utils"; export class QueryParameters { static defaults = {} - static documentation = {} + static documentation: Map = new Map() private static order: string [] = ["layout", "test", "z", "lat", "lon"]; private static _wasInitialized: Set = new Set() private static knownSources = {}; @@ -18,7 +18,7 @@ export class QueryParameters { if (!this.initialized) { this.init(); } - QueryParameters.documentation[key] = documentation; + QueryParameters.documentation.set(key, documentation); if (deflt !== undefined) { QueryParameters.defaults[key] = deflt; } diff --git a/Models/ThemeConfig/Json/DeleteConfigJson.ts b/Models/ThemeConfig/Json/DeleteConfigJson.ts index 9b147bfb7..56b199f4e 100644 --- a/Models/ThemeConfig/Json/DeleteConfigJson.ts +++ b/Models/ThemeConfig/Json/DeleteConfigJson.ts @@ -41,7 +41,7 @@ export interface DeleteConfigJson { * The tags that will be given to the object. * This must remove tags so that the 'source/osmTags' won't match anymore */ - if: AndOrTagConfigJson, + if: string | AndOrTagConfigJson, /** * The human explanation for the options */ diff --git a/UI/QueryParameterDocumentation.ts b/UI/QueryParameterDocumentation.ts index 8158dab7d..405c20ad4 100644 --- a/UI/QueryParameterDocumentation.ts +++ b/UI/QueryParameterDocumentation.ts @@ -6,6 +6,7 @@ import Translations from "./i18n/Translations"; import {QueryParameters} from "../Logic/Web/QueryParameters"; import FeatureSwitchState from "../Logic/State/FeatureSwitchState"; import LayoutConfig from "../Models/ThemeConfig/LayoutConfig"; +import {DefaultGuiState} from "./DefaultGuiState"; export default class QueryParameterDocumentation { @@ -26,12 +27,12 @@ export default class QueryParameterDocumentation { "Finally, the URL-hash is the part after the `#`. It is `node/1234` in this case." ]) - public static UrlParamDocs(): object{ + public static UrlParamDocs(): Map { const dummyLayout = new LayoutConfig({ id: ">theme<", maintainer: "pietervdvn", version: "0", - title: {en:""}, + title: {en: ""}, description: "A theme to generate docs with", socialImage: "./assets/SocialImage.png", startLat: 0, @@ -50,24 +51,26 @@ export default class QueryParameterDocumentation { ] }) - + new DefaultGuiState(); // Init a featureSwitchState to init all the parameters new FeatureSwitchState(dummyLayout) QueryParameters.GetQueryParameter("layer-<layer-id>", "true", "Wether or not the layer with id is shown") return QueryParameters.documentation } - + public static GenerateQueryParameterDocs(): BaseUIElement { + + const docs: (string | BaseUIElement)[] = [...QueryParameterDocumentation.QueryParamDocsIntro]; - for (const key in QueryParameters.documentation) { + this.UrlParamDocs().forEach((value, key) => { const c = new Combine([ new Title(key, 2), - QueryParameters.documentation[key], + value, QueryParameters.defaults[key] === undefined ? "No default value set" : `The default value is _${QueryParameters.defaults[key]}_` ]) docs.push(c) - } + }) return new Combine(docs).SetClass("flex flex-col") } } \ No newline at end of file