Studio: automatically detect possible tag values, fix #2103

This commit is contained in:
Pieter Vander Vennet 2024-09-12 02:37:26 +02:00
parent 5a9ae3f104
commit c176091863

View file

@ -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 ? " <b>{translated(value)}</b>" : " <b>{value}</b>")