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]] = {}
|
||||
|
||||
@@ -297,6 +297,7 @@ export const useDataStore = defineStore('data', () => {
|
||||
label: "Aktiv",
|
||||
component: active,
|
||||
inputType: "bool",
|
||||
defaultValue: true,
|
||||
inputColumn: "Allgemeines",
|
||||
sortable: true,
|
||||
distinct: true
|
||||
@@ -383,6 +384,7 @@ export const useDataStore = defineStore('data', () => {
|
||||
selectDataType: "countrys",
|
||||
selectOptionAttribute: "name",
|
||||
selectValueAttribute: "name",
|
||||
defaultValue: "Deutschland",
|
||||
disabledInTable: true,
|
||||
inputColumn: "Kontaktdaten",
|
||||
sortable: true
|
||||
@@ -559,6 +561,7 @@ export const useDataStore = defineStore('data', () => {
|
||||
label: "Aktiv",
|
||||
component: active,
|
||||
inputType: "bool",
|
||||
defaultValue: true,
|
||||
inputColumn: "Allgemeines",
|
||||
sortable: true,
|
||||
distinct: true
|
||||
@@ -641,6 +644,7 @@ export const useDataStore = defineStore('data', () => {
|
||||
selectDataType: "countrys",
|
||||
selectOptionAttribute: "name",
|
||||
selectValueAttribute: "name",
|
||||
defaultValue: "Deutschland",
|
||||
disabledInTable: true,
|
||||
inputColumn: "Bank & Kontakt"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user