Some Changes

This commit is contained in:
2024-11-20 21:10:20 +01:00
parent fbf1f78d64
commit 818bfd5b1c

View File

@@ -159,9 +159,12 @@ const createProject = async () => {
} }
const changeActivePhase = async (key) => { const changeActivePhase = async (key) => {
console.log(key)
let item = await useSupabaseSelectSingle("projects",itemInfo.value.id,'*') let item = await useSupabaseSelectSingle("projects",itemInfo.value.id,'*')
console.log(key)
let phaseLabel = ""
item.phases = item.phases.map(p => { item.phases = item.phases.map(p => {
if(p.active) p.active = false if(p.active) p.active = false
@@ -169,15 +172,23 @@ const changeActivePhase = async (key) => {
p.active = true p.active = true
p.activated_at = dayjs().format() p.activated_at = dayjs().format()
p.activated_by = dataStore.activeProfile.id p.activated_by = dataStore.activeProfile.id
phaseLabel = p.label
} }
return p return p
}) })
console.log(item.phases) console.log(item.phases)
await dataStore.updateItem("projects", item) await supabase.from("projects").update({phases: item.phases}).eq("id",item.id)
const {error} = await supabase.from("historyitems").insert({
createdBy: dataStore.activeProfile.id,
tenant: dataStore.currentTenant,
text: `Aktive Phase zu "${phaseLabel}" gewechselt`,
project: item.id
})
console.log(error)
setupPage() setupPage()
} }
@@ -260,153 +271,153 @@ const renderedPhases = computed(() => {
</UButton> </UButton>
</template> </template>
</UDashboardNavbar> </UDashboardNavbar>
<UTabs <UDashboardPanelContent>
:items="tabItems" <UTabs
v-if="itemInfo.id && mode == 'show'" :items="tabItems"
class="p-5" v-if="itemInfo.id && mode == 'show'"
v-model="openTab" v-model="openTab"
> >
<template #item="{ item }"> <template #item="{ item }">
<div v-if="item.key === 'information'" class="flex flex-row"> <div v-if="item.key === 'information'" class="flex flex-row">
<div class="w-1/2 mr-3"> <div class="w-1/2 mr-3">
<UCard class="mt-5"> <UCard class="mt-5">
<div class="text-wrap"> <div class="text-wrap">
<p>Kunde: <nuxt-link :to="`/customers/show/${itemInfo.customer.id}`">{{itemInfo.customer.name}}</nuxt-link></p> <p>Kunde: <nuxt-link :to="`/customers/show/${itemInfo.customer.id}`">{{itemInfo.customer.name}}</nuxt-link></p>
<p>Objekt: <nuxt-link v-if="itemInfo.plant" :to="`/plants/show/${itemInfo.plant.id}`">{{itemInfo.plant ? itemInfo.plant.name : ""}}</nuxt-link><span v-else>-</span></p> <p>Objekt: <nuxt-link v-if="itemInfo.plant" :to="`/plants/show/${itemInfo.plant.id}`">{{itemInfo.plant ? itemInfo.plant.name : ""}}</nuxt-link><span v-else>-</span></p>
<p class="">Notizen: {{itemInfo.notes}}</p> <p class="">Notizen: {{itemInfo.notes}}</p>
</div> </div>
</UCard> </UCard>
<UCard class="mt-3"> <UCard class="mt-3">
<h1 class="font-bold text-lg mb-3">Beteiligte Benutzer:</h1> <h1 class="font-bold text-lg mb-3">Beteiligte Benutzer:</h1>
<UAlert <UAlert
v-for="projectUser in itemInfo.users" v-for="projectUser in itemInfo.users"
:avatar="{ alt: dataStore.getProfileById(projectUser).fullName }" :avatar="{ alt: dataStore.getProfileById(projectUser).fullName }"
:title="dataStore.getProfileById(projectUser).fullName" :title="dataStore.getProfileById(projectUser).fullName"
class="mb-3" class="mb-3"
/>
</UCard>
</div>
<div class="w-1/2">
<UCard class="mt-5">
<HistoryDisplay
type="project"
v-if="itemInfo"
:element-id="itemInfo.id"
render-headline
/>
</UCard>
</div>
/>
</UCard>
</div> </div>
<div class="w-1/2"> <div v-if="item.key === 'phases'" class="space-y-3">
<UCard class="mt-5"> <UCard class="mt-5">
<HistoryDisplay <UAccordion
type="project" :items="renderedPhases"
v-if="itemInfo" >
:element-id="itemInfo.id" <template #default="{item,index,open}">
render-headline <UButton
/> variant="ghost"
</UCard> :color="item.active ? 'primary' : 'white'"
</div> class="mb-1"
:disabled="true"
>
<template #leading>
<div class="w-6 h-6 flex items-center justify-center -my-1">
<UIcon :name="item.icon" class="w-4 h-4 " />
</div>
</template>
<span class="truncate"> {{item.label}}</span>
<template #trailing>
<UIcon
name="i-heroicons-chevron-right-20-solid"
class="w-5 h-5 ms-auto transform transition-transform duration-200"
:class="[open && 'rotate-90']"
/>
</template>
</div> </UButton>
<div v-if="item.key === 'phases'" class="space-y-3"> </template>
<UCard class="mt-5"> <template #item="{item, index}">
<UAccordion <UCard class="mx-5">
:items="renderedPhases" <template #header>
> <span class="text-black">{{item.label}}</span>
<template #default="{item,index,open}"> </template>
<UButton <InputGroup>
variant="ghost" <UButton
:color="item.active ? 'primary' : 'white'" v-if="!item.activated_at && index !== 0 "
class="mb-1" @click="changeActivePhase(item.key)"
:disabled="true" >
> Phase aktivieren
<template #leading> </UButton>
<div class="w-6 h-6 flex items-center justify-center -my-1"> <UButton
<UIcon :name="item.icon" class="w-4 h-4 " /> v-if="item.active"
v-for="button in item.quickactions"
@click="router.push(`${button.link}&customer=${itemInfo.customer.id}&project=${itemInfo.id}`)"
>
{{button.label}}
</UButton>
</InputGroup>
<div>
<p v-if="item.activated_at" class="text-black">Aktiviert am: {{dayjs(item.activated_at).format("DD.MM.YY HH:mm")}} Uhr</p>
<p v-if="item.activated_by" class="text-black">Aktiviert durch: {{dataStore.getProfileById(item.activated_by).fullName}}</p>
<p v-if="item.description" class="text-black">Beschreibung: {{item.description}}</p>
</div> </div>
</template> </UCard>
<span class="truncate"> {{item.label}}</span>
<template #trailing>
<UIcon
name="i-heroicons-chevron-right-20-solid"
class="w-5 h-5 ms-auto transform transition-transform duration-200"
:class="[open && 'rotate-90']"
/>
</template>
</template>
</UAccordion>
</UCard>
</div>
<div v-if="item.key === 'tasks'" class="space-y-3">
<UCard class="mt-5">
<Toolbar>
<UButton
@click="router.push(`/tasks/create?project=${itemInfo.id}`)"
>
+ Aufgabe
</UButton> </UButton>
</template> </Toolbar>
<template #item="{item, index}">
<UCard class="mx-5">
<template #header>
<span class="text-black">{{item.label}}</span>
</template>
<InputGroup>
<UButton
v-if="!item.activated_at && index !== 0 "
@click="changeActivePhase(item.key)"
>
Phase aktivieren
</UButton>
<UButton
v-if="item.active"
v-for="button in item.quickactions"
@click="router.push(`${button.link}&customer=${itemInfo.customer.id}&project=${itemInfo.id}`)"
>
{{button.label}}
</UButton>
</InputGroup>
<div> <UTable
<p v-if="item.activated_at" class="text-black">Aktiviert am: {{dayjs(item.activated_at).format("DD.MM.YY HH:mm")}} Uhr</p> :rows="dataStore.getTasksByProjectId(itemInfo.id)"
<p v-if="item.activated_by" class="text-black">Aktiviert durch: {{dataStore.getProfileById(item.activated_by).fullName}}</p> :columns="[{key: 'name',label: 'Name'},{key: 'categorie',label: 'Kategorie'},{key: 'user',label: 'Benutzer'}]"
<p v-if="item.description" class="text-black">Beschreibung: {{item.description}}</p> @select="(row) => router.push(`/tasks/show/${row.id}`)"
</div> :empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Keine zugehörigen Aufgaben' }"
</UCard>
</template>
</UAccordion>
</UCard>
</div>
<div v-if="item.key === 'tasks'" class="space-y-3">
<UCard class="mt-5">
<Toolbar>
<UButton
@click="router.push(`/tasks/create?project=${itemInfo.id}`)"
> >
+ Aufgabe <template #user-data="{row}">
</UButton> {{dataStore.profiles.find(i => i.id === row.user) ? dataStore.profiles.find(i => i.id === row.user).fullName : ""}}
</Toolbar> </template>
</UTable>
<UTable </UCard>
:rows="dataStore.getTasksByProjectId(itemInfo.id)"
:columns="[{key: 'name',label: 'Name'},{key: 'categorie',label: 'Kategorie'},{key: 'user',label: 'Benutzer'}]"
@select="(row) => router.push(`/tasks/show/${row.id}`)"
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Keine zugehörigen Aufgaben' }"
>
<template #user-data="{row}">
{{dataStore.profiles.find(i => i.id === row.user) ? dataStore.profiles.find(i => i.id === row.user).fullName : ""}}
</template>
</UTable>
</UCard>
</div> </div>
<div v-else-if="item.key === 'documents'" class="space-y-3"> <div v-else-if="item.key === 'documents'" class="space-y-3">
<UCard class="mt-5"> <UCard class="mt-5">
<Toolbar> <Toolbar>
<DocumentUpload <DocumentUpload
type="project" type="project"
:element-id="itemInfo.id" :element-id="itemInfo.id"
/> />
<UButton <UButton
@click="router.push(`/createDocument/edit?project=${itemInfo.id}&customer=${itemInfo.customer.id}`)" @click="router.push(`/createDocument/edit?project=${itemInfo.id}&customer=${itemInfo.customer.id}`)"
> >
+ Dokument + Dokument
</UButton> </UButton>
</Toolbar> </Toolbar>
<UTable <UTable
:rows="dataStore.getCreatedDocumentsByProject(itemInfo.id)" :rows="dataStore.getCreatedDocumentsByProject(itemInfo.id)"
:columns="[ :columns="[
{ {
label: 'Typ', label: 'Typ',
key: 'type' key: 'type'
@@ -422,219 +433,221 @@ const renderedPhases = computed(() => {
} }
]" ]"
@select="(row) => row.state === 'Entwurf' ? router.push(`/createDocument/edit/${row.id}`) : router.push(`/createDocument/show/${row.id}`)" @select="(row) => row.state === 'Entwurf' ? router.push(`/createDocument/edit/${row.id}`) : router.push(`/createDocument/show/${row.id}`)"
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Keine zugehörigen erstellten Dokumente' }" :empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Keine zugehörigen erstellten Dokumente' }"
>
<template #type-data="{row}">
<span v-if="row.type === 'invoices'">Rechnung</span>
<span v-if="row.type === 'quotes'">Angebot</span>
<span v-if="row.type === 'deliveryNotes'">Lieferschein</span>
</template>
<template #createdBy-data="{row}">
{{dataStore.getProfileById(row.createdBy).fullName}}
</template>
</UTable>
<DocumentList :documents="dataStore.getDocumentsByProjectId(itemInfo.id)"/>
</UCard>
</div>
<div v-else-if="item.key === 'timetracking'" class="space-y-3">
<UCard class="mt-5">
Projekt Zeit: {{String(projectHours()).replace(".",",")}} Stunden
<UTable
:rows="dataStore.getTimesByProjectId(itemInfo.id)"
:columns="timeTableRows"
:empty-state="{ icon: 'i-heroicons-clock', label: 'Noch keine Zeiten in diesem Projekt' }"
>
<template #user-data="{row}">
{{dataStore.profiles.find(profile => profile.id === row.user) ? dataStore.profiles.find(profile => profile.id === row.user).fullName : row.user }}
</template>
<template #duration-data="{row}">
{{(row.start && row.end) ? `${String(dayjs(row.end).diff(row.start,'hour',true).toFixed(2)).replace(".",",")} h` : ""}}
</template>
<template #start-data="{row}">
{{dayjs(row.start).format("DD.MM.YY HH:mm")}}
</template>
<template #end-data="{row}">
{{dayjs(row.end).format("DD.MM.YY HH:mm")}}
</template>
</UTable>
</UCard>
</div>
<div v-else-if="item.key === 'events'" class="space-y-3">
<UCard class="mt-5">
<Toolbar>
<UButton
@click="router.push(`/events/edit`)"
> >
+ Termin <template #type-data="{row}">
</UButton> <span v-if="row.type === 'invoices'">Rechnung</span>
</Toolbar> <span v-if="row.type === 'quotes'">Angebot</span>
<UTable <span v-if="row.type === 'deliveryNotes'">Lieferschein</span>
:rows="dataStore.getEventsByProjectId(itemInfo.id)" </template>
@select="(i) => router.push(`/events/show/${i.id}`)" <template #createdBy-data="{row}">
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Keine Termine anzuzeigen' }" {{dataStore.getProfileById(row.createdBy).fullName}}
:columns="[{key:'title',label:'Titel'},{key:'start',label:'Start'},{key:'end',label:'Ende'},{key:'type',label:'Typ'},{key:'resources',label:'Resourcen'}]" </template>
> </UTable>
<template #start-data="{row}">
{{dayjs(row.start).format("DD.MM.YY HH:mm")}}
</template>
<template #end-data="{row}">
{{dayjs(row.end).format("DD.MM.YY HH:mm")}}
</template>
<template #resources-data="{row}">
{{row.resources.map(i => i.title).join(", ")}}
</template>
</UTable>
</UCard>
</div>
<div v-else-if="item.key === 'material'" class="space-y-3">
</div> <DocumentList :documents="dataStore.getDocumentsByProjectId(itemInfo.id)"/>
</UCard>
</template>
</UTabs>
<UForm v-else-if="mode === 'edit' || mode === 'create'" class="p-5" >
<UFormGroup
label="Name:"
>
<UInput
v-model="itemInfo.name"
/>
</UFormGroup>
<UFormGroup </div>
label="Projektnummer:" <div v-else-if="item.key === 'timetracking'" class="space-y-3">
> <UCard class="mt-5">
<UInput Projekt Zeit: {{String(projectHours()).replace(".",",")}} Stunden
v-model="itemInfo.projectNumber" <UTable
placeholder="Leer lassen für automatisch generierte Nummer" :rows="dataStore.getTimesByProjectId(itemInfo.id)"
/> :columns="timeTableRows"
</UFormGroup> :empty-state="{ icon: 'i-heroicons-clock', label: 'Noch keine Zeiten in diesem Projekt' }"
>
<template #user-data="{row}">
{{dataStore.profiles.find(profile => profile.id === row.user) ? dataStore.profiles.find(profile => profile.id === row.user).fullName : row.user }}
</template>
<template #duration-data="{row}">
{{(row.start && row.end) ? `${String(dayjs(row.end).diff(row.start,'hour',true).toFixed(2)).replace(".",",")} h` : ""}}
</template>
<template #start-data="{row}">
{{dayjs(row.start).format("DD.MM.YY HH:mm")}}
</template>
<template #end-data="{row}">
{{dayjs(row.end).format("DD.MM.YY HH:mm")}}
</template>
<UFormGroup </UTable>
label="Objekt:" </UCard>
>
<USelectMenu
v-model="itemInfo.plant" </div>
:options="itemInfo.customer ? plants.filter(i => i.customer === itemInfo.customer) : plants" <div v-else-if="item.key === 'events'" class="space-y-3">
option-attribute="name" <UCard class="mt-5">
value-attribute="id" <Toolbar>
searchable <UButton
:search-attributes="['name']" @click="router.push(`/events/edit`)"
@change="itemInfo.customer = plants.find(i => i.id === itemInfo.plant).customer, >
+ Termin
</UButton>
</Toolbar>
<UTable
:rows="dataStore.getEventsByProjectId(itemInfo.id)"
@select="(i) => router.push(`/events/show/${i.id}`)"
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Keine Termine anzuzeigen' }"
:columns="[{key:'title',label:'Titel'},{key:'start',label:'Start'},{key:'end',label:'Ende'},{key:'type',label:'Typ'},{key:'resources',label:'Resourcen'}]"
>
<template #start-data="{row}">
{{dayjs(row.start).format("DD.MM.YY HH:mm")}}
</template>
<template #end-data="{row}">
{{dayjs(row.end).format("DD.MM.YY HH:mm")}}
</template>
<template #resources-data="{row}">
{{row.resources.map(i => i.title).join(", ")}}
</template>
</UTable>
</UCard>
</div>
<div v-else-if="item.key === 'material'" class="space-y-3">
</div>
</template>
</UTabs>
<UForm v-else-if="mode === 'edit' || mode === 'create'" >
<UFormGroup
label="Name:"
>
<UInput
v-model="itemInfo.name"
/>
</UFormGroup>
<UFormGroup
label="Projektnummer:"
>
<UInput
v-model="itemInfo.projectNumber"
placeholder="Leer lassen für automatisch generierte Nummer"
/>
</UFormGroup>
<UFormGroup
label="Objekt:"
>
<USelectMenu
v-model="itemInfo.plant"
:options="itemInfo.customer ? plants.filter(i => i.customer === itemInfo.customer) : plants"
option-attribute="name"
value-attribute="id"
searchable
:search-attributes="['name']"
@change="itemInfo.customer = plants.find(i => i.id === itemInfo.plant).customer,
disableCustomerSelection = true" disableCustomerSelection = true"
>
<template #label>
{{plants.find(i => i.id === itemInfo.plant) ? plants.find(i => i.id === itemInfo.plant).name : "Objekt auswählen"}}
</template>
</USelectMenu>
</UFormGroup>
<UFormGroup
label="Vertrag:"
> >
<template #label> <USelectMenu
{{plants.find(i => i.id === itemInfo.plant) ? plants.find(i => i.id === itemInfo.plant).name : "Objekt auswählen"}} v-model="itemInfo.contract"
</template> :options="itemInfo.customer ? contracts.filter(i => i.customer === itemInfo.customer) : contracts"
</USelectMenu> option-attribute="name"
</UFormGroup> value-attribute="id"
<UFormGroup searchable
label="Vertrag:" :search-attributes="['name']"
> @change="itemInfo.customer = contracts.find(i => i.id === itemInfo.contract).customer,
<USelectMenu
v-model="itemInfo.contract"
:options="itemInfo.customer ? contracts.filter(i => i.customer === itemInfo.customer) : contracts"
option-attribute="name"
value-attribute="id"
searchable
:search-attributes="['name']"
@change="itemInfo.customer = contracts.find(i => i.id === itemInfo.contract).customer,
disableCustomerSelection = true" disableCustomerSelection = true"
>
<template #label>
{{contracts.find(i => i.id === itemInfo.contract) ? contracts.find(i => i.id === itemInfo.contract).name : "Vertrag auswählen"}}
</template>
</USelectMenu>
</UFormGroup>
<UFormGroup
label="Kundennummer:"
> >
<template #label> <USelectMenu
{{contracts.find(i => i.id === itemInfo.contract) ? contracts.find(i => i.id === itemInfo.contract).name : "Vertrag auswählen"}} v-model="itemInfo.customer"
</template> :options="dataStore.customers"
</USelectMenu> option-attribute="name"
</UFormGroup> value-attribute="id"
searchable
:search-attributes="['name']"
:disabled="disableCustomerSelection"
>
<template #label>
{{dataStore.getCustomerById(itemInfo.customer) ? dataStore.getCustomerById(itemInfo.customer).name : "Kunde auswählen"}}
</template>
</USelectMenu>
</UFormGroup>
<UFormGroup <UFormGroup
label="Kundennummer:" label="Typ:"
>
<USelectMenu
v-model="itemInfo.customer"
:options="dataStore.customers"
option-attribute="name"
value-attribute="id"
searchable
:search-attributes="['name']"
:disabled="disableCustomerSelection"
> >
<template #label> <USelectMenu
{{dataStore.getCustomerById(itemInfo.customer) ? dataStore.getCustomerById(itemInfo.customer).name : "Kunde auswählen"}} v-model="itemInfo.projecttype"
</template> :options="projecttypes"
</USelectMenu> option-attribute="name"
</UFormGroup> value-attribute="id"
searchable
:search-attributes="['label']"
:disabled="oldItemInfo.projecttype"
>
</USelectMenu>
</UFormGroup>
<UFormGroup <UFormGroup
label="Typ:" label="Gewerk:"
>
<USelectMenu
v-model="itemInfo.projecttype"
:options="projecttypes"
option-attribute="name"
value-attribute="id"
searchable
:search-attributes="['label']"
:disabled="oldItemInfo.projecttype"
> >
</USelectMenu> <USelectMenu
</UFormGroup> v-model="itemInfo.measure"
:options="dataStore.getMeasures"
option-attribute="name"
value-attribute="short"
searchable
:search-attributes="['name']"
>
<UFormGroup </USelectMenu>
label="Gewerk:" </UFormGroup>
>
<USelectMenu
v-model="itemInfo.measure" <UFormGroup
:options="dataStore.getMeasures" label="Beteiligte Benutzer:"
option-attribute="name"
value-attribute="short"
searchable
:search-attributes="['name']"
> >
<USelectMenu
v-model="itemInfo.users"
:options="dataStore.profiles"
option-attribute="fullName"
value-attribute="id"
searchable
multiple
:search-attributes="['fullName']"
>
<template #label>
{{itemInfo.users.length > 0 ? itemInfo.users.map(i => dataStore.getProfileById(i).fullName).join(", ") : "Kein Benutzer ausgewählt"}}
</template>
</USelectMenu>
</UFormGroup>
</USelectMenu> <UFormGroup
</UFormGroup> label="Notizen:"
<UFormGroup
label="Beteiligte Benutzer:"
>
<USelectMenu
v-model="itemInfo.users"
:options="dataStore.profiles"
option-attribute="fullName"
value-attribute="id"
searchable
multiple
:search-attributes="['fullName']"
> >
<template #label> <UTextarea
{{itemInfo.users.length > 0 ? itemInfo.users.map(i => dataStore.getProfileById(i).fullName).join(", ") : "Kein Benutzer ausgewählt"}} v-model="itemInfo.notes"
</template> />
</USelectMenu> </UFormGroup>
</UFormGroup> </UForm>
</UDashboardPanelContent>
<UFormGroup
label="Notizen:"
>
<UTextarea
v-model="itemInfo.notes"
/>
</UFormGroup>
</UForm>
</template> </template>