Fix #146
This commit is contained in:
@@ -174,6 +174,49 @@ const setupQuery = () => {
|
|||||||
setupQuery()
|
setupQuery()
|
||||||
|
|
||||||
const loadedOptions = ref({})
|
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 () => {
|
const loadOptions = async () => {
|
||||||
let optionsToLoad = dataType.templateColumns.filter(i => i.selectDataType).map(i => {
|
let optionsToLoad = dataType.templateColumns.filter(i => i.selectDataType).map(i => {
|
||||||
return {
|
return {
|
||||||
@@ -198,6 +241,7 @@ const loadOptions = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
loadOptions()
|
loadOptions()
|
||||||
|
normalizeLoadedSelectValues()
|
||||||
|
|
||||||
const contentChanged = (content, datapoint) => {
|
const contentChanged = (content, datapoint) => {
|
||||||
if (datapoint.key.includes(".")) {
|
if (datapoint.key.includes(".")) {
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ setupPage()
|
|||||||
:type="props.type"
|
:type="props.type"
|
||||||
:item="item"
|
:item="item"
|
||||||
:inModal="true"
|
:inModal="true"
|
||||||
@return-data="(data) => emit('return-data',data)"
|
@return-data="(data) => emit('returnData', data)"
|
||||||
:createQuery="props.createQuery"
|
:createQuery="props.createQuery"
|
||||||
:mode="props.mode"
|
:mode="props.mode"
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user