Kundenanlage mit aktiven Standardwerten vorbelegen #120
This commit is contained in:
@@ -123,11 +123,33 @@ const saveAllowed = computed(() => {
|
||||
|
||||
|
||||
const setupCreate = () => {
|
||||
const setDefaultValue = (datapoint) => {
|
||||
if (props.mode !== "create" || !("defaultValue" in datapoint)) return
|
||||
|
||||
const defaultValue = typeof datapoint.defaultValue === "function"
|
||||
? datapoint.defaultValue()
|
||||
: datapoint.defaultValue
|
||||
|
||||
if(datapoint.key.includes(".")){
|
||||
const [parentKey, childKey] = datapoint.key.split(".")
|
||||
if (item.value[parentKey][childKey] === undefined) {
|
||||
item.value[parentKey][childKey] = defaultValue
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if (item.value[datapoint.key] === undefined) {
|
||||
item.value[datapoint.key] = defaultValue
|
||||
}
|
||||
}
|
||||
|
||||
dataType.templateColumns.forEach(datapoint => {
|
||||
if(datapoint.key.includes(".")){
|
||||
!item.value[datapoint.key.split(".")[0]] ? item.value[datapoint.key.split(".")[0]] = {} : null
|
||||
}
|
||||
|
||||
setDefaultValue(datapoint)
|
||||
|
||||
if(datapoint.inputType === "editor") {
|
||||
if(datapoint.key.includes(".")){
|
||||
item.value[datapoint.key.split(".")[0]][datapoint.key.split(".")[1]] = {}
|
||||
|
||||
Reference in New Issue
Block a user