This commit is contained in:
2026-03-23 08:26:21 +01:00
parent ace2213cc4
commit e0e99ba6f5
2 changed files with 45 additions and 1 deletions

View File

@@ -174,6 +174,49 @@ const setupQuery = () => {
setupQuery()
const loadedOptions = ref({})
const normalizeSelectFieldValue = (value, isMultiple = false) => {
if (isMultiple) {
if (!Array.isArray(value)) return []
return value.map((entry) => {
if (entry && typeof entry === "object" && "id" in entry) {
return entry.id
}
return entry
})
}
if (value && typeof value === "object" && "id" in value) {
return value.id
}
return value
}
const normalizeLoadedSelectValues = () => {
dataType.templateColumns.forEach((datapoint) => {
if (datapoint.inputType !== "select") return
if (datapoint.key.includes(".")) {
const [parentKey, childKey] = datapoint.key.split(".")
if (!item.value[parentKey]) return
item.value[parentKey][childKey] = normalizeSelectFieldValue(
item.value[parentKey][childKey],
datapoint.selectMultiple
)
return
}
item.value[datapoint.key] = normalizeSelectFieldValue(
item.value[datapoint.key],
datapoint.selectMultiple
)
})
}
const loadOptions = async () => {
let optionsToLoad = dataType.templateColumns.filter(i => i.selectDataType).map(i => {
return {
@@ -198,6 +241,7 @@ const loadOptions = async () => {
}
loadOptions()
normalizeLoadedSelectValues()
const contentChanged = (content, datapoint) => {
if (datapoint.key.includes(".")) {