forked from MapComplete/MapComplete
		
	Add better error messages when a translation is missing; add play forests
This commit is contained in:
		
							parent
							
								
									7a69847cda
								
							
						
					
					
						commit
						1c2646ae19
					
				
					 8 changed files with 156 additions and 13 deletions
				
			
		|  | @ -22,6 +22,7 @@ import * as tree_nodes from "../assets/layers/trees/tree_nodes.json" | |||
| import * as benches from "../assets/layers/benches/benches.json" | ||||
| import * as benches_at_pt from "../assets/layers/benches/benches_at_pt.json" | ||||
| import * as picnic_tables from "../assets/layers/benches/picnic_tables.json" | ||||
| import * as play_forest from "../assets/layers/play_forest/play_forest.json" | ||||
| import LayerConfig from "./JSON/LayerConfig"; | ||||
| import {LayerConfigJson} from "./JSON/LayerConfigJson"; | ||||
| 
 | ||||
|  | @ -52,7 +53,8 @@ export default class AllKnownLayers { | |||
|         tree_nodes, | ||||
|         benches, | ||||
|         benches_at_pt, | ||||
|         picnic_tables | ||||
|         picnic_tables, | ||||
|         play_forest | ||||
|     ]; | ||||
| 
 | ||||
|     // Must be below the list...
 | ||||
|  |  | |||
|  | @ -21,6 +21,7 @@ import * as trees from "../assets/themes/trees/trees.json" | |||
| import * as personal from "../assets/themes/personalLayout/personalLayout.json" | ||||
| import * as playgrounds from "../assets/themes/playgrounds/playgrounds.json" | ||||
| import * as bicycle_lib from "../assets/themes/bicycle_library/bicycle_library.json" | ||||
| import * as play_forests from "../assets/themes/play_forests/play_forests.json" | ||||
| import LayerConfig from "./JSON/LayerConfig"; | ||||
| import LayoutConfig from "./JSON/LayoutConfig"; | ||||
| import AllKnownLayers from "./AllKnownLayers"; | ||||
|  | @ -70,6 +71,7 @@ export class AllKnownLayouts { | |||
|         new LayoutConfig(climbing), | ||||
|         new LayoutConfig(playgrounds), | ||||
|         new LayoutConfig(trees), | ||||
|         new LayoutConfig(play_forests) | ||||
|     ]; | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -54,19 +54,19 @@ export default class LayerConfig { | |||
|         context = context + "." + json.id; | ||||
|         const self = this; | ||||
|         this.id = json.id; | ||||
|         this.name = Translations.T(json.name); | ||||
|         this.description = Translations.T(json.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; | ||||
|         this.minzoom = json.minzoom; | ||||
|         this.wayHandling = json.wayHandling ?? 0; | ||||
|         this.hideUnderlayingFeaturesMinPercentage = json.hideUnderlayingFeaturesMinPercentage ?? 0; | ||||
|         this.presets = (json.presets ?? []).map(pr => | ||||
|         this.presets = (json.presets ?? []).map((pr, i) => | ||||
|             ({ | ||||
|                 title: Translations.T(pr.title), | ||||
|                 title: Translations.T(pr.title, `${context}.presets[${i}].title`), | ||||
|                 tags: pr.tags.map(t => FromJSON.SimpleTag(t)), | ||||
|                 description: Translations.T(pr.description) | ||||
|                 description: Translations.T(pr.description, `${context}.presets[${i}].description`) | ||||
|             })) | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -53,6 +53,9 @@ export default class LayoutConfig { | |||
|         } else { | ||||
|             this.language = json.language; | ||||
|         } | ||||
|         if(this.language.length == 0){ | ||||
|             throw "No languages defined. Define at least one language" | ||||
|         } | ||||
|         if (json.title === undefined) { | ||||
|             throw "Title not defined in " + this.id; | ||||
|         } | ||||
|  | @ -62,7 +65,7 @@ export default class LayoutConfig { | |||
|         this.title = new Translation(json.title, context + ".title"); | ||||
|         this.description = new Translation(json.description, context + ".description"); | ||||
|         this.shortDescription = json.shortDescription === undefined ? this.description.FirstSentence() : new Translation(json.shortDescription, context + ".shortdescription"); | ||||
|         this.descriptionTail = json.descriptionTail === undefined ? new Translation({"*": ""}, context) : new Translation(json.descriptionTail, context + ".descriptionTail"); | ||||
|         this.descriptionTail = json.descriptionTail === undefined ? new Translation({"*": ""}, context+".descriptionTail") : new Translation(json.descriptionTail, context + ".descriptionTail"); | ||||
|         this.icon = json.icon; | ||||
|         this.socialImage = json.socialImage; | ||||
|         this.startZoom = json.startZoom; | ||||
|  |  | |||
|  | @ -45,13 +45,13 @@ export default class TagRenderingConfig { | |||
|             throw "Initing a TagRenderingConfig with undefined in " + context; | ||||
|         } | ||||
|         if (typeof json === "string") { | ||||
|             this.render = Translations.T(json); | ||||
|             this.render = Translations.T(json, context+".render"); | ||||
|             this.multiAnswer = false; | ||||
|             return; | ||||
|         } | ||||
| 
 | ||||
|         this.render = Translations.T(json.render); | ||||
|         this.question = Translations.T(json.question); | ||||
|         this.render = Translations.T(json.render, context+".render"); | ||||
|         this.question = Translations.T(json.question, context+".question"); | ||||
|         this.roaming = json.roaming ?? false; | ||||
|         const condition = FromJSON.Tag(json.condition ?? {"and": []}, `${context}.condition`); | ||||
|         if (this.roaming && conditionIfRoaming !== undefined) { | ||||
|  | @ -96,10 +96,11 @@ export default class TagRenderingConfig { | |||
|                 } else if (mapping.hideInAnswer !== undefined) { | ||||
|                     hideInAnswer = FromJSON.Tag(mapping.hideInAnswer, `${context}.mapping[${i}].hideInAnswer`); | ||||
|                 } | ||||
|                 const mappingContext = `${context}.mapping[${i}]` | ||||
|                 const mp = { | ||||
|                     if: FromJSON.Tag(mapping.if, `${context}.mapping[${i}].if`), | ||||
|                     ifnot: (mapping.ifnot !== undefined ? FromJSON.Tag(mapping.ifnot, `${context}.mapping[${i}].ifnot`) : undefined), | ||||
|                     then: Translations.T(mapping.then), | ||||
|                     if: FromJSON.Tag(mapping.if, `${mappingContext}.if`), | ||||
|                     ifnot: (mapping.ifnot !== undefined ? FromJSON.Tag(mapping.ifnot, `${mappingContext}.ifnot`) : undefined), | ||||
|                     then: Translations.T(mapping.then, `{mappingContext}.then`), | ||||
|                     hideInAnswer: hideInAnswer | ||||
|                 }; | ||||
|                 if (this.question) { | ||||
|  |  | |||
							
								
								
									
										
											BIN
										
									
								
								assets/layers/play_forest/icon.jpg
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								assets/layers/play_forest/icon.jpg
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 40 KiB | 
							
								
								
									
										108
									
								
								assets/layers/play_forest/play_forest.json
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										108
									
								
								assets/layers/play_forest/play_forest.json
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,108 @@ | |||
| { | ||||
|   "id": "play_forest", | ||||
|   "name": { | ||||
|     "nl": "Speelbossen" | ||||
|   }, | ||||
|   "minzoom": 12, | ||||
|   "overpassTags": { | ||||
|     "and": [ | ||||
|       "playground=forest" | ||||
|     ] | ||||
|   }, | ||||
|   "title": { | ||||
|     "render": { | ||||
|       "nl": "Speelbos" | ||||
|     }, | ||||
|     "mappings": [ | ||||
|       { | ||||
|         "if": "name~*", | ||||
|         "then": { | ||||
|           "nl": "Speelbos {name}" | ||||
|         } | ||||
|       } | ||||
|     ] | ||||
|   }, | ||||
|   "description": { | ||||
|     "nl": "Een speelbos is een vrij toegankelijke zone in een bos" | ||||
|   }, | ||||
|   "tagRenderings": [ | ||||
|     "images", | ||||
|     { | ||||
|       "question": "Wie beheert dit gebied?", | ||||
|       "render": "Dit gebied wordt beheerd door {operator}", | ||||
|       "freeform": { | ||||
|         "key": "operator" | ||||
|       }, | ||||
|       "mappings": [ | ||||
|         { | ||||
|           "if": "operator~[aA][nN][bB]", | ||||
|           "then": "Dit gebied wordt beheerd door het <a href='https://www.natuurenbos.be/spelen'>Agentschap Natuur en Bos</a>", | ||||
|           "hideInAnswer": true | ||||
|         }, | ||||
|         { | ||||
|           "if": "operator=Agenstchap Natuur en Bos", | ||||
|           "then": "Dit gebied wordt beheerd door het <a href='https://www.natuurenbos.be/spelen'>Agentschap Natuur en Bos</a>" | ||||
|         } | ||||
|       ] | ||||
|     }, | ||||
|     { | ||||
|       "question": "Wanneer is deze speelzone toegankelijk?", | ||||
|       "mappings": [ | ||||
|         { | ||||
|           "if": "opening_hours=08:00-22:00", | ||||
|           "then": "Het hele jaar door overdag toegankelijk (van 08:00 tot 22:00)" | ||||
|         }, | ||||
|         { | ||||
|           "if": "opening_hours=Jul-Aug 08:00-22:00", | ||||
|           "then": "Enkel in de <b>zomervakantie</b> en overdag toegankelijk (van 1 juli tot 31 augustus, van 08:00 tot 22:00" | ||||
|         } | ||||
|       ] | ||||
|     }, | ||||
|     { | ||||
|       "question": "Naar waar kan men emailen indien er problemen zijn met de speelzone?", | ||||
|       "render": "De bevoegde dienst kan bereikt worden via {email}", | ||||
|       "freeform": { | ||||
|         "key": "email", | ||||
|         "type": "email" | ||||
|       } | ||||
|     }, | ||||
|     { | ||||
|       "question": "Naar waar kan men bellen indien er problemen zijn met de speelzone?", | ||||
|       "render": "De bevoegde dienst kan getelefoneerd worden via {phone}", | ||||
|       "freeform": { | ||||
|         "key": "phone", | ||||
|         "type": "phone" | ||||
|       } | ||||
|     }, | ||||
|     "questions", | ||||
|     { | ||||
|       "render": "{reviews(name, play_forest)}" | ||||
|     } | ||||
|   ], | ||||
|   "hideUnderlayingFeaturesMinPercentage": 0, | ||||
|   "hideFromOverview": false, | ||||
|   "icon": { | ||||
|     "render": "./assets/layers/play_forest/icon.jpg" | ||||
|   }, | ||||
|   "width": { | ||||
|     "render": "8" | ||||
|   }, | ||||
|   "iconSize": { | ||||
|     "render": "40,40,center" | ||||
|   }, | ||||
|   "color": { | ||||
|     "render": "#2d2" | ||||
|   }, | ||||
|   "presets": [ | ||||
|     { | ||||
|       "title": "Speelbos", | ||||
|       "tags": [ | ||||
|         "leisure=playground", | ||||
|         "playground=forest", | ||||
|         "fixme=Toegevoegd met MapComplete, geometry nog uit te tekenen" | ||||
|       ], | ||||
|       "description": "Een zone in het bos, duidelijk gemarkeerd als speelzone met de betreffende borden<br/><img src='./assets/layers/play_forest/icon.jpg'/>" | ||||
|     } | ||||
|   ], | ||||
|   "wayHandling": 2 | ||||
| } | ||||
							
								
								
									
										27
									
								
								assets/themes/play_forests/play_forests.json
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								assets/themes/play_forests/play_forests.json
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,27 @@ | |||
| { | ||||
|   "id": "play_forests", | ||||
|   "title": { | ||||
|     "nl": "Speelbossen" | ||||
|   }, | ||||
|   "shortDescription": { | ||||
|     "nl": "Deze kaart toont speelbossen" | ||||
|   }, | ||||
|   "description": { | ||||
|     "nl": "Een speelbos is een zone in een bos die vrij toegankelijk is voor spelende kinderen. Deze wordt  in bossen van het Agentschap Natuur en bos altijd aangeduid met het overeenkomstige bord." | ||||
|   }, | ||||
|   "language": [ | ||||
|     "nl" | ||||
|   ], | ||||
|   "maintainer": "", | ||||
|   "icon": "./assets/layers/play_forest/icon.jpg", | ||||
|   "version": "0", | ||||
|   "startLat": 0, | ||||
|   "startLon": 0, | ||||
|   "startZoom": 1, | ||||
|   "widenFactor": 0.05, | ||||
|   "socialImage": "", | ||||
|   "layers": [ | ||||
|     "play_forest" | ||||
|   ], | ||||
|   "roamingRenderings": [] | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue