Restructured Update Process Into Store
This commit is contained in:
@@ -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}}
|
||||
</template>
|
||||
|
||||
{{currentItem}}<br>
|
||||
|
||||
|
||||
Beschreibung:<br>
|
||||
{{currentItem.description}}<br>
|
||||
@@ -222,7 +194,7 @@ setupPage()
|
||||
<template #footer>
|
||||
<UButton
|
||||
v-if="mode == 'edit'"
|
||||
@click="updateItem"
|
||||
@click="dataStore.updateItem('tasks',itemInfo)"
|
||||
>
|
||||
Speichern
|
||||
</UButton>
|
||||
|
||||
Reference in New Issue
Block a user