Introduced ProfileStore

Corrected All Links to DataStore
This commit is contained in:
2024-12-21 22:33:42 +01:00
parent 813944fc23
commit b465f4a75a
64 changed files with 508 additions and 959 deletions

View File

@@ -3,6 +3,7 @@ import dayjs from "dayjs";
const dataStore = useDataStore()
const profileStore = useProfileStore()
const route = useRoute()
const router = useRouter()
const toast = useToast()
@@ -12,7 +13,7 @@ const mode = ref(route.params.mode || "show")
const itemInfo = ref({
startDate: new Date(),
endDate: new Date(),
profile: dataStore.activeProfile.id
profile: profileStore.activeProfile.id
})
const oldItemInfo = ref({})
@@ -88,7 +89,7 @@ setupPage()
label="Mitarbeiter:"
>
<USelectMenu
:options="dataStore.profiles"
:options="profileStore.profiles"
v-model="itemInfo.profile"
option-attribute="fullName"
value-attribute="id"

View File

@@ -15,6 +15,7 @@ dayjs.extend(isSameOrBefore)
const dataStore = useDataStore()
const profileStore = useProfileStore()
const supabase = useSupabaseClient()
const route = useRoute()
const router = useRouter()
@@ -27,7 +28,7 @@ const absencerequests = ref([])
const setupPage = async () => {
if(route.params.id) itemInfo.value = dataStore.getProfileById(route.params.id)
if(route.params.id) itemInfo.value = profileStore.getProfileById(route.params.id)
if(itemInfo.value.id) oldItemInfo.value = JSON.parse(JSON.stringify(itemInfo.value))
workingtimes.value = (await supabase.from("workingtimes").select().eq("profile",itemInfo.value.id).order("startDate",{ascending:false})).data
absencerequests.value = (await supabase.from("absencerequests").select().eq("user",itemInfo.value.id).order("start",{ascending: false})).data
@@ -177,13 +178,13 @@ const getDuration = (time) => {
const showDocument = ref(false)
const uri = ref("")
const generateDocument = async () => {
const ownTenant = dataStore.ownTenant
const ownTenant = profileStore.ownTenant
const path = ownTenant.letterheadConfig["workingTimesEvaluation"]
const {data,error} = await supabase.storage.from("files").download(path)
uri.value = await useCreateWorkingTimesPdf({
profile: dataStore.getProfileById(route.params.id).fullName,
profile: profileStore.getProfileById(route.params.id).fullName,
...workingTimeInfo.value}, await data.arrayBuffer())
//alert(uri.value)
showDocument.value = true
@@ -345,7 +346,7 @@ changeRange()
]"
>
<template #profile-data="{row}">
{{dataStore.profiles.find(profile => profile.id === row.profile) ? dataStore.profiles.find(profile => profile.id === row.profile).fullName : row.profile }}
{{profileStore.profiles.find(profile => profile.id === row.profile) ? profileStore.profiles.find(profile => profile.id === row.profile).fullName : row.profile }}
</template>
<template #approved-data="{row}">
<span v-if="row.approved" class="text-primary-500">Ja</span>

View File

@@ -9,6 +9,7 @@ definePageMeta({
})
const dataStore = useDataStore()
const profileStore = useProfileStore()
const supabase = useSupabaseClient()
const user = useSupabaseUser()
const toast = useToast()
@@ -22,7 +23,7 @@ const timeInfo = ref({
notes: null,
})
const filterUser = ref(dataStore.activeProfile.id || "")
const filterUser = ref(profileStore.activeProfile.id || "")
const workingtimes = ref([])
@@ -43,15 +44,6 @@ const filteredRows = computed(() => {
times = times.filter(i => i.profile === filterUser.value)
/*if(dataStore.hasRight('viewTimes')) {
if(filterUser.value !== "") {
times = times.filter(i => i.profile === filterUser.value)
}
} else if(dataStore.hasRight('viewOwnTimes')) {
times = times.filter(i => i.profile === dataStore.getOwnProfile.id)
} else {
times = []
}*/
return times/*.map(i => {
return {
@@ -115,16 +107,15 @@ const columns = [
}
]
console.log(dataStore.workingtimes)
const runningTimeInfo = ref({})
const startTime = async () => {
console.log("started")
timeInfo.value = {
profile: dataStore.activeProfile.id,
profile: profileStore.activeProfile.id,
startDate: dayjs(),
tenant: dataStore.currentTenant,
tenant: profileStore.currentTenant,
state: "Im Web gestartet"
}
@@ -137,7 +128,7 @@ const startTime = async () => {
} else if(data) {
//timeInfo.value = data[0]
await dataStore.fetchWorkingTimes()
runningTimeInfo.value = timeInfo.value//dataStore.times.find(time => time.profile === dataStore.activeProfile.id && !time.endDate)
runningTimeInfo.value = timeInfo.value//dataStore.times.find(time => time.profile === profileStore.activeProfile.id && !time.endDate)
}
}
@@ -161,8 +152,8 @@ const stopStartedTime = async () => {
}
}
if(dataStore.workingtimes.find(time => time.profile === dataStore.activeProfile.id && !time.endDate)) {
runningTimeInfo.value = dataStore.workingtimes.find(time => time.profile === dataStore.activeProfile.id && !time.end)
if(dataStore.workingtimes.find(time => time.profile === profileStore.activeProfile.id && !time.endDate)) {
runningTimeInfo.value = dataStore.workingtimes.find(time => time.profile === profileStore.activeProfile.id && !time.end)
}
const getDuration = (time) => {
@@ -216,14 +207,14 @@ const expand = ref({
<template #left>
<USelectMenu
:options="dataStore.profiles"
:options="profileStore.profiles"
option-attribute="fullName"
value-attribute="id"
v-model="filterUser"
@change="setupPage"
>
<template #label>
{{dataStore.getProfileById(filterUser) ? dataStore.getProfileById(filterUser).fullName : "Kein Benutzer ausgewählt"}}
{{profileStore.getProfileById(filterUser) ? profileStore.getProfileById(filterUser).fullName : "Kein Benutzer ausgewählt"}}
</template>
</USelectMenu>
<UButton
@@ -337,7 +328,7 @@ const expand = ref({
</div>
<div class="px-4 pb-4" v-else>
<p><span class="font-bold">Mitarbeitende/r:</span> {{dataStore.getProfileById(row.profile).fullName}}</p>
<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>
@@ -345,7 +336,7 @@ const expand = ref({
</div>
</template>
<template #profile-data="{row}">
{{dataStore.profiles.find(profile => profile.id === row.profile) ? dataStore.profiles.find(profile => profile.id === row.profile).fullName : row.profile }}
{{profileStore.profiles.find(profile => profile.id === row.profile) ? profileStore.profiles.find(profile => profile.id === row.profile).fullName : row.profile }}
</template>
<template #approved-data="{row}">
<span v-if="row.approved" class="text-primary-500">Ja</span>