Add better error messages when a translation is missing; add play forests

This commit is contained in:
pietervdvn 2021-03-13 19:08:31 +01:00
parent 7a69847cda
commit 1c2646ae19
8 changed files with 156 additions and 13 deletions

View file

@ -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 from "../assets/layers/benches/benches.json"
import * as benches_at_pt from "../assets/layers/benches/benches_at_pt.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 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 LayerConfig from "./JSON/LayerConfig";
import {LayerConfigJson} from "./JSON/LayerConfigJson"; import {LayerConfigJson} from "./JSON/LayerConfigJson";
@ -52,7 +53,8 @@ export default class AllKnownLayers {
tree_nodes, tree_nodes,
benches, benches,
benches_at_pt, benches_at_pt,
picnic_tables picnic_tables,
play_forest
]; ];
// Must be below the list... // Must be below the list...

View file

@ -21,6 +21,7 @@ import * as trees from "../assets/themes/trees/trees.json"
import * as personal from "../assets/themes/personalLayout/personalLayout.json" import * as personal from "../assets/themes/personalLayout/personalLayout.json"
import * as playgrounds from "../assets/themes/playgrounds/playgrounds.json" import * as playgrounds from "../assets/themes/playgrounds/playgrounds.json"
import * as bicycle_lib from "../assets/themes/bicycle_library/bicycle_library.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 LayerConfig from "./JSON/LayerConfig";
import LayoutConfig from "./JSON/LayoutConfig"; import LayoutConfig from "./JSON/LayoutConfig";
import AllKnownLayers from "./AllKnownLayers"; import AllKnownLayers from "./AllKnownLayers";
@ -70,6 +71,7 @@ export class AllKnownLayouts {
new LayoutConfig(climbing), new LayoutConfig(climbing),
new LayoutConfig(playgrounds), new LayoutConfig(playgrounds),
new LayoutConfig(trees), new LayoutConfig(trees),
new LayoutConfig(play_forests)
]; ];

View file

@ -54,19 +54,19 @@ export default class LayerConfig {
context = context + "." + json.id; context = context + "." + json.id;
const self = this; const self = this;
this.id = json.id; this.id = json.id;
this.name = Translations.T(json.name); this.name = Translations.T(json.name, context+".name");
this.description = Translations.T(json.description); this.description = Translations.T(json.description, context+".description");
this.overpassTags = FromJSON.Tag(json.overpassTags, context + ".overpasstags"); this.overpassTags = FromJSON.Tag(json.overpassTags, context + ".overpasstags");
this.doNotDownload = json.doNotDownload ?? false, this.doNotDownload = json.doNotDownload ?? false,
this.passAllFeatures = json.passAllFeatures ?? false; this.passAllFeatures = json.passAllFeatures ?? false;
this.minzoom = json.minzoom; this.minzoom = json.minzoom;
this.wayHandling = json.wayHandling ?? 0; this.wayHandling = json.wayHandling ?? 0;
this.hideUnderlayingFeaturesMinPercentage = json.hideUnderlayingFeaturesMinPercentage ?? 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)), tags: pr.tags.map(t => FromJSON.SimpleTag(t)),
description: Translations.T(pr.description) description: Translations.T(pr.description, `${context}.presets[${i}].description`)
})) }))

View file

@ -53,6 +53,9 @@ export default class LayoutConfig {
} else { } else {
this.language = json.language; this.language = json.language;
} }
if(this.language.length == 0){
throw "No languages defined. Define at least one language"
}
if (json.title === undefined) { if (json.title === undefined) {
throw "Title not defined in " + this.id; throw "Title not defined in " + this.id;
} }
@ -62,7 +65,7 @@ export default class LayoutConfig {
this.title = new Translation(json.title, context + ".title"); this.title = new Translation(json.title, context + ".title");
this.description = new Translation(json.description, context + ".description"); this.description = new Translation(json.description, context + ".description");
this.shortDescription = json.shortDescription === undefined ? this.description.FirstSentence() : new Translation(json.shortDescription, context + ".shortdescription"); 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.icon = json.icon;
this.socialImage = json.socialImage; this.socialImage = json.socialImage;
this.startZoom = json.startZoom; this.startZoom = json.startZoom;

View file

@ -45,13 +45,13 @@ export default class TagRenderingConfig {
throw "Initing a TagRenderingConfig with undefined in " + context; throw "Initing a TagRenderingConfig with undefined in " + context;
} }
if (typeof json === "string") { if (typeof json === "string") {
this.render = Translations.T(json); this.render = Translations.T(json, context+".render");
this.multiAnswer = false; this.multiAnswer = false;
return; return;
} }
this.render = Translations.T(json.render); this.render = Translations.T(json.render, context+".render");
this.question = Translations.T(json.question); this.question = Translations.T(json.question, context+".question");
this.roaming = json.roaming ?? false; this.roaming = json.roaming ?? false;
const condition = FromJSON.Tag(json.condition ?? {"and": []}, `${context}.condition`); const condition = FromJSON.Tag(json.condition ?? {"and": []}, `${context}.condition`);
if (this.roaming && conditionIfRoaming !== undefined) { if (this.roaming && conditionIfRoaming !== undefined) {
@ -96,10 +96,11 @@ export default class TagRenderingConfig {
} else if (mapping.hideInAnswer !== undefined) { } else if (mapping.hideInAnswer !== undefined) {
hideInAnswer = FromJSON.Tag(mapping.hideInAnswer, `${context}.mapping[${i}].hideInAnswer`); hideInAnswer = FromJSON.Tag(mapping.hideInAnswer, `${context}.mapping[${i}].hideInAnswer`);
} }
const mappingContext = `${context}.mapping[${i}]`
const mp = { const mp = {
if: FromJSON.Tag(mapping.if, `${context}.mapping[${i}].if`), if: FromJSON.Tag(mapping.if, `${mappingContext}.if`),
ifnot: (mapping.ifnot !== undefined ? FromJSON.Tag(mapping.ifnot, `${context}.mapping[${i}].ifnot`) : undefined), ifnot: (mapping.ifnot !== undefined ? FromJSON.Tag(mapping.ifnot, `${mappingContext}.ifnot`) : undefined),
then: Translations.T(mapping.then), then: Translations.T(mapping.then, `{mappingContext}.then`),
hideInAnswer: hideInAnswer hideInAnswer: hideInAnswer
}; };
if (this.question) { if (this.question) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

View 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
}

View 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": []
}