From fdb769a0fc661f510f9e2e0a256b5e4d82f9f2e6 Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Sun, 7 Nov 2021 18:37:42 +0100 Subject: [PATCH] Fix text-area type, support for newlines in key substitutions (fix #543), small tweaks to etymology-theme (fix #537) --- Models/ThemeConfig/TagRenderingConfig.ts | 3 +++ Models/ThemeConfig/WithContextLoader.ts | 6 ------ UI/Input/ValidatedTextField.ts | 5 ++++- Utils.ts | 9 ++++++++- assets/layers/etymology/etymology.json | 3 ++- assets/layers/ghost_bike/ghost_bike.json | 3 ++- 6 files changed, 19 insertions(+), 10 deletions(-) diff --git a/Models/ThemeConfig/TagRenderingConfig.ts b/Models/ThemeConfig/TagRenderingConfig.ts index ae053f3a0..e43dffb73 100644 --- a/Models/ThemeConfig/TagRenderingConfig.ts +++ b/Models/ThemeConfig/TagRenderingConfig.ts @@ -48,6 +48,9 @@ export default class TagRenderingConfig { this.render = null; this.question = null; this.condition = null; + this.id = "questions" + this.group = "" + return; } diff --git a/Models/ThemeConfig/WithContextLoader.ts b/Models/ThemeConfig/WithContextLoader.ts index 04999b9d9..36948c973 100644 --- a/Models/ThemeConfig/WithContextLoader.ts +++ b/Models/ThemeConfig/WithContextLoader.ts @@ -66,12 +66,6 @@ export default class WithContextLoader { if (renderingJson["builtin"] !== undefined) { const renderingId = renderingJson["builtin"] if (renderingId === "questions") { - if (readOnly) { - throw `A tagrendering has a question, but asking a question does not make sense here: is it a title icon or a geojson-layer? ${context}. The offending tagrendering is ${JSON.stringify( - renderingJson - )}`; - } - const tr = new TagRenderingConfig("questions", context); renderings.push(tr) continue; diff --git a/UI/Input/ValidatedTextField.ts b/UI/Input/ValidatedTextField.ts index a6aef8131..16e222358 100644 --- a/UI/Input/ValidatedTextField.ts +++ b/UI/Input/ValidatedTextField.ts @@ -196,7 +196,7 @@ export default class ValidatedTextField { "A basic string"), ValidatedTextField.tp( "text", - "A string, but allows input of longer strings more comfortably (a text area)", + "A string, but allows input of longer strings more comfortably and supports newlines (a text area)", undefined, undefined, undefined, @@ -473,6 +473,9 @@ export default class ValidatedTextField { options.inputMode = tp.inputmode; + if(tp.inputmode === "text") { + options.htmlType = "area" + } let input: InputElement = new TextField(options); diff --git a/Utils.ts b/Utils.ts index 2fd29533a..21210a086 100644 --- a/Utils.ts +++ b/Utils.ts @@ -186,7 +186,14 @@ Note that these values can be prepare with javascript in the theme by using a [c while (match) { const key = match[1] - txt = txt.replace("{" + key + "}", tags[key] ?? "") + let v = tags[key] + if(v !== undefined ){ + if(typeof v !== "string"){ + v = ""+v + } + v = v.replace(/\n/g, "
") + } + txt = txt.replace("{" + key + "}", v ?? "") match = txt.match(regex) } diff --git a/assets/layers/etymology/etymology.json b/assets/layers/etymology/etymology.json index 773addd3a..e8e35d4ad 100644 --- a/assets/layers/etymology/etymology.json +++ b/assets/layers/etymology/etymology.json @@ -84,7 +84,7 @@ "nl": "Zoeken op inventaris onroerend erfgoed", "en": "Search on inventaris onroerend erfgoed" }, - "conditions": "_country=be" + "condition": "_country=be" }, { "id": "simple etymology", @@ -118,6 +118,7 @@ ] } }, + "questions", { "id": "street-name-sign-image", "render": { diff --git a/assets/layers/ghost_bike/ghost_bike.json b/assets/layers/ghost_bike/ghost_bike.json index 7463a4ba5..106b0b5ee 100644 --- a/assets/layers/ghost_bike/ghost_bike.json +++ b/assets/layers/ghost_bike/ghost_bike.json @@ -165,7 +165,8 @@ "id": "{inscription}" }, "freeform": { - "key": "inscription" + "key": "inscription", + "type": "text" }, "id": "ghost_bike-inscription" },