Cahnges in Projektzeiten and Naming

This commit is contained in:
2025-06-07 16:33:57 +02:00
parent bab0187467
commit 96cd94d77f
4 changed files with 40 additions and 25 deletions

View File

@@ -125,7 +125,7 @@ const links = computed(() => {
icon: "i-heroicons-user-group", icon: "i-heroicons-user-group",
children: [ children: [
... profileStore.ownTenant.features.timeTracking ? [{ ... profileStore.ownTenant.features.timeTracking ? [{
label: "Zeiterfassung", label: "Projektzeiten",
to: "/times", to: "/times",
icon: "i-heroicons-clock" icon: "i-heroicons-clock"
}] : [], }] : [],

View File

@@ -43,9 +43,9 @@ const startTime = async () => {
.select() .select()
if(error) { if(error) {
console.log(error) console.log(error)
toast.add({title: "Fehler beim starten der Zeit",color:"rose"}) toast.add({title: "Fehler beim starten der Projektzeit",color:"rose"})
} else if(data) { } else if(data) {
toast.add({title: "Zeit erfolgreich gestartet"}) toast.add({title: "Projektzeit erfolgreich gestartet"})
runningTimeInfo.value = data[0] runningTimeInfo.value = data[0]
//console.log(runningTimeInfo.value) //console.log(runningTimeInfo.value)
} }
@@ -63,11 +63,11 @@ const stopStartedTime = async () => {
if(error) { if(error) {
console.log(error) console.log(error)
let errorId = await useError().logError(`${status} - ${JSON.stringify(error)}`) let errorId = await useError().logError(`${status} - ${JSON.stringify(error)}`)
toast.add({title: errorId ? `Fehler beim stoppen der Zeit (Fehler ID: ${errorId})` : `Fehler beim stoppen der Zeit`,color:"rose"}) toast.add({title: errorId ? `Fehler beim stoppen der Projektzeit (Fehler ID: ${errorId})` : `Fehler beim stoppen der Projektzeit`,color:"rose"})
} else { } else {
toast.add({title: "Zeit erfolgreich gestoppt"}) toast.add({title: "Projektzeit erfolgreich gestoppt"})
runningTimeInfo.value = {} runningTimeInfo.value = {}
} }
} }
@@ -111,7 +111,7 @@ const stopStartedTime = async () => {
</UButton> </UButton>
</div> </div>
<div v-else> <div v-else>
<p>Keine Zeit gestartet</p> <p>Keine Projektzeit gestartet</p>
<UButton <UButton
class="mt-3" class="mt-3"
@click="startTime" @click="startTime"

View File

@@ -39,15 +39,17 @@
<display-projects-in-phases/> <display-projects-in-phases/>
</UDashboardCard> </UDashboardCard>
<UDashboardCard <UDashboardCard
title="Anwesenheiten" title="Anwesende"
> >
<display-present-profiles/> <display-present-profiles/>
</UDashboardCard> </UDashboardCard>
<UDashboardCard <UDashboardCard
title="Projektzeiten"
> >
<display-running-time/> <display-running-time/>
</UDashboardCard> </UDashboardCard>
<UDashboardCard <UDashboardCard
title="Anwesenheiten"
> >
<display-running-working-time/> <display-running-working-time/>
</UDashboardCard> </UDashboardCard>

View File

@@ -35,8 +35,11 @@ const configTimeMode = ref("create")
const platform = ref("default") const platform = ref("default")
const projects = ref([])
const setup = async () => { const setup = async () => {
times.value = await useSupabaseSelect("times","*, profile(*), project(id, name)") times.value = await useSupabaseSelect("times","*, profile(*), project(id, name)")
projects.value = await useSupabaseSelect("projects","*")
if(await useCapacitor().getIsPhone()) { if(await useCapacitor().getIsPhone()) {
platform.value = "mobile" platform.value = "mobile"
@@ -179,10 +182,27 @@ const createTime = async () => {
} }
} }
const openTime = (row) => {
itemInfo.value = row
itemInfo.value.project = itemInfo.value.project.id
itemInfo.value.profile = itemInfo.value.profile.id
showConfigTimeModal.value = true
configTimeMode.value = "edit"
}
const updateTime = async () => { const updateTime = async () => {
let data = itemInfo.value
data.profile = data.profile.id
data.project = data.project.id
const {error} = await supabase const {error} = await supabase
.from("times") .from("times")
.update(itemInfo.value) .update(data)
.eq('id',itemInfo.value.id) .eq('id',itemInfo.value.id)
if(error) { if(error) {
@@ -191,7 +211,7 @@ const updateTime = async () => {
toast.add({title: "Zeit erfolgreich gespeichert"}) toast.add({title: "Zeit erfolgreich gespeichert"})
showConfigTimeModal.value = false showConfigTimeModal.value = false
await dataStore.fetchTimes() setup()
} }
const format = (date) => { const format = (date) => {
@@ -230,7 +250,7 @@ const getSecondInfo = (item) => {
</script> </script>
<template> <template>
<UDashboardNavbar title="Zeiterfassung"> <UDashboardNavbar title="Projektzeiten">
<template #toggle> <template #toggle>
<div v-if="platform === 'mobile'"></div> <div v-if="platform === 'mobile'"></div>
</template> </template>
@@ -317,7 +337,7 @@ const getSecondInfo = (item) => {
> >
<UCard> <UCard>
<template #header> <template #header>
Zeiteintrag {{configTimeMode === 'create' ? "erstellen" : "bearbeiten"}} Projektzeit {{configTimeMode === 'create' ? "erstellen" : "bearbeiten"}}
</template> </template>
<UFormGroup <UFormGroup
label="Start:" label="Start:"
@@ -325,7 +345,7 @@ const getSecondInfo = (item) => {
<UPopover :popper="{ placement: 'bottom-start' }"> <UPopover :popper="{ placement: 'bottom-start' }">
<UButton <UButton
icon="i-heroicons-calendar-days-20-solid" icon="i-heroicons-calendar-days-20-solid"
:label="itemInfo.startDate ? dayjs(itemInfo.startDate).format('DD.MM.YYYY') : 'Datum auswählen'" :label="itemInfo.startDate ? dayjs(itemInfo.startDate).format('DD.MM.YYYY HH:mm') : 'Datum auswählen'"
variant="outline" variant="outline"
/> />
@@ -340,7 +360,7 @@ const getSecondInfo = (item) => {
<UPopover :popper="{ placement: 'bottom-start' }"> <UPopover :popper="{ placement: 'bottom-start' }">
<UButton <UButton
icon="i-heroicons-calendar-days-20-solid" icon="i-heroicons-calendar-days-20-solid"
:label="itemInfo.endDate ? dayjs(itemInfo.endDate).format('DD.MM.YYYY') : 'Datum auswählen'" :label="itemInfo.endDate ? dayjs(itemInfo.endDate).format('DD.MM.YYYY HH:mm') : 'Datum auswählen'"
variant="outline" variant="outline"
/> />
@@ -354,13 +374,12 @@ const getSecondInfo = (item) => {
> >
<USelectMenu <USelectMenu
:options="profileStore.profiles" :options="profileStore.profiles"
v-model="itemInfo.user" v-model="itemInfo.profile"
option-attribute="fullName" option-attribute="fullName"
value-attribute="id" value-attribute="id"
:disabled="(configTimeMode === 'create' ? false : itemInfo.state !== 'Entwurf') || (!dataStore.hasRight('createTime') || !useRole().hasRight('createOwnTime'))"
> >
<template #label> <template #label>
{{profileStore.profiles.find(profile => profile.id === itemInfo.user) ? profileStore.profiles.find(profile => profile.id === itemInfo.user).fullName : "Benutzer auswählen"}} {{profileStore.profiles.find(profile => profile.id === itemInfo.profile) ? profileStore.profiles.find(profile => profile.id === itemInfo.profile).fullName : "Benutzer auswählen"}}
</template> </template>
</USelectMenu> </USelectMenu>
</UFormGroup> </UFormGroup>
@@ -368,14 +387,13 @@ const getSecondInfo = (item) => {
label="Projekt:" label="Projekt:"
> >
<USelectMenu <USelectMenu
:options="dataStore.projects" :options="projects"
v-model="itemInfo.project" v-model="itemInfo.project"
option-attribute="name" option-attribute="name"
value-attribute="id" value-attribute="id"
searchable searchable
searchable-placeholder="Suche..." searchable-placeholder="Suche..."
:search-attributes="['name']" :search-attributes="['name']"
:disabled="configTimeMode === 'create' ? false : itemInfo.state !== 'Entwurf'"
> >
<template #label> <template #label>
{{dataStore.projects.find(project => project.id === itemInfo.project) ? dataStore.projects.find(project => project.id === itemInfo.project).name : "Projekt auswählen"}} {{dataStore.projects.find(project => project.id === itemInfo.project) ? dataStore.projects.find(project => project.id === itemInfo.project).name : "Projekt auswählen"}}
@@ -390,7 +408,6 @@ const getSecondInfo = (item) => {
:options="timeTypes" :options="timeTypes"
option-attribute="label" option-attribute="label"
value-attribute="label" value-attribute="label"
:disabled="configTimeMode === 'create' ? false : itemInfo.state !== 'Entwurf'"
> >
<template #label> <template #label>
{{itemInfo.type ? itemInfo.type : "Kategorie auswählen"}} {{itemInfo.type ? itemInfo.type : "Kategorie auswählen"}}
@@ -402,12 +419,11 @@ const getSecondInfo = (item) => {
> >
<UTextarea <UTextarea
v-model="itemInfo.notes" v-model="itemInfo.notes"
:disabled="configTimeMode === 'create' ? false : itemInfo.state !== 'Entwurf'"
/> />
</UFormGroup> </UFormGroup>
<template #footer v-if="configTimeMode === 'create' || itemInfo.state === 'Entwurf'"> <template #footer>
<InputGroup> <InputGroup>
<UButton <UButton
@click="createTime" @click="createTime"
@@ -418,7 +434,6 @@ const getSecondInfo = (item) => {
<UButton <UButton
@click="updateTime" @click="updateTime"
v-else-if="configTimeMode === 'edit'" v-else-if="configTimeMode === 'edit'"
v-if="itemInfo.state === 'Entwurf'"
> >
Speichern Speichern
</UButton> </UButton>
@@ -456,9 +471,7 @@ const getSecondInfo = (item) => {
:columns="columns" :columns="columns"
:rows="filteredRows" :rows="filteredRows"
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Noch keine Einträge' }" :empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Noch keine Einträge' }"
@select="(row) => {configTimeMode = 'edit'; @select="(row) => openTime(row)"
itemInfo = row;
showConfigTimeModal = true}"
> >
<template #state-data="{row}"> <template #state-data="{row}">
<span <span