Fix #146
This commit is contained in:
@@ -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(".")) {
|
||||
|
||||
Reference in New Issue
Block a user