From 85ffd61c1627c3fdfcb1c54f8fe9ec08d3b76886 Mon Sep 17 00:00:00 2001 From: florianfederspiel Date: Wed, 12 Feb 2025 10:19:50 +0100 Subject: [PATCH] Added Required Values --- components/EntityEdit.vue | 106 +++++++++++++++++++++++++++++--------- stores/data.js | 30 ++++++++++- 2 files changed, 112 insertions(+), 24 deletions(-) diff --git a/components/EntityEdit.vue b/components/EntityEdit.vue index d6fd9a1..852a0b7 100644 --- a/components/EntityEdit.vue +++ b/components/EntityEdit.vue @@ -126,6 +126,32 @@ const contentChanged = (content, datapoint) => { } } +const saveAllowed = ref(false) +const calcSaveAllowed = (item) => { + console.log(dataType.templateColumns) + let allowedCount = 0 + + dataType.templateColumns.filter(i => i.inputType).forEach(datapoint => { + if(datapoint.required) { + console.log("is required") + + if(datapoint.key.includes(".")){ + if(item[datapoint.key.split('.')[0]][datapoint.key.split('.')[1]]) allowedCount += 1 + } else { + if(item[datapoint.key]) allowedCount += 1 + } + } else { + allowedCount += 1 + } + }) + + saveAllowed.value = allowedCount >= dataType.templateColumns.filter(i => i.inputType).length +} +//calcSaveAllowed() + +watch(item.value, async (newItem, oldItem) => { + calcSaveAllowed(newItem) +}) { { /> { { { { { /> { { /> + + + + { icon="i-heroicons-x-mark" /> -
- Eigene Felder +
@@ -437,6 +484,7 @@ const contentChanged = (content, datapoint) => { { { { /> { { { { { /> { { /> + { key: "name", label: "Name", title: true, + required: true, inputType: "text" },{ key: "categorie", - label: "Kategorie" + label: "Kategorie", + required: true, },{ key: "profile", label: "Mitarbeiter", @@ -157,6 +159,7 @@ export const useDataStore = defineStore('data', () => { }, { key: "name", label: "Firmenname", + required: true, title: true, inputType: "text", disabledFunction: function (item) { @@ -324,6 +327,7 @@ export const useDataStore = defineStore('data', () => { },{ key: "lastName", label: "Nachname", + required: true, inputType: "text", inputChangeFunction: function (row) { row.fullName = `${row.firstName} ${row.lastName}` @@ -414,6 +418,7 @@ export const useDataStore = defineStore('data', () => { templateColumns: [ { key: "name", + required: true, label: "Name", title: true, inputType: "text", @@ -570,12 +575,14 @@ export const useDataStore = defineStore('data', () => { },{ key: "name", label: "Name", + required: true, inputType: "text", title: true }, { key: "profile", label: "Mitarbeiter", + required: true, inputType: "select", selectDataType: "profiles", selectOptionAttribute: "fullName", @@ -601,11 +608,13 @@ export const useDataStore = defineStore('data', () => { ] },{ key: "startDate", + required: true, label: "Start", inputType: "date", component: startDate },{ key: "endDate", + required: true, label: "Ende", inputType: "date", component: endDate @@ -639,6 +648,7 @@ export const useDataStore = defineStore('data', () => { { key: "name", label: "Name", + required: true, inputType: "text", title: true }, @@ -690,6 +700,7 @@ export const useDataStore = defineStore('data', () => { { key: "name", label:"Name", + required: true, title: true, inputType: "text" }, @@ -716,6 +727,7 @@ export const useDataStore = defineStore('data', () => { },{ key: "sellingPrice", label: "Verkaufpreispreis", + required: true, component: sellingPrice, inputType: "number", inputTrailing: "EUR" @@ -800,6 +812,7 @@ export const useDataStore = defineStore('data', () => { { key: "projecttype", label: "Typ", + required: true, component: projecttype, inputType: "select", selectDataType: "projecttypes", @@ -815,6 +828,7 @@ export const useDataStore = defineStore('data', () => { },{ key: "name", label: "Name", + required: true, title: true, inputType: "text" }, @@ -822,6 +836,7 @@ export const useDataStore = defineStore('data', () => { key: "customer", label: "Kunde", component: customer, + required: true, inputType: "select", selectDataType: "customers", selectOptionAttribute: "name", @@ -909,6 +924,7 @@ export const useDataStore = defineStore('data', () => { },{ key: 'licensePlate', label: "Kennzeichen", + required: true, inputType: "text", title: true },{ @@ -1011,6 +1027,7 @@ export const useDataStore = defineStore('data', () => { }, { key: "name", + required: true, label: "Name", title: true, inputType: "text" @@ -1143,6 +1160,7 @@ export const useDataStore = defineStore('data', () => { key: "name", label: "Name", inputType: "text", + required: true, title: true, inputColumn: "Allgemeines" }, @@ -1157,6 +1175,7 @@ export const useDataStore = defineStore('data', () => { key: "type", label: "Typ", inputType: "select", + required: true, selectValueAttribute: "label", selectManualOptions: [ {label:"Standort"}, @@ -1278,6 +1297,7 @@ export const useDataStore = defineStore('data', () => { key: "name", label: "Name", title: true, + required: true, inputType: "text", inputColumn: "Allgemeines" }, @@ -1408,6 +1428,7 @@ export const useDataStore = defineStore('data', () => { { key: "name", label: "Name", + required: true, title: true, inputType: "text" }, @@ -1519,17 +1540,20 @@ export const useDataStore = defineStore('data', () => { { key: 'name', label: "Name", + required: true, title: true, inputType: "text" }, { key: "startDate", label: "Start", + required: true, inputType: "datetime", }, { key: "endDate", label: "Ende", + required: true, inputType: "datetime", },/*{ key: "eventtype", @@ -1556,6 +1580,7 @@ export const useDataStore = defineStore('data', () => { },{ key: "profiles", label: "Beteiligte Benutzer", + required: true, inputType: "select", selectDataType: "profiles", selectOptionAttribute: "fullName", @@ -1615,6 +1640,7 @@ export const useDataStore = defineStore('data', () => { { key: "name", label: "Name", + required: true, title: true, inputType: "text" }, @@ -1651,6 +1677,7 @@ export const useDataStore = defineStore('data', () => { { key: "name", label: "Name", + required: true, title: true, inputType: "text" }, @@ -1701,6 +1728,7 @@ export const useDataStore = defineStore('data', () => { key: "name", label: "Name", title: true, + required: true, inputType: "text" }, {