From 400756cdea976667a83a14813cbf3d74b673df82 Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Mon, 7 Feb 2022 01:57:15 +0100 Subject: [PATCH] Add placeholder options for freeform keys --- Models/ThemeConfig/Json/TagRenderingConfigJson.ts | 5 +++++ Models/ThemeConfig/TagRenderingConfig.ts | 2 ++ UI/Popup/TagRenderingQuestion.ts | 3 ++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Models/ThemeConfig/Json/TagRenderingConfigJson.ts b/Models/ThemeConfig/Json/TagRenderingConfigJson.ts index 8bed8de50e..72ed195a00 100644 --- a/Models/ThemeConfig/Json/TagRenderingConfigJson.ts +++ b/Models/ThemeConfig/Json/TagRenderingConfigJson.ts @@ -56,6 +56,11 @@ export interface TagRenderingConfigJson { * See Docs/SpecialInputElements.md and UI/Input/ValidatedTextField.ts for supported values */ type?: string, + /** + * A (translated) text that is shown (as gray text) within the textfield + */ + placeholder: string | any + /** * Extra parameters to initialize the input helper arguments. * For semantics, see the 'SpecialInputElements.md' diff --git a/Models/ThemeConfig/TagRenderingConfig.ts b/Models/ThemeConfig/TagRenderingConfig.ts index 14768b35bf..833b4ac8ed 100644 --- a/Models/ThemeConfig/TagRenderingConfig.ts +++ b/Models/ThemeConfig/TagRenderingConfig.ts @@ -30,6 +30,7 @@ export default class TagRenderingConfig { readonly freeform?: { readonly key: string, readonly type: string, + readonly placeholder: Translation, readonly addExtraTags: TagsFilter[]; readonly inline: boolean, readonly default?: string, @@ -93,6 +94,7 @@ export default class TagRenderingConfig { this.freeform = { key: json.freeform.key, type: json.freeform.type ?? "string", + placeholder: Translations.T(json.freeform.placeholder ?? (json.freeform.key + "(" + (json.freeform.type ?? "string") + ")")), addExtraTags: json.freeform.addExtraTags?.map((tg, i) => TagUtils.Tag(tg, `${context}.extratag[${i}]`)) ?? [], inline: json.freeform.inline ?? false, diff --git a/UI/Popup/TagRenderingQuestion.ts b/UI/Popup/TagRenderingQuestion.ts index 6fa6f2d07f..350ef4ad75 100644 --- a/UI/Popup/TagRenderingQuestion.ts +++ b/UI/Popup/TagRenderingQuestion.ts @@ -425,7 +425,8 @@ export default class TagRenderingQuestion extends Combine { mapBackgroundLayer: state.backgroundLayer, unit: applicableUnit, args: configuration.freeform.helperArgs, - feature: feature + feature: feature, + placeholder: configuration.freeform.placeholder }); input.GetValue().setData(tagsData[freeform.key] ?? freeform.default);