| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  | import BaseUIElement from "./BaseUIElement" | 
					
						
							|  |  |  | import Combine from "./Base/Combine" | 
					
						
							|  |  |  | import Title from "./Base/Title" | 
					
						
							|  |  |  | import List from "./Base/List" | 
					
						
							|  |  |  | import Translations from "./i18n/Translations" | 
					
						
							| 
									
										
										
										
											2023-06-14 20:39:36 +02:00
										 |  |  | import { QueryParameters } from "../Logic/Web/QueryParameters" | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  | import FeatureSwitchState from "../Logic/State/FeatureSwitchState" | 
					
						
							|  |  |  | import LayoutConfig from "../Models/ThemeConfig/LayoutConfig" | 
					
						
							| 
									
										
										
										
											2023-08-10 15:37:44 +02:00
										 |  |  | import ThemeViewStateHashActor from "../Logic/Web/ThemeViewStateHashActor" | 
					
						
							| 
									
										
										
										
											2024-07-12 03:17:15 +02:00
										 |  |  | import MarkdownUtils from "../Utils/MarkdownUtils" | 
					
						
							| 
									
										
										
										
											2021-11-30 22:50:48 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | export default class QueryParameterDocumentation { | 
					
						
							| 
									
										
										
										
											2024-07-12 03:17:15 +02:00
										 |  |  |     private static QueryParamDocsIntro: string[] = [ | 
					
						
							|  |  |  |         "# URL-parameters and URL-hash", | 
					
						
							| 
									
										
										
										
											2021-11-30 22:50:48 +01:00
										 |  |  |         "This document gives an overview of which URL-parameters can be used to influence MapComplete.", | 
					
						
							| 
									
										
										
										
											2024-07-12 03:17:15 +02:00
										 |  |  |         "## What is a URL parameter?", | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |         '"URL-parameters are extra parts of the URL used to set the state.', | 
					
						
							| 
									
										
										
										
											2023-08-23 18:33:30 +02:00
										 |  |  |         "For example, if the url is `https://mapcomplete.org/cyclofix?lat=51.0&lon=4.3&z=5&test=true#node/1234`, " + | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |             "the URL-parameters are stated in the part between the `?` and the `#`. There are multiple, all separated by `&`, namely: ", | 
					
						
							| 
									
										
										
										
											2024-07-21 10:52:51 +02:00
										 |  |  |         MarkdownUtils.list([ | 
					
						
							|  |  |  |             "The url-parameter `lat` is `51.0` in this instance", | 
					
						
							|  |  |  |             "The url-parameter `lon` is `4.3` in this instance", | 
					
						
							|  |  |  |             "The url-parameter `z` is `5` in this instance", | 
					
						
							|  |  |  |             "The url-parameter `test` is `true` in this instance", | 
					
						
							|  |  |  |         ]), | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |         "Finally, the URL-hash is the part after the `#`. It is `node/1234` in this case.", | 
					
						
							|  |  |  |     ] | 
					
						
							| 
									
										
										
										
											2022-01-26 21:40:38 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-14 18:44:24 +02:00
										 |  |  |     public static UrlParamDocs(): Map<string, string> { | 
					
						
							| 
									
										
										
										
											2024-07-12 03:17:15 +02:00
										 |  |  |         const dummyLayout = new LayoutConfig(<any>{ | 
					
						
							| 
									
										
										
										
											2022-05-18 01:56:09 +02:00
										 |  |  |             id: ">theme<", | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |             title: { en: "<theme>" }, | 
					
						
							| 
									
										
										
										
											2022-05-18 01:56:09 +02:00
										 |  |  |             description: "A theme to generate docs with", | 
					
						
							|  |  |  |             socialImage: "./assets/SocialImage.png", | 
					
						
							|  |  |  |             startLat: 0, | 
					
						
							|  |  |  |             startLon: 0, | 
					
						
							|  |  |  |             startZoom: 0, | 
					
						
							|  |  |  |             icon: undefined, | 
					
						
							|  |  |  |             layers: [ | 
					
						
							|  |  |  |                 { | 
					
						
							|  |  |  |                     name: "<layer>", | 
					
						
							|  |  |  |                     id: "<layer>", | 
					
						
							|  |  |  |                     source: { | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |                         osmTags: "id~*", | 
					
						
							| 
									
										
										
										
											2022-05-18 01:56:09 +02:00
										 |  |  |                     }, | 
					
						
							| 
									
										
										
										
											2023-09-19 14:04:13 +02:00
										 |  |  |                     lineRendering: [ | 
					
						
							|  |  |  |                         { | 
					
						
							|  |  |  |                             color: "#000000", | 
					
						
							|  |  |  |                             width: 5, | 
					
						
							|  |  |  |                         }, | 
					
						
							|  |  |  |                     ], | 
					
						
							|  |  |  |                     pointRendering: null, | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |                 }, | 
					
						
							|  |  |  |             ], | 
					
						
							| 
									
										
										
										
											2022-05-18 01:56:09 +02:00
										 |  |  |         }) | 
					
						
							|  |  |  |         new FeatureSwitchState(dummyLayout) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |         QueryParameters.GetQueryParameter( | 
					
						
							|  |  |  |             "layer-<layer-id>", | 
					
						
							|  |  |  |             "true", | 
					
						
							| 
									
										
										
										
											2024-07-12 03:17:15 +02:00
										 |  |  |             "Whether the layer with id <layer-id> is shown" | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |         ) | 
					
						
							| 
									
										
										
										
											2022-05-18 01:56:09 +02:00
										 |  |  |         return QueryParameters.documentation | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-06-14 18:44:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-12 03:17:15 +02:00
										 |  |  |     public static GenerateQueryParameterDocs(): string { | 
					
						
							|  |  |  |         const docs: string[] = [ | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |             ...QueryParameterDocumentation.QueryParamDocsIntro, | 
					
						
							| 
									
										
										
										
											2023-08-10 15:37:44 +02:00
										 |  |  |             ...ThemeViewStateHashActor.documentation, | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |         ] | 
					
						
							| 
									
										
										
										
											2022-06-14 18:44:24 +02:00
										 |  |  |         this.UrlParamDocs().forEach((value, key) => { | 
					
						
							| 
									
										
										
										
											2024-07-12 03:17:15 +02:00
										 |  |  |             const c = [ | 
					
						
							| 
									
										
										
										
											2024-07-21 10:52:51 +02:00
										 |  |  |                 "## " + key, | 
					
						
							| 
									
										
										
										
											2022-06-14 18:44:24 +02:00
										 |  |  |                 value, | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |                 QueryParameters.defaults[key] === undefined | 
					
						
							|  |  |  |                     ? "No default value set" | 
					
						
							|  |  |  |                     : `The default value is _${QueryParameters.defaults[key]}_`, | 
					
						
							| 
									
										
										
										
											2024-07-12 03:17:15 +02:00
										 |  |  |             ].join("\n\n") | 
					
						
							| 
									
										
										
										
											2021-11-30 22:50:48 +01:00
										 |  |  |             docs.push(c) | 
					
						
							| 
									
										
										
										
											2022-06-14 18:44:24 +02:00
										 |  |  |         }) | 
					
						
							| 
									
										
										
										
											2024-07-12 03:17:15 +02:00
										 |  |  |         return docs.join("\n\n") | 
					
						
							| 
									
										
										
										
											2021-11-30 22:50:48 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  | } |