forked from MapComplete/MapComplete
Studio: fix #1750
This commit is contained in:
parent
121efd8dfb
commit
ef34304efa
4 changed files with 23 additions and 23 deletions
|
@ -35,7 +35,6 @@
|
||||||
|
|
||||||
onDestroy(
|
onDestroy(
|
||||||
currentLang.addCallbackAndRunD((currentLang) => {
|
currentLang.addCallbackAndRunD((currentLang) => {
|
||||||
console.log("Applying current lang:", currentLang)
|
|
||||||
if (!translations.data) {
|
if (!translations.data) {
|
||||||
translations.data = {}
|
translations.data = {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,6 @@
|
||||||
if (config.id === highlighted) {
|
if (config.id === highlighted) {
|
||||||
htmlElem.classList.add("glowing-shadow")
|
htmlElem.classList.add("glowing-shadow")
|
||||||
htmlElem.tabIndex = -1
|
htmlElem.tabIndex = -1
|
||||||
console.log("Scrolling to", htmlElem)
|
|
||||||
htmlElem.scrollIntoView({ behavior: "smooth" })
|
htmlElem.scrollIntoView({ behavior: "smooth" })
|
||||||
Utils.focusOnFocusableChild(htmlElem)
|
Utils.focusOnFocusableChild(htmlElem)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -128,7 +128,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
freeformInput.addCallbackAndRun((freeformValue) => {
|
freeformInput.addCallbackAndRun((freeformValue) => {
|
||||||
console.log("FreeformValue:", freeformValue)
|
|
||||||
if (!mappings || mappings?.length == 0 || config.freeform?.key === undefined) {
|
if (!mappings || mappings?.length == 0 || config.freeform?.key === undefined) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,24 @@
|
||||||
export let path: (string | number)[] = []
|
export let path: (string | number)[] = []
|
||||||
export let schema: ConfigMeta
|
export let schema: ConfigMeta
|
||||||
export let startInEditModeIfUnset: boolean = schema.hints && !schema.hints.ifunset
|
export let startInEditModeIfUnset: boolean = schema.hints && !schema.hints.ifunset
|
||||||
|
|
||||||
|
function mightBeBoolean(type: undefined | JsonSchemaType): boolean {
|
||||||
|
if (type === undefined) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (type["type"]) {
|
||||||
|
type = type["type"]
|
||||||
|
}
|
||||||
|
if (type === "boolean") {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if (!Array.isArray(type)) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return type.some((t) => mightBeBoolean(t))
|
||||||
|
}
|
||||||
|
|
||||||
const isTranslation =
|
const isTranslation =
|
||||||
schema.hints?.typehint === "translation" ||
|
schema.hints?.typehint === "translation" ||
|
||||||
schema.hints?.typehint === "rendered" ||
|
schema.hints?.typehint === "rendered" ||
|
||||||
|
@ -66,6 +83,7 @@
|
||||||
helperArgs,
|
helperArgs,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (schema.hints.default) {
|
if (schema.hints.default) {
|
||||||
configJson.mappings = [
|
configJson.mappings = [
|
||||||
|
@ -77,6 +95,7 @@
|
||||||
schema.hints.default +
|
schema.hints.default +
|
||||||
"</b> will be used. " +
|
"</b> will be used. " +
|
||||||
(schema.hints.ifunset ?? ""),
|
(schema.hints.ifunset ?? ""),
|
||||||
|
hideInAnswer: mightBeBoolean(schema.type)
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
} else if (!schema.required) {
|
} else if (!schema.required) {
|
||||||
|
@ -88,23 +107,7 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
function mightBeBoolean(type: undefined | JsonSchemaType): boolean {
|
|
||||||
if (type === undefined) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if (type["type"]) {
|
|
||||||
type = type["type"]
|
|
||||||
}
|
|
||||||
if (type === "boolean") {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
if (!Array.isArray(type)) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return type.some((t) => mightBeBoolean(t))
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mightBeBoolean(schema.type)) {
|
if (mightBeBoolean(schema.type)) {
|
||||||
configJson.mappings = configJson.mappings ?? []
|
configJson.mappings = configJson.mappings ?? []
|
||||||
configJson.mappings.push(
|
configJson.mappings.push(
|
||||||
|
@ -135,7 +138,7 @@
|
||||||
err = path.join(".") + " " + e
|
err = path.join(".") + " " + e
|
||||||
}
|
}
|
||||||
let startValue = state.getCurrentValueFor(path)
|
let startValue = state.getCurrentValueFor(path)
|
||||||
let startInEditMode = !startValue && startInEditModeIfUnset
|
let startInEditMode = startValue === undefined && startInEditModeIfUnset
|
||||||
const tags = new UIEventSource<Record<string, string>>({ value: startValue })
|
const tags = new UIEventSource<Record<string, string>>({ value: startValue })
|
||||||
try {
|
try {
|
||||||
onDestroy(
|
onDestroy(
|
||||||
|
@ -156,7 +159,7 @@
|
||||||
if (v === "true" || v === "yes" || v === "1") {
|
if (v === "true" || v === "yes" || v === "1") {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if (v === "false" || v === "no" || v === "0") {
|
if (v === "false" || v === "no" || v === "0" || (<any> v) === false) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue