Kundenanlage mit aktiven Standardwerten vorbelegen #120
This commit is contained in:
@@ -123,11 +123,33 @@ const saveAllowed = computed(() => {
|
|||||||
|
|
||||||
|
|
||||||
const setupCreate = () => {
|
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 => {
|
dataType.templateColumns.forEach(datapoint => {
|
||||||
if(datapoint.key.includes(".")){
|
if(datapoint.key.includes(".")){
|
||||||
!item.value[datapoint.key.split(".")[0]] ? item.value[datapoint.key.split(".")[0]] = {} : null
|
!item.value[datapoint.key.split(".")[0]] ? item.value[datapoint.key.split(".")[0]] = {} : null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setDefaultValue(datapoint)
|
||||||
|
|
||||||
if(datapoint.inputType === "editor") {
|
if(datapoint.inputType === "editor") {
|
||||||
if(datapoint.key.includes(".")){
|
if(datapoint.key.includes(".")){
|
||||||
item.value[datapoint.key.split(".")[0]][datapoint.key.split(".")[1]] = {}
|
item.value[datapoint.key.split(".")[0]][datapoint.key.split(".")[1]] = {}
|
||||||
|
|||||||
@@ -297,6 +297,7 @@ export const useDataStore = defineStore('data', () => {
|
|||||||
label: "Aktiv",
|
label: "Aktiv",
|
||||||
component: active,
|
component: active,
|
||||||
inputType: "bool",
|
inputType: "bool",
|
||||||
|
defaultValue: true,
|
||||||
inputColumn: "Allgemeines",
|
inputColumn: "Allgemeines",
|
||||||
sortable: true,
|
sortable: true,
|
||||||
distinct: true
|
distinct: true
|
||||||
@@ -383,6 +384,7 @@ export const useDataStore = defineStore('data', () => {
|
|||||||
selectDataType: "countrys",
|
selectDataType: "countrys",
|
||||||
selectOptionAttribute: "name",
|
selectOptionAttribute: "name",
|
||||||
selectValueAttribute: "name",
|
selectValueAttribute: "name",
|
||||||
|
defaultValue: "Deutschland",
|
||||||
disabledInTable: true,
|
disabledInTable: true,
|
||||||
inputColumn: "Kontaktdaten",
|
inputColumn: "Kontaktdaten",
|
||||||
sortable: true
|
sortable: true
|
||||||
@@ -559,6 +561,7 @@ export const useDataStore = defineStore('data', () => {
|
|||||||
label: "Aktiv",
|
label: "Aktiv",
|
||||||
component: active,
|
component: active,
|
||||||
inputType: "bool",
|
inputType: "bool",
|
||||||
|
defaultValue: true,
|
||||||
inputColumn: "Allgemeines",
|
inputColumn: "Allgemeines",
|
||||||
sortable: true,
|
sortable: true,
|
||||||
distinct: true
|
distinct: true
|
||||||
@@ -641,6 +644,7 @@ export const useDataStore = defineStore('data', () => {
|
|||||||
selectDataType: "countrys",
|
selectDataType: "countrys",
|
||||||
selectOptionAttribute: "name",
|
selectOptionAttribute: "name",
|
||||||
selectValueAttribute: "name",
|
selectValueAttribute: "name",
|
||||||
|
defaultValue: "Deutschland",
|
||||||
disabledInTable: true,
|
disabledInTable: true,
|
||||||
inputColumn: "Bank & Kontakt"
|
inputColumn: "Bank & Kontakt"
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user