Tidying in Plants
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="p-3 mt-3 editor">
|
<div class="p-3 editor">
|
||||||
<div v-if="editor">
|
<div v-if="editor">
|
||||||
<InputGroup class="mb-3">
|
<InputGroup class="mb-3">
|
||||||
<UButton
|
<UButton
|
||||||
|
|||||||
@@ -9,66 +9,74 @@ definePageMeta({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
|
const supabase = useSupabaseClient()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
const id = ref(route.params.id ? route.params.id : null )
|
const id = ref(route.params.id ? route.params.id : null )
|
||||||
|
|
||||||
const editor = useEditor({
|
|
||||||
content: "<p>Hier kann deine Projektdokumentation stehen</p>",
|
|
||||||
extensions: [TiptapStarterKit],
|
|
||||||
});
|
|
||||||
|
|
||||||
let currentItem = ref(null)
|
|
||||||
|
|
||||||
//Working
|
//Working
|
||||||
const mode = ref(route.params.mode || "show")
|
const mode = ref(route.params.mode || "show")
|
||||||
const itemInfo = ref({})
|
const itemInfo = ref({
|
||||||
|
description: {
|
||||||
|
html: ""
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const tabItems = [
|
const tabItems = [
|
||||||
{
|
{
|
||||||
label: "Informationen"
|
label: "Informationen"
|
||||||
},{
|
|
||||||
label: "Logbuch"
|
|
||||||
},{
|
},{
|
||||||
label: "Projekte"
|
label: "Projekte"
|
||||||
},{
|
},{
|
||||||
label: "Aufgaben"
|
label: "Aufgaben"
|
||||||
},{
|
},{
|
||||||
label: "Dokumente"
|
label: "Dokumente"
|
||||||
},{
|
|
||||||
label: "Dokumentation"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
//Functions
|
//Functions
|
||||||
const setupPage = () => {
|
const setupPage = async () => {
|
||||||
if(mode.value === "show" || mode.value === "edit"){
|
if(mode.value === "show"){
|
||||||
currentItem.value = dataStore.getPlantById(Number(useRoute().params.id))
|
itemInfo.value = (await supabase.from("plants").select("*, customer(*)").eq("id",useRoute().params.id).single()).data
|
||||||
|
} else if(mode.value === "edit") {
|
||||||
|
itemInfo.value = (await supabase.from("plants").select().eq("id",useRoute().params.id).single()).data
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mode.value === "edit") itemInfo.value = currentItem.value
|
|
||||||
|
|
||||||
if(mode.value === "create") {
|
if(mode.value === "create") {
|
||||||
let query = route.query
|
let query = route.query
|
||||||
if(query.customer) itemInfo.value.customer = Number(query.customer)
|
if(query.customer) itemInfo.value.customer = Number(query.customer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const cancelEditorCreate = () => {
|
const contentChanged = (content) => {
|
||||||
if(currentItem.value) {
|
itemInfo.value.description.html = content.html
|
||||||
router.push(`/plants/show/${currentItem.value.id}`)
|
itemInfo.value.description.text = content.text
|
||||||
} else {
|
itemInfo.value.description.json = content.json
|
||||||
router.push(`/plants`)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setupPage()
|
setupPage()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<UDashboardNavbar :title="currentItem ? currentItem.name : (mode === 'create' ? 'Objekt erstellen' : 'Objekt bearbeiten')">
|
<UDashboardNavbar :title="itemInfo ? itemInfo.name : (mode === 'create' ? 'Objekt erstellen' : 'Objekt bearbeiten')">
|
||||||
|
<template #left>
|
||||||
|
<UButton
|
||||||
|
icon="i-heroicons-chevron-left"
|
||||||
|
variant="outline"
|
||||||
|
@click="router.push(`/plants`)"
|
||||||
|
>
|
||||||
|
Objekte
|
||||||
|
</UButton>
|
||||||
|
</template>
|
||||||
|
<template #center>
|
||||||
|
<h1
|
||||||
|
v-if="itemInfo"
|
||||||
|
:class="['text-xl','font-medium']"
|
||||||
|
>{{itemInfo ? `Objekt: ${itemInfo.name}` : (mode === 'create' ? 'Objekt erstellen' : 'Objekt bearbeiten')}}</h1>
|
||||||
|
</template>
|
||||||
<template #right>
|
<template #right>
|
||||||
<UButton
|
<UButton
|
||||||
v-if="mode === 'edit'"
|
v-if="mode === 'edit'"
|
||||||
@@ -83,7 +91,7 @@ setupPage()
|
|||||||
Erstellen
|
Erstellen
|
||||||
</UButton>
|
</UButton>
|
||||||
<UButton
|
<UButton
|
||||||
@click="cancelEditorCreate"
|
@click="router.push(itemInfo.id ? `/plants/show/${itemInfo.value.id}` : `/plants/`)"
|
||||||
color="red"
|
color="red"
|
||||||
class="ml-2"
|
class="ml-2"
|
||||||
v-if="mode === 'edit' || mode === 'create'"
|
v-if="mode === 'edit' || mode === 'create'"
|
||||||
@@ -92,44 +100,53 @@ setupPage()
|
|||||||
</UButton>
|
</UButton>
|
||||||
<UButton
|
<UButton
|
||||||
v-if="mode === 'show'"
|
v-if="mode === 'show'"
|
||||||
@click="router.push(`/plants/edit/${currentItem.id}`)"
|
@click="router.push(`/plants/edit/${itemInfo.id}`)"
|
||||||
>
|
>
|
||||||
Bearbeiten
|
Bearbeiten
|
||||||
</UButton>
|
</UButton>
|
||||||
</template>
|
</template>
|
||||||
</UDashboardNavbar>
|
</UDashboardNavbar>
|
||||||
|
|
||||||
<UTabs
|
<UTabs
|
||||||
:items="tabItems"
|
:items="tabItems"
|
||||||
v-if="mode === 'show'"
|
v-if="mode === 'show'"
|
||||||
class="p-5"
|
class="p-5"
|
||||||
>
|
>
|
||||||
<template #item="{item}">
|
<template #item="{item}">
|
||||||
<UCard class="mt-5">
|
<div v-if="item.label === 'Informationen'" class="flex flex-row mt-5">
|
||||||
<div v-if="item.label === 'Informationen'">
|
<UCard class="w-1/2 mr-5">
|
||||||
<div class="text-wrap">
|
<div class="text-wrap">
|
||||||
<p>Kunde: <nuxt-link :to="`/customers/show/${currentItem.customer}`">{{dataStore.getCustomerById(currentItem.customer).name}}</nuxt-link></p>
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td>Kunde:</td>
|
||||||
|
<td><nuxt-link v-if="itemInfo.customer" :to="`/customers/show/${itemInfo.customer.id}`">{{itemInfo.customer.name}}</nuxt-link></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-if="itemInfo.description.html">
|
||||||
|
<p>Notizen:</p>
|
||||||
|
<span v-html="itemInfo.description.html"></span>
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="item.label === 'Logbuch'">
|
</UCard>
|
||||||
|
<UCard class="w-1/2">
|
||||||
<HistoryDisplay
|
<HistoryDisplay
|
||||||
type="plant"
|
type="plant"
|
||||||
v-if="currentItem"
|
v-if="itemInfo"
|
||||||
:element-id="currentItem.id"
|
:element-id="itemInfo.id"
|
||||||
|
render-headline
|
||||||
/>
|
/>
|
||||||
|
</UCard>
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="item.label === 'Projekte'">
|
<div v-else-if="item.label === 'Projekte'">
|
||||||
<Toolbar>
|
<Toolbar>
|
||||||
<UButton
|
<UButton
|
||||||
@click="router.push(`/projects/create?plant=${currentItem.id}`)"
|
@click="router.push(`/projects/create?plant=${itemInfo.id}`)"
|
||||||
>
|
>
|
||||||
+ Projekt
|
+ Projekt
|
||||||
</UButton>
|
</UButton>
|
||||||
</Toolbar>
|
</Toolbar>
|
||||||
|
|
||||||
<UTable
|
<UTable
|
||||||
:rows="dataStore.getProjectsByPlantId(currentItem.id)"
|
:rows="dataStore.getProjectsByPlantId(itemInfo.id)"
|
||||||
:columns="[{key: 'name', label: 'Name'}]"
|
:columns="[{key: 'name', label: 'Name'}]"
|
||||||
@select="(row) => router.push(`/projects/show/${row.id}`)"
|
@select="(row) => router.push(`/projects/show/${row.id}`)"
|
||||||
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Keine zugehörigen Projekte' }"
|
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Keine zugehörigen Projekte' }"
|
||||||
@@ -141,13 +158,13 @@ setupPage()
|
|||||||
<div v-else-if="item.label === 'Aufgaben'">
|
<div v-else-if="item.label === 'Aufgaben'">
|
||||||
<Toolbar>
|
<Toolbar>
|
||||||
<UButton
|
<UButton
|
||||||
@click="router.push(`/tasks/create?plant=${currentItem.id}`)"
|
@click="router.push(`/tasks/create?plant=${itemInfo.id}`)"
|
||||||
>
|
>
|
||||||
+ Aufgabe
|
+ Aufgabe
|
||||||
</UButton>
|
</UButton>
|
||||||
</Toolbar>
|
</Toolbar>
|
||||||
<UTable
|
<UTable
|
||||||
:rows="dataStore.getTasksByPlantId(currentItem.id)"
|
:rows="dataStore.getTasksByPlantId(itemInfo.id)"
|
||||||
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Keine zugehörigen Aufgaben' }"
|
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Keine zugehörigen Aufgaben' }"
|
||||||
:columns="[{key: 'name', label: 'Name'},{key: 'categore', label: 'Kategorie'}]"
|
:columns="[{key: 'name', label: 'Name'},{key: 'categore', label: 'Kategorie'}]"
|
||||||
@select="(row) => router.push(`/tasks/show/${row.id}`)"
|
@select="(row) => router.push(`/tasks/show/${row.id}`)"
|
||||||
@@ -159,26 +176,16 @@ setupPage()
|
|||||||
<Toolbar>
|
<Toolbar>
|
||||||
<DocumentUpload
|
<DocumentUpload
|
||||||
type="plant"
|
type="plant"
|
||||||
:element-id="currentItem.id"
|
:element-id="itemInfo.id"
|
||||||
/>
|
/>
|
||||||
</Toolbar>
|
</Toolbar>
|
||||||
|
|
||||||
<DocumentList :documents="dataStore.getDocumentsByPlantId(currentItem.id)"/>
|
<DocumentList :documents="dataStore.getDocumentsByPlantId(itemInfo.id)"/>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div v-if="item.label === 'Dokumentation'">
|
|
||||||
|
|
||||||
<Editor/>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</UCard>
|
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
</UTabs>
|
</UTabs>
|
||||||
|
|
||||||
<div v-if="currentItem && mode == 'show'">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<UForm
|
<UForm
|
||||||
v-else-if="mode === 'edit' || mode === 'create'"
|
v-else-if="mode === 'edit' || mode === 'create'"
|
||||||
@@ -208,6 +215,16 @@ setupPage()
|
|||||||
</template>
|
</template>
|
||||||
</USelectMenu>
|
</USelectMenu>
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
|
<UFormGroup
|
||||||
|
label="Notizen:"
|
||||||
|
>
|
||||||
|
<Tiptap
|
||||||
|
v-if="itemInfo.description"
|
||||||
|
@updateContent="contentChanged"
|
||||||
|
:preloadedContent="itemInfo.description.html"
|
||||||
|
/>
|
||||||
|
</UFormGroup>
|
||||||
|
|
||||||
</UForm>
|
</UForm>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<UDashboardNavbar title="Objekte" >
|
<UDashboardNavbar title="Objekte" :badge="filteredRows.length" >
|
||||||
<template #right>
|
<template #right>
|
||||||
<UInput
|
<UInput
|
||||||
id="searchinput"
|
id="searchinput"
|
||||||
@@ -105,7 +105,6 @@ const selectedItem = ref(0)
|
|||||||
|
|
||||||
const setupPage = async () => {
|
const setupPage = async () => {
|
||||||
items.value = await useSupabaseSelect("plants","*, customer(id,name)")
|
items.value = await useSupabaseSelect("plants","*, customer(id,name)")
|
||||||
console.log(items.value)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setupPage()
|
setupPage()
|
||||||
|
|||||||
Reference in New Issue
Block a user