-
-
-
-
-
-
-
-
- {{message.text}}
-
-
+
+
+ {{message.text}}
+
+
-
-
-
-
- {{message.text}}
-
+ />
+
+
-
-
-
-
-
-
-
- Senden
-
-
-
-
-
+
+
+
+
+
+
+ Senden
+
+
+
+
+
diff --git a/spaces/pages/contacts/[mode]/[[id]].vue b/spaces/pages/contacts/[mode]/[[id]].vue
index a969b7e..c1b7e5d 100644
--- a/spaces/pages/contacts/[mode]/[[id]].vue
+++ b/spaces/pages/contacts/[mode]/[[id]].vue
@@ -53,23 +53,6 @@ const cancelEditorCreate = () => {
}
}
-const updateItem = async () => {
- const {error} = await supabase
- .from("contacts")
- .update(itemInfo.value)
- .eq('id',itemInfo.value.id)
-
- if(error) {
- console.log(error)
- }
-
- router.push(`/contacts/show/${currentContact.id}`)
- toast.add({title: "Kontakt erfolgreich gespeichert"})
- dataStore.fetchContacts()
-}
-
-
-
setupPage()
@@ -244,7 +227,7 @@ setupPage()
Speichern
diff --git a/spaces/pages/contracts/[mode]/[[id]].vue b/spaces/pages/contracts/[mode]/[[id]].vue
index 58a598b..ac19807 100644
--- a/spaces/pages/contracts/[mode]/[[id]].vue
+++ b/spaces/pages/contracts/[mode]/[[id]].vue
@@ -50,22 +50,6 @@ const cancelEditorCreate = () => {
}
}
-const updateItem = async () => {
- const {error} = await supabase
- .from("contracts")
- .update(itemInfo.value)
- .eq('id',itemInfo.value.id)
- if(error) {
- console.log(error)
- }
-
- router.push(`/contracts/show/${currentContract.id}`)
- toast.add({title: "Vertrag erfolgreich gespeichert"})
- dataStore.fetchContracts()
-}
-
-
-
setupPage()
@@ -170,7 +154,7 @@ setupPage()
Speichern
diff --git a/spaces/pages/customers/[mode]/[[id]].vue b/spaces/pages/customers/[mode]/[[id]].vue
index 305a757..0074ccc 100644
--- a/spaces/pages/customers/[mode]/[[id]].vue
+++ b/spaces/pages/customers/[mode]/[[id]].vue
@@ -13,7 +13,7 @@ const id = ref(route.params.id ? route.params.id : null )
const numberRange = useNumberRange("customers")
const dataStore = useDataStore()
-let currentCustomer = ref(null)
+let currentItem = ref(null)
@@ -28,16 +28,16 @@ const itemInfo = ref({
//Functions
const setupPage = async () => {
if(mode.value === "show" || mode.value === "edit"){
- currentCustomer.value = await dataStore.getCustomerById(Number(useRoute().params.id))
+ currentItem.value = await dataStore.getCustomerById(Number(useRoute().params.id))
}
- if(mode.value === "edit") itemInfo.value = currentCustomer.value
+ if(mode.value === "edit") itemInfo.value = currentItem.value
}
const editCustomer = async () => {
- router.push(`/customers/edit/${currentCustomer.value.id}`)
+ router.push(`/customers/edit/${currentItem.value.id}`)
setupPage()
}
@@ -50,19 +50,7 @@ const cancelEditorCreate = () => {
}
}
-const updateCustomer = async () => {
- const {error} = await supabase
- .from("customers")
- .update(itemInfo.value)
- .eq('id',itemInfo.value.id)
- if(error) {
- console.log(error)
- }
- toast.add({title: "Kunde erfolgreich gespeichert"})
- router.push(`/customers/show/${currentCustomer.id}`)
- dataStore.fetchCustomers()
-}
@@ -70,10 +58,10 @@ setupPage()
-
+
Kunde aktiv
@@ -83,37 +71,37 @@ setupPage()
>
Kunde gesperrt
- {{currentCustomer.name}}
+ {{currentItem.name}}
+ Projekt
+ Ansprechpartner
- Kundennummer: {{currentCustomer.customerNumber}}
+ Kundennummer: {{currentItem.customerNumber}}
Informationen:
-
-
Straße + Hausnummer: {{currentCustomer.infoData.street}}
-
PLZ + Ort: {{currentCustomer.infoData.zip}} {{currentCustomer.infoData.city}}
-
Telefon: {{currentCustomer.infoData.tel}}
-
E-Mail: {{currentCustomer.infoData.email}}
-
Web: {{currentCustomer.infoData.web}}
-
USt-Id: {{currentCustomer.infoData.ustid}}
+
+ Straße + Hausnummer: {{currentItem.infoData.street}}
+ PLZ + Ort: {{currentItem.infoData.zip}} {{currentItem.infoData.city}}
+ Telefon: {{currentItem.infoData.tel}}
+ E-Mail: {{currentItem.infoData.email}}
+ Web: {{currentItem.infoData.web}}
+ USt-Id: {{currentItem.infoData.ustid}}
Notizen:
- {{currentCustomer.notes}}
+ {{currentItem.notes}}
{{contact.salutation}} {{contact.fullName}} - {{contact.role}}
@@ -142,7 +130,7 @@ setupPage()
Bearbeiten
@@ -253,7 +241,7 @@ setupPage()
Speichern
@@ -276,8 +264,8 @@ setupPage()
diff --git a/spaces/pages/incominginvoices/[mode]/[[id]].vue b/spaces/pages/incominginvoices/[mode]/[[id]].vue
index a62cbfd..075fa1b 100644
--- a/spaces/pages/incominginvoices/[mode]/[[id]].vue
+++ b/spaces/pages/incominginvoices/[mode]/[[id]].vue
@@ -89,30 +89,14 @@ const totalCalculated = computed(() => {
const setState = async (newState) => {
if(mode.value === 'show') {
- await updateItem({...currentVendorInvoice.value, state: newState})
+ await dataStore.updateItem('incomingInvoices',{...currentVendorInvoice.value, state: newState})
} else if(mode.value === 'edit') {
- await updateItem({...itemInfo.value, state: newState})
+ await dataStore.updateItem('incomingInvoices',{...itemInfo.value, state: newState})
}
await router.push("/incominginvoices")
}
-const updateItem = async (item) => {
- const {error} = await supabase
- .from("incomingInvoices")
- .update(item)
- .eq('id',item.id)
- if(error) {
- console.log(error)
- } else {
- mode.value = "show"
- toast.add({title: "Eingangsrechnung erfolgreich gespeichert"})
- dataStore.fetchIncomingInvoices()
- //await router.push("/incominginvoices")
- }
-}
-
-
setupPage()
@@ -128,7 +112,7 @@ setupPage()
Speichern
diff --git a/spaces/pages/plants/[mode]/[[id]].vue b/spaces/pages/plants/[mode]/[[id]].vue
index 664f521..d0f83ba 100644
--- a/spaces/pages/plants/[mode]/[[id]].vue
+++ b/spaces/pages/plants/[mode]/[[id]].vue
@@ -55,24 +55,6 @@ const cancelEditorCreate = () => {
}
}
-const updateItem = async () => {
- const {error} = await supabase
- .from("plants")
- .update(itemInfo.value)
- .eq('id',itemInfo.value.id)
-
- if(error) {
- console.log(error)
- }
-
-
- router.push(`/plants/show/${currentItem.id}`)
- toast.add({title: "Anlage erfolgreich gespeichert"})
- dataStore.fetchPlants()
-}
-
-
-
setupPage()
@@ -174,7 +156,7 @@ setupPage()
Speichern
diff --git a/spaces/pages/products/[mode]/[[id]].vue b/spaces/pages/products/[mode]/[[id]].vue
index f2bbc77..3766d58 100644
--- a/spaces/pages/products/[mode]/[[id]].vue
+++ b/spaces/pages/products/[mode]/[[id]].vue
@@ -47,27 +47,6 @@ const cancelEditorCreate = () => {
}
}
-const updateItem = async () => {
- const {error} = await supabase
- .from("products")
- .update(itemInfo.value)
- .eq('id',itemInfo.value.id)
-
- if(error) {
- console.log(error)
- } else {
- mode.value = "show"
- itemInfo.value = {
- id: 0,
- name: "",
- }
- toast.add({title: "Artikel erfolgreich gespeichert"})
- dataStore.fetchProducts()
- }
-
-
-}
-
setupPage()
@@ -200,7 +179,7 @@ setupPage()
Speichern
diff --git a/spaces/pages/projects/[mode]/[[id]].vue b/spaces/pages/projects/[mode]/[[id]].vue
index 61a310a..888b0c4 100644
--- a/spaces/pages/projects/[mode]/[[id]].vue
+++ b/spaces/pages/projects/[mode]/[[id]].vue
@@ -506,7 +506,7 @@ setupPage()
Speichern
diff --git a/spaces/pages/projects/[mode]/deprecated.vue b/spaces/pages/projects/[mode]/deprecated.vue
deleted file mode 100644
index 1d011f1..0000000
--- a/spaces/pages/projects/[mode]/deprecated.vue
+++ /dev/null
@@ -1,528 +0,0 @@
-
-
-
-
-
-
-
-
Hier wird aktuell noch gearbeitet
-
-
-
-
- {
- router.push(`/tasks/show/${row.id}`)
- }"
- >
-
-
-
-
-
-
-
- Hochladen
-
-
-
-
-
- Datei hochladen
-
-
-
-
-
-
-
-
-
-
-
-
- Hochladen
-
-
-
-
-
-
-
-
-
-
-
-
-
- Dokumente
-
-
-
- Speichern
-
-
-
-
- Projekt Zeit: {{currentProject.projectHours.toString().replace(".",":")}} Stunden
-
-
- {{profiles.find(profile => profile.id === row.user) ? profiles.find(profile => profile.id === row.user).firstName + " " + profiles.find(profile => profile.id === row.user).lastName : row.user }}
-
-
-
- {{dayjs(row.start).format("DD.MM.YY HH:mm")}}
-
-
- {{dayjs(row.end).format("DD.MM.YY HH:mm")}}
-
-
-
-
-
-
Hier wird aktuell noch gearbeitet
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/spaces/pages/inventory/spaces/[mode]/[[id]].vue b/spaces/pages/spaces/[mode]/[[id]].vue
similarity index 89%
rename from spaces/pages/inventory/spaces/[mode]/[[id]].vue
rename to spaces/pages/spaces/[mode]/[[id]].vue
index 1102b60..7e141a7 100644
--- a/spaces/pages/inventory/spaces/[mode]/[[id]].vue
+++ b/spaces/pages/spaces/[mode]/[[id]].vue
@@ -45,30 +45,6 @@ const setupPage = async () => {
}
-const createItem = async () => {
-
- if(!itemInfo.value.spaceNumber) itemInfo.value.spaceNumber = await numberRange.useNextNumber()
-
- const {data,error} = await supabase
- .from("spaces")
- .insert([itemInfo.value])
- .select()
-
- if(error) {
- console.log(error)
- } else {
- console.log(data[0])
- mode.value = "show"
- toast.add({title: "Lagerplatz erfolgreich erstellt"})
- await dataStore.fetchSpaces()
- router.push(`/inventory/spaces/show/${data[0].id}`)
-
-
-
- //setupPage()
- }
-}
-
const editItem = async () => {
router.push(`/inventory/spaces/edit/${currentItem.value.id}`)
setupPage()
@@ -208,13 +184,13 @@ setupPage()
Speichern
Erstellen
diff --git a/spaces/pages/inventory/spaces/index.vue b/spaces/pages/spaces/index.vue
similarity index 100%
rename from spaces/pages/inventory/spaces/index.vue
rename to spaces/pages/spaces/index.vue
diff --git a/spaces/pages/tasks/[mode]/[[id]].vue b/spaces/pages/tasks/[mode]/[[id]].vue
index a1765df..5b187db 100644
--- a/spaces/pages/tasks/[mode]/[[id]].vue
+++ b/spaces/pages/tasks/[mode]/[[id]].vue
@@ -26,10 +26,10 @@ const categories = ["Offen", "In Bearbeitung", "Dringed", "Erledigt"]
//Functions
const setupPage = () => {
if(mode.value === "show" || mode.value === "edit"){
- currentItem = dataStore.getTaskById(Number(useRoute().params.id))
+ currentItem.value = dataStore.getTaskById(Number(useRoute().params.id))
}
- if(mode.value === "edit") itemInfo.value = currentItem
+ if(mode.value === "edit") itemInfo.value = currentItem.value
if(mode.value === "create") {
let query = route.query
@@ -37,43 +37,17 @@ const setupPage = () => {
if(query.plant) itemInfo.value.plant = Number(query.plant)
}
-
-
-
}
-const createItem = async () => {
-
-
-
- /*const {data,error} = await supabase
- .from("tasks")
- .insert([itemInfo.value])
- .select()
-
- if(error) {
- console.log(error)
- } else {
- mode.value = "show"
- itemInfo.value = {
- id: 0,
- title: "",
- }
- //toast.add({title: "Aufgabe erfolgreich erstellt"})
- await dataStore.fetchTasks()
- //router.push(`/tasks/show/${data[0].id}`)
- setupPage()
- }*/
-}
const editItem = async () => {
- router.push(`/tasks/edit/${currentItem.id}`)
+ router.push(`/tasks/edit/${currentItem.value.id}`)
setupPage()
}
const cancelEditorCreate = () => {
- if(currentItem) {
- router.push(`/tasks/show/${currentItem.id}`)
+ if(currentItem.value) {
+ router.push(`/tasks/show/${currentItem.value.id}`)
} else {
router.push(`/tasks/`)
}
@@ -90,7 +64,7 @@ const updateItem = async () => {
}
- router.push(`/tasks/show/${currentItem.id}`)
+ router.push(`/tasks/show/${currentItem.value.id}`)
toast.add({title: "Aufgabe erfolgreich gespeichert"})
dataStore.fetchTasks()
}
@@ -111,8 +85,6 @@ setupPage()
{{currentItem.name}}
- {{currentItem}}
-
Beschreibung:
{{currentItem.description}}
@@ -222,7 +194,7 @@ setupPage()
Speichern
diff --git a/spaces/pages/users/[mode]/[[id]].vue b/spaces/pages/users/[mode]/[[id]].vue
index 6df1810..a4d2b19 100644
--- a/spaces/pages/users/[mode]/[[id]].vue
+++ b/spaces/pages/users/[mode]/[[id]].vue
@@ -85,32 +85,8 @@ const setupPage = () => {
}
itemInfo.value = currentItem
-
-
-
}
-/*const createItem = async () => {
- const {data,error} = await supabase
- .from("profiles")
- .insert([itemInfo.value])
- .select()
-
- if(error) {
- console.log(error)
- } else {
- mode.value = "show"
- itemInfo.value = {
- id: 0,
- title: "",
- }
- toast.add({title: "Job erfolgreich erstellt"})
- await dataStore.fetchJobs()
- router.push(`/jobs/show/${data[0].id}`)
- setupPage()
- }
-}*/
-
const editItem = async () => {
router.push(`/users/edit/${currentItem.id}`)
setupPage()
@@ -124,22 +100,7 @@ const cancelEditorCreate = () => {
}
}
-const updateItem = async () => {
- itemInfo.value.fullName = `${itemInfo.value.firstName} ${itemInfo.value.lastName}`
- const {error} = await supabase
- .from("profiles")
- .update(itemInfo.value)
- .eq('id',itemInfo.value.id)
- if(error) {
- console.log(error)
- }
-
-
- router.push(`/users/show/${currentItem.id}`)
- toast.add({title: "Mitarbeiter erfolgreich gespeichert"})
- dataStore.fetchProfiles()
-}
const getDuration = (time) => {
const dez = dayjs(time.end).diff(time.start,'hour',true).toFixed(2)
@@ -295,7 +256,7 @@ setupPage()
Speichern
@@ -463,16 +424,16 @@ setupPage()
Speichern
-
Erstellen
-
+ -->
Speichern
diff --git a/spaces/pages/vendors/[mode]/[[id]].vue b/spaces/pages/vendors/[mode]/[[id]].vue
index 7aa5253..7daec2e 100644
--- a/spaces/pages/vendors/[mode]/[[id]].vue
+++ b/spaces/pages/vendors/[mode]/[[id]].vue
@@ -41,25 +41,6 @@ const cancelEditorCreate = () => {
router.push(`/vendors/`)
}
-const updateItem = async () => {
- const {error} = await supabase
- .from("vendors")
- .update(itemInfo.value)
- .eq('id',itemInfo.value.id)
-
- if(error) {
- console.log(error)
- } else {
- toast.add({title: "Lieferant erfolgreich gespeichert"})
- router.push(`/vendors/show/${currentItem.value.id}`)
- dataStore.fetchVendors()
- }
-
-
-}
-
-
-
setupPage()
@@ -196,7 +177,7 @@ setupPage()
Speichern
diff --git a/spaces/stores/data.ts b/spaces/stores/data.ts
index 6c14464..581738e 100644
--- a/spaces/stores/data.ts
+++ b/spaces/stores/data.ts
@@ -15,43 +15,66 @@ export const useDataStore = defineStore('data', () => {
const dataTypes = {
tasks: {
label: "Aufgaben",
- labelSingle: "Aufgabe"
+ labelSingle: "Aufgabe",
+ redirect: true
},
customers: {
label: "Kunden",
- labelSingle: "Kunde"
+ labelSingle: "Kunde",
+ redirect:true
},
contacts: {
label: "Kontakte",
- labelSingle: "Kontakt"
+ labelSingle: "Kontakt",
+ redirect:true
},
contracts: {
label: "Verträge",
- labelSingle: "Vertrag"
+ labelSingle: "Vertrag",
+ redirect:true
},
absenceRequests: {
label: "Abwesenheitsanträge",
- labelSingle: "Abwesenheitsantrag"
+ labelSingle: "Abwesenheitsantrag",
+ redirect:true
},
plants: {
label: "Anlagen",
- labelSingle: "Anlage"
+ labelSingle: "Anlage",
+ redirect:true
},
products: {
label: "Artikel",
- labelSingle: "Artikel"
+ labelSingle: "Artikel",
+ redirect:true
},
projects: {
label: "Projekte",
- labelSingle: "Projekt"
+ labelSingle: "Projekt",
+ redirect:true
},
vehicles: {
label: "Fahrzeuge",
- labelSingle: "Fahrzeug"
+ labelSingle: "Fahrzeug",
+ redirect:true
},
vendors: {
label: "Lieferanten",
- labelSingle: "Lieferant"
+ labelSingle: "Lieferant",
+ redirect:true
+ },
+ messages: {
+ label: "Nachrichten",
+ labelSingle: "Nachricht"
+ },
+ spaces: {
+ label: "Lagerplätze",
+ labelSingle: "Lagerplatz",
+ redirect: true
+ },
+ users: {
+ label: "Benutzer",
+ labelSingle: "Benutzer"
}
}
@@ -172,6 +195,7 @@ export const useDataStore = defineStore('data', () => {
messages.value = []
}
+ //Realtime Update
const channelA = supabase
.channel('schema-db-changes')
.on(
@@ -181,10 +205,15 @@ export const useDataStore = defineStore('data', () => {
schema: 'public',
},
(payload) => {
- //console.log(payload)
- const c = payload.table + '.value.push(' + JSON.stringify(payload.new) + ')'
- eval(c)
+ console.log(payload)
+ if(payload.eventType === 'INSERT') {
+ const c = payload.table + '.value.push(' + JSON.stringify(payload.new) + ')'
+ eval(c)
+ } else if(payload.eventType === 'UPDATE'){
+ const c = payload.table + '.value[' + payload.table + '.value.findIndex(i => i.id === ' + JSON.stringify(payload.old.id) + ')] = ' + JSON.stringify(payload.new)
+ eval(c)
+ }
}
)
.subscribe()
@@ -200,7 +229,24 @@ export const useDataStore = defineStore('data', () => {
} else if (supabaseData) {
await eval( dataType + '.value.push(' + JSON.stringify(...supabaseData) + ')')
toast.add({title: `${dataTypes[dataType].labelSingle} hinzugefügt`})
- await router.push(`/${dataType}/show/${supabaseData[0].id}`)
+ if(dataTypes[dataType].redirect) await router.push(`/${dataType}/show/${supabaseData[0].id}`)
+ }
+ }
+
+ async function updateItem (dataType:string, data:Object) {
+ const {data:supabaseData,error: supabaseError} = await supabase
+ .from(dataType)
+ .update(data)
+ .eq('id',data.id)
+ .select()
+
+ if(supabaseError) {
+ console.log(supabaseError)
+ } else if(supabaseData) {
+ await eval(dataType + '.value[' + dataType + '.value.findIndex(i => i.id === ' + JSON.stringify(data.id) + ')] = ' + JSON.stringify(supabaseData[0]))
+ toast.add({title: `${dataTypes[dataType].labelSingle} gespeichert`})
+ if(dataTypes[dataType].redirect) await router.push(`/${dataType}/show/${supabaseData[0].id}`)
+
}
}
@@ -660,6 +706,7 @@ export const useDataStore = defineStore('data', () => {
messages,
//Functions
createNewItem,
+ updateItem,
fetchData,
clearStore,
fetchOwnTenant,