Fixed Show Workingtimes

This commit is contained in:
2025-10-13 21:32:22 +02:00
parent 59c32ef8d8
commit 2d332f1ded
3 changed files with 29 additions and 153 deletions

View File

@@ -10,15 +10,17 @@ dayjs.extend(customParseFormat)
const dataStore = useDataStore()
const profileStore = useProfileStore()
const supabase = useSupabaseClient()
const router = useRouter()
const route = useRoute()
const auth = useAuthStore()
const platform = await useCapacitor().getIsPhone() ? "mobile" : "default"
const filterUser = ref(profileStore.activeProfile.id || "")
const filterUser = ref(auth.profile.old_profile_id || "c149b249-5baf-43a2-9cc0-1947d3710a43")
const profiles = ref([])
const selectableProfiles = ref([])
const workingtimes = ref([])
@@ -31,8 +33,18 @@ const setupPage = async () => {
if(route.query.profile) filterUser.value = route.query.profile
}
workingtimes.value = (await supabase.from("workingtimes").select().eq("profile",filterUser.value).order("startDate",{ascending: false})).data
//workingtimes.value = (await supabase.from("workingtimes").select().eq("profile",filterUser.value).order("startDate",{ascending: false})).data
workingtimes.value = (await useEntities("workingtimes").select(null,"startDate",false))
let res = await useNuxtApp().$api("/api/tenant/profiles")
console.log(res)
profiles.value = res.data
selectableProfiles.value = res.data.filter(i => i.old_profile_id)
console.log(profiles.value)
console.log(selectableProfiles.value)
@@ -155,7 +167,7 @@ const setEndDate = (row) => {
</script>
<template>
<FloatingActionButton
<!-- <FloatingActionButton
:label="`+ Anwesenheit`"
variant="outline"
v-if="platform === 'mobile'"
@@ -168,11 +180,12 @@ const setEndDate = (row) => {
v-if="platform === 'mobile'"
@click="router.push(`/workingtimes/evaluate/${profileStore.activeProfile.id}`)"
:pos="1"
/>
<UDashboardNavbar title="Anwesenheiten" v-if="platform !== 'mobile'">
/>-->
<UDashboardNavbar title="Anwesenheiten" v-if="platform !== 'mobile'" :badge="filteredRows.length">
<template #right>
<UButton
@click="router.push(`/workingtimes/edit?profile=${filterUser}`)"
disabled
>
+ Anwesenheit
</UButton>
@@ -187,14 +200,14 @@ const setEndDate = (row) => {
<template #left>
<USelectMenu
:options="profileStore.profiles"
option-attribute="fullName"
value-attribute="id"
:options="selectableProfiles"
option-attribute="full_name"
value-attribute="old_profile_id"
v-model="filterUser"
@change="changeFilterUser"
>
<template #label>
{{profileStore.getProfileById(filterUser) ? profileStore.getProfileById(filterUser).fullName : "Kein Benutzer ausgewählt"}}
{{ selectableProfiles.find(i => i.old_profile_id === filterUser) ? selectableProfiles.find(i => i.old_profile_id === filterUser).full_name : "Kein Benutzer ausgewählt"}}
</template>
</USelectMenu>
<UButton
@@ -278,7 +291,9 @@ const setEndDate = (row) => {
</div>
<div class="px-4 pb-4" v-else>
<!--
<p><span class="font-bold">Mitarbeitende/r:</span> {{profileStore.getProfileById(row.profile).fullName}}</p>
-->
<p><span class="font-bold">Start:</span> {{dayjs(row.startDate).format("DD.MM.YYYY HH:mm")}}</p>
<p><span class="font-bold">Ende:</span> {{dayjs(row.endDate).format("DD.MM.YYYY HH:mm")}}</p>
<p><span class="font-bold">Genehmigt:</span> {{row.approved ? "Ja" : "Nein"}}</p>
@@ -286,7 +301,7 @@ const setEndDate = (row) => {
</div>
</template>
<template #profile-data="{row}">
{{profileStore.profiles.find(profile => profile.id === row.profile) ? profileStore.profiles.find(profile => profile.id === row.profile).fullName : row.profile }}
{{ profiles.find(i => i.old_profile_id === row.profile) ? profiles.find(i => i.old_profile_id === row.profile).full_name : ""}}
</template>
<template #approved-data="{row}">
<span v-if="row.approved" class="text-primary-500">Ja</span>