From 666a3039fed4475afe7cc86620c92841f977fab8 Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Sun, 11 Apr 2021 19:21:41 +0200 Subject: [PATCH] Improvements to GRB theme --- Customizations/JSON/LayerConfig.ts | 3 +-- UI/i18n/Translation.ts | 12 ++++++--- assets/themes/grb.json | 43 +++++++++++++++++++++++++++--- 3 files changed, 49 insertions(+), 9 deletions(-) diff --git a/Customizations/JSON/LayerConfig.ts b/Customizations/JSON/LayerConfig.ts index 45aae95..c65a556 100644 --- a/Customizations/JSON/LayerConfig.ts +++ b/Customizations/JSON/LayerConfig.ts @@ -193,7 +193,7 @@ export default class LayerConfig { this.title = tr("title", undefined); - this.icon = tr("icon", Img.AsData(Svg.pin)); + this.icon = tr("icon", ""); this.iconOverlays = (json.iconOverlays ?? []).map((overlay, i) => { let tr = new TagRenderingConfig(overlay.then, self.source.osmTags, `iconoverlays.${i}`); if (typeof overlay.then === "string" && SharedTagRenderings.SharedIcons[overlay.then] !== undefined) { @@ -415,7 +415,6 @@ export default class LayerConfig { const label = self.label.GetRenderValue(tgs)?.Subs(tgs) .SetClass("block w-min text-center") .SetStyle("margin-top: "+(iconH + 2) +"px") - console.log("Generating label gave ", label, " source: ", self.label, "tags: ", tgs) if (label !== undefined) { htmlParts.push(new Combine([label]).SetClass("flex flex-col items-center")) } diff --git a/UI/i18n/Translation.ts b/UI/i18n/Translation.ts index 279b0a9..0730f28 100644 --- a/UI/i18n/Translation.ts +++ b/UI/i18n/Translation.ts @@ -19,8 +19,8 @@ export class Translation extends UIElement { let count = 0; for (const translationsKey in translations) { count++; - if(typeof(translations[translationsKey]) != "string"){ - throw "Error in an object depicting a translation: a non-string object was found. ("+context+")\n You probably put some other section accidentally in the translation" + if (typeof (translations[translationsKey]) != "string") { + throw "Error in an object depicting a translation: a non-string object was found. (" + context + ")\n You probably put some other section accidentally in the translation" } } this.translations = translations; @@ -73,9 +73,13 @@ export class Translation extends UIElement { let rtext: string = ""; if (typeof (el) === "string") { rtext = el; - } else { + } else if(typeof(el) === "number") { + // HUH? Where did that number come from? + rtext = "" + el; + }else { Translation.forcedLanguage = lang; // This is a very dirty hack - it'll bite me one day rtext = el.InnerRender(); + } for (let i = 0; i < parts.length - 1; i++) { combined.push(parts[i]); @@ -145,7 +149,7 @@ export class Translation extends UIElement { .map(match => match[1].trim().replace(/^['"]/, '').replace(/['"]$/, '')); allIcons.push(...sources) } - }catch(e){ + } catch (e) { console.error("Could not search for images: ", render, this.txt) throw e } diff --git a/assets/themes/grb.json b/assets/themes/grb.json index b56fa01..1ade2d1 100644 --- a/assets/themes/grb.json +++ b/assets/themes/grb.json @@ -35,6 +35,9 @@ ] } }, + "calculatedTags": [ + "_grbNumber=(feat.properties.fixme?.match(/GRB thinks that this has number ([^;]+)/ ) ?? ['','none']) [1]" + ], "title": { "render": { "nl": "{addr:street} {addr:housenumber}" @@ -77,12 +80,40 @@ "then": { "nl": "Geen huisnummer" } + }, + { + "if": { + "and": [ + "addr:housenumber:={_grbNumber}", + "fixme=" + ] + }, + "then": "Het huisnummer is {_grbNumber}, wat overeenkomt met het GRB", + "hideInAnswer": { + "or": [ + "_grbNumber=", + "_grbNumber=none", + "_grbNumber=no number" + ] + } + }, + { + "if": { + "and": [ + "addr:housenumber:=", + "not:addr:housenumber=yes", + "fixme=" + ] + }, + "then": "Dit gebouw heeft geen nummer, net zoals in het GRB", + "hideInAnswer": "_grbNumber!=no number" } ] }, { + "question": "Wat is de wooneenheid-aanduiding?", "render": { - "nl": "De wooneeinheid-aanduiding is {addr:unit} " + "nl": "De wooneenheid-aanduiding is {addr:unit} " }, "freeform": { "key": "addr:unit" @@ -142,8 +173,13 @@ } ], "hideUnderlayingFeaturesMinPercentage": 0, - "icon": { - "render": "./assets/svg/bug.svg" + "label": { + "mappings": [ + { + "if": "addr:housenumber~*", + "then": "
{addr:housenumber}
" + } + ] }, "width": { "render": "2" @@ -155,6 +191,7 @@ "color": { "render": "#00f" }, + "wayHandling": 2, "presets": [] } ],