From c1760918632f6a44adb1578582b20c30afcea80d Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Thu, 12 Sep 2024 02:37:26 +0200 Subject: [PATCH] Studio: automatically detect possible tag values, fix #2103 --- src/UI/Studio/SchemaBasedField.svelte | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/UI/Studio/SchemaBasedField.svelte b/src/UI/Studio/SchemaBasedField.svelte index f7855b273f..1870db2dc3 100644 --- a/src/UI/Studio/SchemaBasedField.svelte +++ b/src/UI/Studio/SchemaBasedField.svelte @@ -32,12 +32,23 @@ return type.some((t) => mightBeBoolean(t)) } + function mightBeTag(){ + const t = schema.type + if(!Array.isArray(t)){ + return false + } + const hasAnd = t.some(obj => obj["$ref"] === "#/definitions/{and:TagConfigJson[];}") + const hasOr = t.some(obj => obj["$ref"] === "#/definitions/{or:TagConfigJson[];}") + const hasString = t.some(obj => obj["type"] === "string") + return hasAnd && hasOr && hasString + } + const isTranslation = schema.hints?.typehint === "translation" || schema.hints?.typehint === "rendered" || ConfigMetaUtils.isTranslation(schema) - let type = schema.hints.typehint ?? "string" + let type = schema.hints.typehint ?? (mightBeTag() ? "tag" : "string") let rendervalue = (schema.hints.inline ?? schema.path.join(".")) + (isTranslation ? " {translated(value)}" : " {value}")