forked from MapComplete/MapComplete
		
	Change type of query-parameter-documention to Map instead of an object
This commit is contained in:
		
							parent
							
								
									53e760437c
								
							
						
					
					
						commit
						8b59f1208e
					
				
					 3 changed files with 13 additions and 10 deletions
				
			
		| 
						 | 
					@ -8,7 +8,7 @@ import {Utils} from "../../Utils";
 | 
				
			||||||
export class QueryParameters {
 | 
					export class QueryParameters {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    static defaults = {}
 | 
					    static defaults = {}
 | 
				
			||||||
    static documentation = {}
 | 
					    static documentation: Map<string, string> = new Map<string, string>()
 | 
				
			||||||
    private static order: string [] = ["layout", "test", "z", "lat", "lon"];
 | 
					    private static order: string [] = ["layout", "test", "z", "lat", "lon"];
 | 
				
			||||||
    private static _wasInitialized: Set<string> = new Set()
 | 
					    private static _wasInitialized: Set<string> = new Set()
 | 
				
			||||||
    private static knownSources = {};
 | 
					    private static knownSources = {};
 | 
				
			||||||
| 
						 | 
					@ -18,7 +18,7 @@ export class QueryParameters {
 | 
				
			||||||
        if (!this.initialized) {
 | 
					        if (!this.initialized) {
 | 
				
			||||||
            this.init();
 | 
					            this.init();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        QueryParameters.documentation[key] = documentation;
 | 
					        QueryParameters.documentation.set(key, documentation);
 | 
				
			||||||
        if (deflt !== undefined) {
 | 
					        if (deflt !== undefined) {
 | 
				
			||||||
            QueryParameters.defaults[key] = deflt;
 | 
					            QueryParameters.defaults[key] = deflt;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -41,7 +41,7 @@ export interface DeleteConfigJson {
 | 
				
			||||||
         * The tags that will be given to the object.
 | 
					         * The tags that will be given to the object.
 | 
				
			||||||
         * This must remove tags so that the 'source/osmTags' won't match anymore
 | 
					         * This must remove tags so that the 'source/osmTags' won't match anymore
 | 
				
			||||||
         */
 | 
					         */
 | 
				
			||||||
        if: AndOrTagConfigJson,
 | 
					        if: string | AndOrTagConfigJson,
 | 
				
			||||||
        /**
 | 
					        /**
 | 
				
			||||||
         * The human explanation for the options
 | 
					         * The human explanation for the options
 | 
				
			||||||
         */
 | 
					         */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,6 +6,7 @@ import Translations from "./i18n/Translations";
 | 
				
			||||||
import {QueryParameters} from "../Logic/Web/QueryParameters";
 | 
					import {QueryParameters} from "../Logic/Web/QueryParameters";
 | 
				
			||||||
import FeatureSwitchState from "../Logic/State/FeatureSwitchState";
 | 
					import FeatureSwitchState from "../Logic/State/FeatureSwitchState";
 | 
				
			||||||
import LayoutConfig from "../Models/ThemeConfig/LayoutConfig";
 | 
					import LayoutConfig from "../Models/ThemeConfig/LayoutConfig";
 | 
				
			||||||
 | 
					import {DefaultGuiState} from "./DefaultGuiState";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default class QueryParameterDocumentation {
 | 
					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."
 | 
					        "Finally, the URL-hash is the part after the `#`. It is `node/1234` in this case."
 | 
				
			||||||
    ])
 | 
					    ])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static UrlParamDocs(): object{
 | 
					    public static UrlParamDocs(): Map<string, string> {
 | 
				
			||||||
        const dummyLayout = new LayoutConfig({
 | 
					        const dummyLayout = new LayoutConfig({
 | 
				
			||||||
            id: ">theme<",
 | 
					            id: ">theme<",
 | 
				
			||||||
            maintainer: "pietervdvn",
 | 
					            maintainer: "pietervdvn",
 | 
				
			||||||
            version: "0",
 | 
					            version: "0",
 | 
				
			||||||
            title: {en:"<theme>"},
 | 
					            title: {en: "<theme>"},
 | 
				
			||||||
            description: "A theme to generate docs with",
 | 
					            description: "A theme to generate docs with",
 | 
				
			||||||
            socialImage: "./assets/SocialImage.png",
 | 
					            socialImage: "./assets/SocialImage.png",
 | 
				
			||||||
            startLat: 0,
 | 
					            startLat: 0,
 | 
				
			||||||
| 
						 | 
					@ -50,7 +51,7 @@ export default class QueryParameterDocumentation {
 | 
				
			||||||
            ]
 | 
					            ]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        })
 | 
					        })
 | 
				
			||||||
 | 
					        new DefaultGuiState(); // Init a featureSwitchState to init all the parameters
 | 
				
			||||||
        new FeatureSwitchState(dummyLayout)
 | 
					        new FeatureSwitchState(dummyLayout)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        QueryParameters.GetQueryParameter("layer-<layer-id>", "true", "Wether or not the layer with id <layer-id> is shown")
 | 
					        QueryParameters.GetQueryParameter("layer-<layer-id>", "true", "Wether or not the layer with id <layer-id> is shown")
 | 
				
			||||||
| 
						 | 
					@ -58,16 +59,18 @@ export default class QueryParameterDocumentation {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static GenerateQueryParameterDocs(): BaseUIElement {
 | 
					    public static GenerateQueryParameterDocs(): BaseUIElement {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const docs: (string | BaseUIElement)[] = [...QueryParameterDocumentation.QueryParamDocsIntro];
 | 
					        const docs: (string | BaseUIElement)[] = [...QueryParameterDocumentation.QueryParamDocsIntro];
 | 
				
			||||||
        for (const key in QueryParameters.documentation) {
 | 
					        this.UrlParamDocs().forEach((value, key) => {
 | 
				
			||||||
            const c = new Combine([
 | 
					            const c = new Combine([
 | 
				
			||||||
                new Title(key, 2),
 | 
					                new Title(key, 2),
 | 
				
			||||||
                QueryParameters.documentation[key],
 | 
					                value,
 | 
				
			||||||
                QueryParameters.defaults[key] === undefined ? "No default value set" : `The default value is _${QueryParameters.defaults[key]}_`
 | 
					                QueryParameters.defaults[key] === undefined ? "No default value set" : `The default value is _${QueryParameters.defaults[key]}_`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            ])
 | 
					            ])
 | 
				
			||||||
            docs.push(c)
 | 
					            docs.push(c)
 | 
				
			||||||
        }
 | 
					        })
 | 
				
			||||||
        return new Combine(docs).SetClass("flex flex-col")
 | 
					        return new Combine(docs).SetClass("flex flex-col")
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue