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

@@ -7,6 +7,7 @@ definePageMeta({
})
const dataStore = useDataStore()
const profileStore = useProfileStore()
const route = useRoute()
const router = useRouter()
const toast = useToast()
@@ -110,7 +111,7 @@ setupPage()
<UCard class="mt-5">
<div v-if="item.label === 'Informationen'">
<div class="truncate">
<p>Mitarbeiter: {{dataStore.profiles.find(item => item.id === itemInfo.user) ? dataStore.profiles.find(item => item.id === itemInfo.user).fullName : ""}}</p>
<p>Mitarbeiter: {{profileStore.profiles.find(item => item.id === itemInfo.user) ? profileStore.profiles.find(item => item.id === itemInfo.user).fullName : ""}}</p>
<p>Start: {{dayjs(itemInfo.start).format("DD.MM.YYYY")}}</p>
<p>Ende: {{dayjs(itemInfo.end).format("DD.MM.YYYY")}}</p>
<p>Grund: {{itemInfo.reason}}</p>
@@ -151,14 +152,14 @@ setupPage()
>
<USelectMenu
v-model="itemInfo.user"
:options="dataStore.profiles"
:options="profileStore.profiles"
option-attribute="fullName"
value-attribute="id"
searchable
:search-attributes="['fullName']"
>
<template #label>
{{dataStore.getProfileById(itemInfo.user) ? dataStore.getProfileById(itemInfo.user).fullName : "Mitarbeiter auswählen"}}
{{profileStore.getProfileById(itemInfo.user) ? profileStore.getProfileById(itemInfo.user).fullName : "Mitarbeiter auswählen"}}
</template>
</USelectMenu>
</UFormGroup>

View File

@@ -61,7 +61,7 @@
</span>
</template>
<template #user-data="{row}">
{{dataStore.profiles.find(profile => profile.id === row.user) ? dataStore.profiles.find(profile => profile.id === row.user).fullName : ""}}
{{profileStore.profiles.find(profile => profile.id === row.user) ? profileStore.profiles.find(profile => profile.id === row.user).fullName : ""}}
</template>
</UTable>
</template>
@@ -84,6 +84,7 @@ defineShortcuts({
})
const dataStore = useDataStore()
const profileStore = useProfileStore()
const router = useRouter()
const templateColumns = [

View File

@@ -20,6 +20,7 @@ defineShortcuts({
})
const dataStore = useDataStore()
const profileStore = useProfileStore()
const router = useRouter()
const supabase = useSupabaseClient()
@@ -27,7 +28,7 @@ const bankstatements = ref([])
const setupPage = async () => {
bankstatements.value = (await supabase.from("bankstatements").select("*, statementallocations(*)").eq('tenant', dataStore.currentTenant).order("date", {ascending:false})).data
bankstatements.value = (await supabase.from("bankstatements").select("*, statementallocations(*)").eq('tenant', profileStore.currentTenant).order("date", {ascending:false})).data
}

View File

@@ -14,6 +14,7 @@ defineShortcuts({
})
const dataStore = useDataStore()
const profileStore = useProfileStore()
const route = useRoute()
const router = useRouter()
const mode = ref(route.params.mode || "show")
@@ -132,7 +133,7 @@ const saveAllocations = async () => {
const saveAllocation = async (allocation) => {
const {data,error} = await supabase.from("statementallocations").insert({
...allocation,
tenant: dataStore.currentTenant
tenant: profileStore.currentTenant
}).select()
if(data) {

View File

@@ -11,6 +11,7 @@ const supabase = useSupabaseClient()
const user = useSupabaseUser()
const dataStore = useDataStore()
const profileStore = useProfileStore()
const selectedChat = ref({})
const messageText = ref("")
@@ -24,8 +25,8 @@ const messageText = ref("")
@click="selectedChat = chat"
>
<UAlert
:title="chat.title ? chat.title : chat.members.map(i => { if(i !== user.id) return dataStore.getProfileById(i).fullName}).join(' ')"
:avatar="{alt: chat.members.map(i => { if(i !== user.id) return dataStore.getProfileById(i).fullName}).join(' ')}"
:title="chat.title ? chat.title : chat.members.map(i => { if(i !== user.id) return profileStore.getProfileById(i).fullName}).join(' ')"
:avatar="{alt: chat.members.map(i => { if(i !== user.id) return profileStore.getProfileById(i).fullName}).join(' ')}"
:color="selectedChat.id === chat.id ? 'primary' : 'white'"
variant="outline"
>
@@ -49,13 +50,13 @@ const messageText = ref("")
{{message.text}}
</div>
<UAvatar
:alt="dataStore.getProfileById(message.origin) ? dataStore.getProfileById(message.origin).fullName : ''"
:alt="profileStore.getProfileById(message.origin) ? profileStore.getProfileById(message.origin).fullName : ''"
size="md"
/>
</div>
<div class="flex justify-start mb-4" v-else>
<UAvatar
:alt="dataStore.getProfileById(message.origin) ? dataStore.getProfileById(message.origin).fullName : ''"
:alt="profileStore.getProfileById(message.origin) ? profileStore.getProfileById(message.origin).fullName : ''"
size="md"
/>
<div

View File

@@ -1,6 +1,6 @@
<script setup>
const dataStore = useDataStore()
const profileStore = useProfileStore()
const supabase = useSupabaseClient()
const profiles = ref([])
@@ -10,14 +10,14 @@ const selectedProfiles = ref([])
const setup = async () => {
profiles.value = await useSupabaseSelect("profiles")
selectedProfiles.value = [dataStore.activeProfile.id]
selectedProfiles.value = [profileStore.activeProfile.id]
}
setup()
const createChat = async () => {
const {data,error} = await supabase.from("chats").insert({
tenant: dataStore.currentTenant,
tenant: profileStore.currentTenant,
name: itemInfo.value.name
}).select()
@@ -105,7 +105,7 @@ const createChat = async () => {
:search-attributes="['fullName']"
>
<template #label>
{{selectedProfiles.length > 0 ? selectedProfiles.map(i => dataStore.getProfileById(i).fullName).join(", ") : "Keine Benutzer ausgewählt"}}
{{selectedProfiles.length > 0 ? selectedProfiles.map(i => profileStore.getProfileById(i).fullName).join(", ") : "Keine Benutzer ausgewählt"}}
</template>
</USelectMenu>
</UFormGroup>

View File

@@ -13,17 +13,17 @@ defineShortcuts({
})
const itemInfo = ref({})
const dataStore = useDataStore()
const profileStore = useProfileStore()
const supabase = useSupabaseClient()
const setup = async () => {
itemInfo.value = await useSupabaseSelectSingle("chats",useRoute().params.id,"*, profiles(*), chatmessages(*)")
let unseenMessages = itemInfo.value.chatmessages.filter(i => !i.seenBy.includes(dataStore.activeProfile.id))
let unseenMessages = itemInfo.value.chatmessages.filter(i => !i.seenBy.includes(profileStore.activeProfile.id))
for await (const message of unseenMessages){
await supabase.from("chatmessages").update({seenBy: [...message.seenBy, dataStore.activeProfile.id]}).eq("id",message.id)
await supabase.from("chatmessages").update({seenBy: [...message.seenBy, profileStore.activeProfile.id]}).eq("id",message.id)
}
@@ -34,11 +34,11 @@ const messageText = ref("")
const sendMessage = async () => {
if(messageText.value.length > 0) {
const message = {
origin: dataStore.activeProfile.id,
origin: profileStore.activeProfile.id,
destinationchat: itemInfo.value.id,
text: messageText.value,
tenant: dataStore.currentTenant,
seenBy: [dataStore.activeProfile.id]
tenant: profileStore.currentTenant,
seenBy: [profileStore.activeProfile.id]
}
const {data,error} = await supabase.from("chatmessages").insert(message)
@@ -49,11 +49,11 @@ const sendMessage = async () => {
//Reset
messageText.value = ""
//Create Notifications
let notifications = itemInfo.value.profiles.filter(i => i.id !== dataStore.activeProfile.id).map(i => {
let notifications = itemInfo.value.profiles.filter(i => i.id !== profileStore.activeProfile.id).map(i => {
return {
tenant: dataStore.currentTenant,
tenant: profileStore.currentTenant,
profile: i.id,
initiatingProfile: dataStore.activeProfile.id,
initiatingProfile: profileStore.activeProfile.id,
title: `Sie haben eine neue Nachricht im Chat ${itemInfo.value.name}`,
link: `/chats/show/${itemInfo.value.id}`,
message: message.text
@@ -88,13 +88,13 @@ const sendMessage = async () => {
</UDashboardNavbar>
<div class="scrollList p-5">
<UAlert
:color="message.seenBy.includes(dataStore.activeProfile.id) ? 'white' : 'primary'"
:variant="message.seenBy.includes(dataStore.activeProfile.id) ? 'solid' : 'outline'"
:color="message.seenBy.includes(profileStore.activeProfile.id) ? 'white' : 'primary'"
:variant="message.seenBy.includes(profileStore.activeProfile.id) ? 'solid' : 'outline'"
class="my-2"
v-for="message in itemInfo.chatmessages"
:description="message.text"
:avatar="{ alt: dataStore.getProfileById(message.origin).fullName }"
:title="`${dataStore.getProfileById(message.origin).fullName} - ${isToday(new Date(message.created_at)) ? dayjs(message.created_at).format('HH:mm') : dayjs(message.created_at).format('DD.MM.YYYY HH:mm')}`"
:avatar="{ alt: profileStore.getProfileById(message.origin).fullName }"
:title="`${profileStore.getProfileById(message.origin).fullName} - ${isToday(new Date(message.created_at)) ? dayjs(message.created_at).format('HH:mm') : dayjs(message.created_at).format('DD.MM.YYYY HH:mm')}`"
/>
</div>

View File

@@ -3,6 +3,7 @@ import dayjs from "dayjs"
const supabase = useSupabaseClient()
const dataStore = useDataStore()
const profileStore = useProfileStore()
const router = useRouter()
@@ -10,7 +11,7 @@ const items = ref([])
const setup = async () => {
items.value = (await supabase.from("historyitems").select().like('text',`%@${dataStore.activeProfile.username}%`)/*.textSearch("text", `'@${dataStore.activeProfile.username}'`)*/.order("created_at")).data
items.value = (await supabase.from("historyitems").select().like('text',`%@${profileStore.activeProfile.username}%`)/*.textSearch("text", `'@${profileStore.activeProfile.username}'`)*/.order("created_at")).data
}
const navigateToHistoryItem = (item) => {

View File

@@ -23,6 +23,7 @@ defineShortcuts({
})
const dataStore = useDataStore()
const profileStore = useProfileStore()
const route = useRoute()
const router = useRouter()
const toast = useToast()
@@ -33,7 +34,8 @@ const openTab = ref(0)
//Working
const mode = ref(route.params.mode || "show")
const itemInfo = ref({
active: true
active: true,
profiles: [profileStore.activeProfile.id]
})
const oldItemInfo = ref({})
@@ -300,6 +302,23 @@ setupPage()
</template>
</UPopover>
</UFormGroup>
<UFormGroup
label="Berechtige Benutzer:"
>
<USelectMenu
v-model="itemInfo.profiles"
:options="profileStore.profiles"
option-attribute="fullName"
value-attribute="id"
searchable
multiple
:search-attributes="['fullName']"
>
<template #label>
{{itemInfo.profiles.length > 0 ? itemInfo.profiles.map(i => profileStore.getProfileById(i).fullName).join(", ") : "Kein Benutzer ausgewählt"}}
</template>
</USelectMenu>
</UFormGroup>
<UFormGroup
label="Notizen:"
>
@@ -307,6 +326,7 @@ setupPage()
v-model="itemInfo.notes"
/>
</UFormGroup>
</UForm>
</template>

View File

@@ -24,6 +24,7 @@ defineShortcuts({
})
const dataStore = useDataStore()
const profileStore = useProfileStore()
const route = useRoute()
const router = useRouter()
const toast = useToast()
@@ -215,7 +216,7 @@ setupPage()
<td colspan="2"><span class="font-bold">Eigene Felder:</span></td>
</tr>
<tr v-for="fieldKey in Object.keys(itemInfo.ownFields)">
<td>{{dataStore.ownTenant.ownFields.contracts.find(i => i.key === fieldKey).label}}</td>
<td>{{profileStore.ownTenant.ownFields.contracts.find(i => i.key === fieldKey).label}}</td>
<td>{{itemInfo.ownFields[fieldKey]}}</td>
</tr>
</table>
@@ -491,14 +492,14 @@ setupPage()
</UFormGroup>
<div
v-if="dataStore.ownTenant.ownFields"
v-if="profileStore.ownTenant.ownFields"
>
<UDivider
class="mt-3"
>Eigene Felder</UDivider>
<UFormGroup
v-for="field in dataStore.ownTenant.ownFields.contracts"
v-for="field in profileStore.ownTenant.ownFields.contracts"
:key="field.key"
:label="field.label"
>

View File

@@ -5,6 +5,7 @@ import {useNumberRange} from "~/composables/useNumberRange.js";
import { v4 as uuidv4 } from 'uuid';
const dataStore = useDataStore()
const profileStore = useProfileStore()
const user = useSupabaseUser()
const route = useRoute()
const router = useRouter()
@@ -37,7 +38,7 @@ const itemInfo = ref({
deliveryDateType: "Lieferdatum",
dateOfPerformance: null,
paymentDays: 7,
createdBy: dataStore.activeProfile.id,
createdBy: profileStore.activeProfile.id,
title: null,
description: null,
startText: null,
@@ -45,7 +46,7 @@ const itemInfo = ref({
rows: [
],
contactPerson: dataStore.activeProfile.id,
contactPerson: profileStore.activeProfile.id,
contactPersonName: null,
contactTel: null,
contactEMail: null,
@@ -74,6 +75,7 @@ const servicecategories = ref([])
const selectedServicecategorie = ref(null)
const customers = ref([])
const contacts = ref([])
const texttemplates = ref([])
const loaded = ref(false)
const setupPage = async () => {
@@ -87,6 +89,7 @@ const setupPage = async () => {
productcategories.value = (await useSupabaseSelect("productcategories","*"))
customers.value = (await useSupabaseSelect("customers","*","customerNumber"))
contacts.value = (await useSupabaseSelect("contacts","*"))
texttemplates.value = (await useSupabaseSelect("texttemplates","*"))
if(productcategories.value.length > 0) selectedProductcategorie.value = productcategories.value[0].id
if(servicecategories.value.length > 0) selectedServicecategorie.value = servicecategories.value[0].id
@@ -216,8 +219,8 @@ const setDocumentTypeConfig = (withTexts = false) => {
}
if(withTexts) {
itemInfo.value.startText = dataStore.getTextTemplatesByDocumentType(itemInfo.value.type).find(i => i.default && i.pos === "startText").text
itemInfo.value.endText = dataStore.getTextTemplatesByDocumentType(itemInfo.value.type).find(i => i.default && i.pos === "endText").text
itemInfo.value.startText = texttemplates.value.find(i => i.documentType === itemInfo.value.type && i.default && i.pos === "startText").text
itemInfo.value.endText = texttemplates.value.find(i => i.documentType === itemInfo.value.type && i.default && i.pos === "endText").text
}
itemInfo.value.letterhead = letterheads.value[0].id
@@ -310,7 +313,7 @@ const addPosition = (mode) => {
discountPercent: 0
}
itemInfo.value.rows.push({...rowData, ...dataStore.ownTenant.extraModules.includes("agriculture") ? {agriculture: {}}: {}})
itemInfo.value.rows.push({...rowData, ...profileStore.ownTenant.extraModules.includes("agriculture") ? {agriculture: {}}: {}})
} else if(mode === 'normal'){
itemInfo.value.rows.push({
@@ -334,7 +337,7 @@ const addPosition = (mode) => {
}
//Push Agriculture Holder only if Module is activated
itemInfo.value.rows.push({...rowData, ...dataStore.ownTenant.extraModules.includes("agriculture") ? {agriculture: {}}: {}})
itemInfo.value.rows.push({...rowData, ...profileStore.ownTenant.extraModules.includes("agriculture") ? {agriculture: {}}: {}})
} else if(mode === "pagebreak") {
itemInfo.value.rows.push({
id: uuidv4(),
@@ -373,7 +376,7 @@ const removePosition = (id) => {
const getRowMargin = (row) => {
if(row.mode === "normal" && row.product) {
let purchasePrice = dataStore.getProductById(row.product).purchasePrice || 0
let purchasePrice = products.value.find(i => i.id === row.product).purchasePrice || 0
return row.price - purchasePrice
} else {
return 0
@@ -530,9 +533,9 @@ const getDocumentData = () => {
let customerData = dataStore.getCustomerById(itemInfo.value.customer)
let contactData = dataStore.getContactById(itemInfo.value.contact)
let businessInfo = dataStore.ownTenant.businessInfo
let businessInfo = profileStore.ownTenant.businessInfo
if(dataStore.ownTenant.extraModules.includes("agriculture")) {
if(profileStore.ownTenant.extraModules.includes("agriculture")) {
itemInfo.value.rows.forEach(row => {
if(row.agriculture && row.agriculture.dieselUsage) {
row.agriculture.description = `${row.agriculture.dieselUsage} L Diesel zu ${renderCurrency(row.agriculture.dieselPrice)}/L verbraucht ${row.description ? "\n" + row.description : ""}`
@@ -555,7 +558,7 @@ const getDocumentData = () => {
}
if(!['pagebreak','title','text'].includes(row.mode)) {
if(row.mode === 'normal') row.text = dataStore.getProductById(row.product).name
if(row.mode === 'normal') row.text = products.value.find(i => i.id === row.product).name
if(row.mode === 'service') row.text = dataStore.getServiceById(row.service).name
@@ -630,7 +633,7 @@ const getDocumentData = () => {
const showDocument = ref(false)
const uri = ref("")
const generateDocument = async () => {
const ownTenant = dataStore.ownTenant
const ownTenant = profileStore.ownTenant
const path = letterheads.value.find(i => i.id === itemInfo.value.letterhead).path
@@ -717,7 +720,7 @@ const saveDocument = async (state) => {
setDocumentTypeConfig(false)
}
if(dataStore.ownTenant.extraModules.includes("agriculture")) {
if(profileStore.ownTenant.extraModules.includes("agriculture")) {
itemInfo.value.rows.forEach(row => {
if(row.agriculture && row.agriculture.dieselUsage) {
row.agriculture.description = `${row.agriculture.dieselUsage} L Diesel zu ${renderCurrency(row.agriculture.dieselPrice)}/L verbraucht ${row.description ? "\n" + row.description : ""}`
@@ -1193,7 +1196,7 @@ setupPage()
label="Ansprechpartner:"
>
<USelectMenu
:options="dataStore.profiles"
:options="profileStore.profiles"
v-model="itemInfo.contactPerson"
option-attribute="fullName"
value-attribute="id"
@@ -1464,12 +1467,12 @@ setupPage()
searchable-placeholder="Suche ..."
:search-attributes="['name']"
v-model="row.product"
@change="row.unit = dataStore.getProductById(row.product).unit,
row.price = (dataStore.getProductById(row.product).sellingPrice || 0),
row.description = dataStore.getProductById(row.product).description"
@change="row.unit = products.find(i => i.id === row.product).unit,
row.price = (products.find(i => i.id === row.product).sellingPrice || 0),
row.description = products.find(i => i.id === row.product).description"
>
<template #label>
<span class="truncate">{{row.product ? dataStore.getProductById(row.product).name : "Kein Produkt ausgewählt" }}</span>
<span class="truncate">{{row.product ? products.find(i => i.id === row.product).name : "Kein Produkt ausgewählt" }}</span>
</template>
</USelectMenu>
<UButton
@@ -1503,9 +1506,9 @@ setupPage()
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Keine Artikel anzuzeigen' }"
@select=" (i) => {
row.product = i.id
row.unit = dataStore.getProductById(row.product).unit,
row.price = (dataStore.getProductById(row.product).sellingPrice || 0),
row.description = dataStore.getProductById(row.product).description
row.unit = products.find(i => i.id === row.product).unit,
row.price = (products.find(i => i.id === row.product).sellingPrice || 0),
row.description = products.find(i => i.id === row.product).description
showProductSelectionModal = false}"
>
@@ -1514,9 +1517,6 @@ setupPage()
</UModal>
</InputGroup>
<!--
{{dataStore.getProductById(66)}}
-->
</td>
<td
class="w-120"

View File

@@ -280,10 +280,6 @@ const isPaid = (item) => {
let amountPaid = 0
item.statementallocations.forEach(allocation => amountPaid += allocation.amount)
console.log(item.documentNumber)
console.log(amountPaid)
console.log(calculateDocSum(item))
return Number(amountPaid.toFixed(2)) === Number(calculateDocSum(item))
}
</script>

View File

@@ -12,6 +12,7 @@ defineShortcuts({
const supabase = useSupabaseClient()
const dataStore = useDataStore()
const profileStore = useProfileStore()
const route = useRoute()
const router = useRouter()
@@ -26,7 +27,7 @@ const setupPage = async () => {
}
currentTenant.value = (await supabase.from("tenants").select().eq("id",dataStore.currentTenant).single()).data
currentTenant.value = (await supabase.from("tenants").select().eq("id",profileStore.currentTenant).single()).data
console.log(currentTenant.value)
}

View File

@@ -23,10 +23,9 @@ defineShortcuts({
})
const dataStore = useDataStore()
const profileStore = useProfileStore()
const route = useRoute()
const router = useRouter()
const toast = useToast()
const id = ref(route.params.id ? route.params.id : null )
const openTab = ref(0)
@@ -39,7 +38,8 @@ const itemInfo = ref({
country: "Deutschland"
},
active: true,
isCompany: true
isCompany: true,
profiles: [profileStore.activeProfile.id]
})
const oldItemInfo = ref({})
@@ -356,6 +356,23 @@ setupPage()
v-model="itemInfo.infoData.ustid"
/>
</UFormGroup>
<UFormGroup
label="Berechtigte Benutzer:"
>
<USelectMenu
v-model="itemInfo.profiles"
:options="profileStore.profiles"
option-attribute="fullName"
value-attribute="id"
searchable
multiple
:search-attributes="['fullName']"
>
<template #label>
{{itemInfo.profiles.length > 0 ? itemInfo.profiles.map(i => profileStore.getProfileById(i).fullName).join(", ") : "Kein Benutzer ausgewählt"}}
</template>
</USelectMenu>
</UFormGroup>
</UForm>
</UDashboardPanelContent>

View File

@@ -11,6 +11,7 @@ definePageMeta({
const dataStore = useDataStore()
const profileStore = useProfileStore()
const supabase = useSupabaseClient()
const route = useRoute()
const router = useRouter()
@@ -81,7 +82,7 @@ const filteredTimes = computed(() => {
//Functions
const setupPage = () => {
if(mode.value === "show" || mode.value === "edit"){
currentItem = dataStore.getProfileById(useRoute().params.id)
currentItem = profileStore.getProfileById(useRoute().params.id)
}
itemInfo.value = currentItem
@@ -337,7 +338,7 @@ setupPage()
<div class="text-right">{{dayjs(row.end).format("HH:mm")}}</div>
</template>
<template #user-data="{row}">
{{dataStore.getProfileById(row.user) ? dataStore.getProfileById(row.user).fullName : ""}}
{{profileStore.getProfileById(row.user) ? profileStore.getProfileById(row.user).fullName : ""}}
</template>
<template #duration-data="{row}">
<div class="text-right">{{ getDuration(row).composed}} Std</div>

View File

@@ -8,6 +8,7 @@ definePageMeta({
middleware: "auth"
})
const dataStore = useDataStore()
const profileStore = useProfileStore()
const supabase = useSupabaseClient()
const user = useSupabaseUser()
const toast = useToast()
@@ -21,7 +22,7 @@ const uploadInProgress = ref(false)
const fileUploadFormData = ref({
tags: ["Eingang"],
path: "",
tenant: dataStore.currentTenant,
tenant: profileStore.currentTenant,
folder: null
})
@@ -163,7 +164,7 @@ const uploadFiles = async (files) => {
uploadInProgress.value = true;
if(files) {
await dataStore.uploadFiles({tags: ["Ablage"],tenant: dataStore.currentTenant,folder: currentFolder.value.id}, files, true)
await dataStore.uploadFiles({tags: ["Ablage"],tenant: profileStore.currentTenant,folder: currentFolder.value.id}, files, true)
} else {
await dataStore.uploadFiles(fileUploadFormData.value, document.getElementById("fileUploadInput").files, true)

View File

@@ -2,6 +2,7 @@
const supabase = useSupabaseClient()
const dataStore = useDataStore()
const profileStore = useProfileStore()
const selectedTab = ref(0)
@@ -12,7 +13,7 @@ const accountData = ref(null)
const availableAccounts = ref(null)
const selectedAccount = ref(null)
const setupPage = async () => {
availableAccounts.value = (await supabase.from("emailAccounts").select("*").contains("profiles",[dataStore.activeProfile.id])).data
availableAccounts.value = (await supabase.from("emailAccounts").select("*").contains("profiles",[profileStore.activeProfile.id])).data
console.log(availableAccounts.value)
if(availableAccounts.value.length > 0) {

View File

@@ -2,6 +2,7 @@
const supabase = useSupabaseClient()
const dataStore = useDataStore()
const profileStore = useProfileStore()
const route = useRoute()
const router = useRouter()
const toast = useToast()
@@ -29,7 +30,7 @@ const setupPage = async () => {
} else {
emailData.value.account = emailAccounts.value[0].id
preloadedContent.value = `<p></p><p></p><p></p>${dataStore.activeProfile.emailSignature}`
preloadedContent.value = `<p></p><p></p><p></p>${profileStore.activeProfile.emailSignature}`
//Check Query
if(route.query.to) emailData.value.to = route.query.to

View File

@@ -9,6 +9,7 @@ definePageMeta({
})
const dataStore = useDataStore()
const profileStore = useProfileStore()
const supabase = useSupabaseClient()
const user = useSupabaseUser()
const toast = useToast()
@@ -111,7 +112,7 @@ const startTime = async () => {
console.log("started")
timeInfo.value.user = user.value.id
timeInfo.value.start = new Date().toISOString()
timeInfo.value.tenant = dataStore.currentTenant
timeInfo.value.tenant = profileStore.currentTenant
const {data,error} = await supabase
.from("times")
@@ -162,7 +163,7 @@ if(dataStore.times.find(time => time.user == user.value.id && !time.end)) {
const createTime = async () => {
const {data,error} = await supabase
.from("times")
.insert({...itemInfo.value, tenant: dataStore.currentTenant})
.insert({...itemInfo.value, tenant: profileStore.currentTenant})
.select()
if(error) {
@@ -241,13 +242,13 @@ const setState = async (newState) => {
</UButton>
<USelectMenu
v-if="dataStore.hasRight('viewTimes')"
:options="dataStore.profiles"
:options="profileStore.profiles"
option-attribute="fullName"
value-attribute="id"
v-model="filterUser"
>
<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>
</template>
@@ -339,14 +340,14 @@ const setState = async (newState) => {
label="Benutzer:"
>
<USelectMenu
:options="dataStore.profiles"
:options="profileStore.profiles"
v-model="itemInfo.user"
option-attribute="fullName"
value-attribute="id"
:disabled="(configTimeMode === 'create' ? false : itemInfo.state !== 'Entwurf') || (!dataStore.hasRight('createTime') || !dataStore.hasRight('createOwnTime'))"
>
<template #label>
{{dataStore.profiles.find(profile => profile.id === itemInfo.user) ? dataStore.profiles.find(profile => profile.id === itemInfo.user).fullName : "Benutzer auswählen"}}
{{profileStore.profiles.find(profile => profile.id === itemInfo.user) ? profileStore.profiles.find(profile => profile.id === itemInfo.user).fullName : "Benutzer auswählen"}}
</template>
</USelectMenu>
</UFormGroup>
@@ -444,7 +445,7 @@ const setState = async (newState) => {
>{{row.state}}</span>
</template>
<template #user-data="{row}">
{{dataStore.profiles.find(profile => profile.id === row.user) ? dataStore.profiles.find(profile => profile.id === row.user).fullName : row.user }}
{{profileStore.profiles.find(profile => profile.id === row.user) ? profileStore.profiles.find(profile => profile.id === row.user).fullName : row.user }}
</template>
<template #start-data="{row}">

View File

@@ -4,6 +4,7 @@ import dayjs from "dayjs";
const route = useRoute()
const router = useRouter()
const dataStore = useDataStore()
const profileStore = useProfileStore()
const mode = ref(route.params.mode || "show")
@@ -13,7 +14,7 @@ const itemInfo = ref({
})
const oldItemInfo = ref({})
const resourceToAdd = ref(dataStore.activeProfile.id)
const resourceToAdd = ref(profileStore.activeProfile.id)
/*const mapResources = () => {
console.log(itemInfo.value.resources)
itemInfo.value.resources.map(resource => {

View File

@@ -18,7 +18,7 @@
title="Anwesenheiten"
v-if="dataStore.getStartedWorkingTimes().length > 0"
>
<p v-for="time in dataStore.getStartedWorkingTimes()"><UIcon name="i-heroicons-check"/>{{dataStore.getProfileById(time.profile).fullName}}</p>
<p v-for="time in dataStore.getStartedWorkingTimes()"><UIcon name="i-heroicons-check"/>{{profileStore.getProfileById(time.profile).fullName}}</p>
</UDashboardCard>
<!--TODO: Fix Card Table overflowing <UDashboardCard
@@ -27,7 +27,7 @@
class="w-1/2 h-1/2"
>
<UTable
:rows="dataStore.tasks.filter(i => i.categorie !== 'Erledigt' && (i.profile === dataStore.activeProfile.id ||!i.profile))"
:rows="dataStore.tasks.filter(i => i.categorie !== 'Erledigt' && (i.profile === profileStore.activeProfile.id ||!i.profile))"
@select="(row) => router.push(`/tasks/show/${row.id}`)"
:columns="[
{
@@ -69,6 +69,7 @@ definePageMeta({
})
const dataStore = useDataStore()
const profileStore = useProfileStore()
const toast = useToast()
const router = useRouter()

View File

@@ -4,6 +4,7 @@ definePageMeta({
})
const dataStore = useDataStore()
const profileStore = useProfileStore()
const supabase = useSupabaseClient()
const router = useRouter()
const mode = ref("incoming")
@@ -41,8 +42,8 @@ const createMovement = async () => {
spaceId: inventoryChangeData.value.destinationSpaceId,
projectId: inventoryChangeData.value.destinationProjectId,
quantity: inventoryChangeData.value.quantity,
profileId: dataStore.activeProfile.id,
tenant: dataStore.currentTenant
profileId: profileStore.activeProfile.id,
tenant: profileStore.currentTenant
}
movements.push(movement)
@@ -61,8 +62,8 @@ const createMovement = async () => {
spaceId: inventoryChangeData.value.sourceSpaceId,
projectId: inventoryChangeData.value.sourceProjectId,
quantity: inventoryChangeData.value.quantity * -1,
profileId: dataStore.activeProfile.id,
tenant: dataStore.currentTenant
profileId: profileStore.activeProfile.id,
tenant: profileStore.currentTenant
}
movements.push(movement)
@@ -72,16 +73,16 @@ const createMovement = async () => {
spaceId: inventoryChangeData.value.sourceSpaceId,
projectId: inventoryChangeData.value.sourceProjectId,
quantity: inventoryChangeData.value.quantity * -1,
profileId: dataStore.activeProfile.id,
tenant: dataStore.currentTenant
profileId: profileStore.activeProfile.id,
tenant: profileStore.currentTenant
}
let inMovement = {
productId: inventoryChangeData.value.productId,
spaceId: inventoryChangeData.value.destinationSpaceId,
projectId: inventoryChangeData.value.destinationProjectId,
quantity: inventoryChangeData.value.quantity,
profileId: dataStore.activeProfile.id,
tenant: dataStore.currentTenant
profileId: profileStore.activeProfile.id,
tenant: profileStore.currentTenant
}
movements.push(outMovement)

View File

@@ -1,5 +1,7 @@
<script setup >
import {useProfileStore} from "~/stores/profile.js";
definePageMeta({
layout: "notLoggedIn"
})
@@ -8,8 +10,8 @@ const supabase = useSupabaseClient()
const user = useSupabaseUser()
const router = useRouter()
const colorMode = useColorMode()
const dataStore = useDataStore()
const toast = useToast()
const profileStore = useProfileStore()
const isLight = computed({
get () {
@@ -61,7 +63,7 @@ const onSubmit = async (data) => {
} else {
//console.log("Login Successful")
dataStore.initializeData(user.id)
profileStore.initializeData(user.id)
router.push("/")

View File

@@ -20,9 +20,6 @@ const id = ref(route.params.id ? route.params.id : null )
//Working
const mode = ref(route.params.mode || "show")
const itemInfo = ref({
description: {
html: ""
}
})
const tabItems = [
@@ -105,7 +102,7 @@ setupPage()
Erstellen
</UButton>
<UButton
@click="router.push(itemInfo.id ? `/plants/show/${itemInfo.value.id}` : `/plants/`)"
@click="router.push(itemInfo.id ? `/plants/show/${itemInfo.id}` : `/plants/`)"
color="red"
class="ml-2"
v-if="mode === 'edit' || mode === 'create'"
@@ -144,7 +141,7 @@ setupPage()
</tr>
</table>
</div>
<div v-if="itemInfo.description.html">
<div v-if="itemInfo.description">
<p>Notizen:</p>
<span v-html="itemInfo.description.html"></span>
</div>

View File

@@ -25,6 +25,7 @@ defineShortcuts({
})
const dataStore = useDataStore()
const profileStore = useProfileStore()
const supabase = useSupabaseClient()
const route = useRoute()
const router = useRouter()
@@ -270,7 +271,7 @@ setupPage()
>
<USelectMenu
v-model="itemInfo.tags"
:options="dataStore.ownTenant.tags.products"
:options="profileStore.ownTenant.tags.products"
multiple
>
<template #label>

View File

@@ -1,5 +1,6 @@
<script setup>
const dataStore = useDataStore()
const profileStore = useProfileStore()
const router = useRouter()
@@ -35,7 +36,7 @@
</UDashboardNavbar>
<UTable
:rows="dataStore.profiles"
:rows="profileStore.profiles"
@select="(item) => router.push(`/profiles/show/${item.id}`)"
:columns="columns"
>

View File

@@ -12,6 +12,7 @@ dayjs.extend(isoWeek)
dayjs.extend(isBetween)
const dataStore = useDataStore()
const profileStore = useProfileStore()
const route = useRoute()
const router = useRouter()
const supabase = useSupabaseClient()
@@ -33,7 +34,7 @@ const setupPage = async () => {
setupPage()
const emailSignature = ref(dataStore.activeProfile.emailSignature)
const emailSignature = ref(profileStore.activeProfile.emailSignature)
const tiptapLoaded = ref(false)
const contentSaved = ref(true)
const contentChanged = async (content) => {
@@ -49,7 +50,7 @@ const contentChanged = async (content) => {
const saveSignature = async () => {
const {data,error} = await supabase.from("profiles").update({emailSignature: emailSignature.value}).eq("id", dataStore.activeProfile.id)
const {data,error} = await supabase.from("profiles").update({emailSignature: emailSignature.value}).eq("id", profileStore.activeProfile.id)
if(error) {
toast.add({title: "Fehler beim Speichern der Signatur", color:"rose"})
@@ -66,8 +67,8 @@ const addToNewsletter = async () => {
url: "https://newsletter.fedeo.io/api/public/subscription",
method: "post",
data: {
email: dataStore.activeProfile.email,
name: dataStore.activeProfile.name,
email: profileStore.activeProfile.email,
name: profileStore.activeProfile.name,
list_uuids: ["b97453fd-14b2-4b25-8f9b-b83847317ea3"],
}
@@ -227,12 +228,12 @@ const isLight = computed({
</UFormGroup>
</InputGroup>
<UDivider class="my-5" v-if="dataStore.activeProfile.id === itemInfo.id">
<UDivider class="my-5" v-if="profileStore.activeProfile.id === itemInfo.id">
Helligkeitseinstellung
</UDivider>
<UButton
v-if="dataStore.activeProfile.id === itemInfo.id"
v-if="profileStore.activeProfile.id === itemInfo.id"
:icon="isLight ? 'i-heroicons-moon-20-solid' : 'i-heroicons-sun-20-solid'"
color="white"
variant="outline"

View File

@@ -23,6 +23,7 @@ defineShortcuts({
})
const dataStore = useDataStore()
const profileStore = useProfileStore()
const supabase = useSupabaseClient()
const user = useSupabaseUser()
const route = useRoute()
@@ -90,11 +91,9 @@ const mode = ref(route.params.mode || "show")
const itemInfo = ref({
name: "",
customer: 0,
users: [dataStore.activeProfile.id]
profiles: [profileStore.activeProfile.id]
})
const oldItemInfo = ref({})
const tags = dataStore.getDocumentTags
const phasesTemplates = ref([])
const plants = ref([])
const contracts = ref([])
@@ -180,7 +179,7 @@ const changeActivePhase = async (key) => {
if(p.key === key) {
p.active = true
p.activated_at = dayjs().format()
p.activated_by = dataStore.activeProfile.id
p.activated_by = profileStore.activeProfile.id
phaseLabel = p.label
}
@@ -191,8 +190,8 @@ const changeActivePhase = async (key) => {
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,
createdBy: profileStore.activeProfile.id,
tenant: profileStore.currentTenant,
text: `Aktive Phase zu "${phaseLabel}" gewechselt`,
project: item.id
})
@@ -304,8 +303,8 @@ const invoiceDeliveryNotes = () => {
<h1 class="font-bold text-lg mb-3">Beteiligte Benutzer:</h1>
<UAlert
v-for="projectUser in itemInfo.profiles"
:avatar="{ alt: dataStore.getProfileById(projectUser).fullName }"
:title="dataStore.getProfileById(projectUser).fullName"
:avatar="{ alt: profileStore.getProfileById(projectUser).fullName }"
:title="profileStore.getProfileById(projectUser).fullName"
class="mb-3"
/>
@@ -378,7 +377,7 @@ const invoiceDeliveryNotes = () => {
<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.activated_by" class="text-black">Aktiviert durch: {{profileStore.getProfileById(item.activated_by).fullName}}</p>
<p v-if="item.description" class="text-black">Beschreibung: {{item.description}}</p>
</div>
</UCard>
@@ -406,7 +405,7 @@ const invoiceDeliveryNotes = () => {
>
<template #user-data="{row}">
{{dataStore.profiles.find(i => i.id === row.user) ? dataStore.profiles.find(i => i.id === row.user).fullName : ""}}
{{profileStore.profiles.find(i => i.id === row.user) ? profileStore.profiles.find(i => i.id === row.user).fullName : ""}}
</template>
</UTable>
</UCard>
@@ -462,7 +461,7 @@ const invoiceDeliveryNotes = () => {
<span v-if="row.type === 'deliveryNotes'">Lieferschein</span>
</template>
<template #createdBy-data="{row}">
{{dataStore.getProfileById(row.createdBy).fullName}}
{{profileStore.getProfileById(row.createdBy).fullName}}
</template>
</UTable>
@@ -482,7 +481,7 @@ const invoiceDeliveryNotes = () => {
: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 }}
{{profileStore.profiles.find(profile => profile.id === row.user) ? profileStore.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` : ""}}
@@ -640,11 +639,11 @@ const invoiceDeliveryNotes = () => {
<UFormGroup
label="Beteiligte Benutzer:"
label="Berechtigte Benutzer:"
>
<USelectMenu
v-model="itemInfo.profiles"
:options="dataStore.profiles"
:options="profileStore.profiles"
option-attribute="fullName"
value-attribute="id"
searchable
@@ -652,7 +651,7 @@ const invoiceDeliveryNotes = () => {
:search-attributes="['fullName']"
>
<template #label>
{{itemInfo.profiles.length > 0 ? itemInfo.profiles.map(i => dataStore.getProfileById(i).fullName).join(", ") : "Kein Benutzer ausgewählt"}}
{{itemInfo.profiles.length > 0 ? itemInfo.profiles.map(i => profileStore.getProfileById(i).fullName).join(", ") : "Kein Benutzer ausgewählt"}}
</template>
</USelectMenu>
</UFormGroup>

View File

@@ -20,6 +20,7 @@ defineShortcuts({
})
const dataStore = useDataStore()
const profileStore = useProfileStore()
const route = useRoute()
const router = useRouter()
const toast = useToast()
@@ -210,7 +211,7 @@ setupPage()
>
<USelectMenu
v-model="itemInfo.tags"
:options="dataStore.ownTenant.tags.products"
:options="profileStore.ownTenant.tags.products"
multiple
/>
</UFormGroup>

View File

@@ -1,5 +1,6 @@
<script setup>
const dataStore = useDataStore()
const profileStore = useProfileStore()
const route = useRoute()
const supabase = useSupabaseClient()
const toast = useToast()
@@ -43,7 +44,7 @@ const generateLink = async () => {
body: {
method: "generateLink",
institutionId: bankData.value.id,
tenant: dataStore.currentTenant
tenant: profileStore.currentTenant
}
})
@@ -62,7 +63,7 @@ const addAccount = async (account) => {
accountId: account.id,
ownerName: account.owner_name,
iban: account.iban,
tenant: dataStore.currentTenant,
tenant: profileStore.currentTenant,
bankId: account.institution_id
}

View File

@@ -2,6 +2,7 @@
import axios from "axios"
const supabase = useSupabaseClient()
const dataStore = useDataStore()
const profileStore = useProfileStore()
const createEMailAddress = ref("")
const createEMailType = ref("imap")
@@ -22,7 +23,7 @@ const createAccount = async () => {
body: {
emailAddress: createEMailAddress.value,
accountType: createEMailType.value,
profile: dataStore.activeProfile.id
profile: profileStore.activeProfile.id
}
})

View File

@@ -3,6 +3,7 @@ definePageMeta({
middleware: "auth"
})
const dataStore = useDataStore()
const profileStore = useProfileStore()
const supabase = useSupabaseClient()
const router = useRouter()
@@ -71,14 +72,14 @@ const isLight = computed({
/>
<InputGroup>
<UBadge
v-for="tag in dataStore.ownTenant.tags.documents"
v-for="tag in profileStore.ownTenant.tags.documents"
>
{{tag}}
</UBadge>
</InputGroup>
{{dataStore.ownTenant.tags}}
{{profileStore.ownTenant.tags}}
</div>
</UCard>

View File

@@ -87,6 +87,7 @@ defineShortcuts({
const router = useRouter()
const supabase = useSupabaseClient()
const dataStore = useDataStore()
const profileStore = useProfileStore()
const mode = useRoute().params.mode
const openTab = ref(0)
@@ -106,7 +107,7 @@ const renderDemoZPL = () => {
const printLabel = async () => {
await supabase.from("printJobs").insert({
tenant: dataStore.currentTenant,
tenant: profileStore.currentTenant,
rawContent: useGenerateZPL(itemInfo.value.handlebarsZPL,{barcode:"XXX"}),
printerName: "ZD411",
printServer: "0dbe30f3-3008-4cde-8a7c-e785b1c22bfc"

View File

@@ -5,6 +5,8 @@ definePageMeta({
const supabase = useSupabaseClient()
const dataStore = useDataStore()
const profileStore = useProfileStore()
const profileStore = useProfileStore()
@@ -38,14 +40,14 @@ const resources = {
}
}
const numberRanges = ref(dataStore.ownTenant.numberRanges)
const numberRanges = ref(profileStore.ownTenant.numberRanges)
const updateNumberRanges = async (range) => {
const {data,error} = await supabase
.from("tenants")
.update({numberRanges: numberRanges.value})
.eq('id',dataStore.currentTenant)
.eq('id',profileStore.currentTenant)
await dataStore.fetchOwnTenant()
}

View File

@@ -16,12 +16,6 @@ const setupPage = async () => {
>
</UDashboardNavbar>
{{dataStore.ownTenant.ownFields}}
</template>
<style scoped>

View File

@@ -1,6 +1,7 @@
<script setup>
const dataStore = useDataStore()
const profileStore = useProfileStore()
const supabase = useSupabaseClient()
const itemInfo = ref({
@@ -10,17 +11,17 @@ const itemInfo = ref({
})
const setupPage = async () => {
itemInfo.value = (await supabase.from("tenants").select().eq("id",dataStore.currentTenant).single()).data
itemInfo.value = (await supabase.from("tenants").select().eq("id",profileStore.currentTenant).single()).data
console.log(itemInfo.value)
}
const features = ref(dataStore.ownTenant.features)
const businessInfo = ref(dataStore.ownTenant.businessInfo)
const features = ref(profileStore.ownTenant.features)
const businessInfo = ref(profileStore.ownTenant.businessInfo)
const updateTenant = async (newData) => {
const {data,error} = await supabase.from("tenants")
.update(newData)
.eq("id",dataStore.currentTenant)
.eq("id",profileStore.currentTenant)
.select()
if (error) console.log(error)

View File

@@ -79,7 +79,7 @@ function getSpaceProductCount(productId) {
/*
const printSpaceLabel = async () => {
axios
.post(`http://${dataStore.ownTenant.value.labelPrinterIp}/pstprnt`, `^XA^FO10,20^BCN,100^FD${itemInfo.value.spaceNumber}^XZ` )
.post(`http://${profileStore.ownTenant.value.labelPrinterIp}/pstprnt`, `^XA^FO10,20^BCN,100^FD${itemInfo.value.spaceNumber}^XZ` )
.then(console.log)
.catch(console.log)
}

View File

@@ -4,6 +4,7 @@ definePageMeta({
})
const dataStore = useDataStore()
const profileStore = useProfileStore()
const route = useRoute()
const router = useRouter()
const toast = useToast()
@@ -12,7 +13,7 @@ const id = ref(route.params.id ? route.params.id : null )
//Working
const mode = ref(route.params.mode || "show")
const itemInfo = ref({
profile: dataStore.activeProfile.id
profile: profileStore.activeProfile.id
})
const oldItemInfo = ref({})
const categories = ["Offen", "In Bearbeitung", "Dringed", "Erledigt"]
@@ -148,7 +149,7 @@ setupPage()
>
<USelectMenu
v-model="itemInfo.profile"
:options="dataStore.profiles"
:options="profileStore.profiles"
option-attribute="fullName"
value-attribute="id"
searchable-placeholder="Suche..."
@@ -156,7 +157,7 @@ setupPage()
:search-attributes="['fullName']"
>
<template #label>
{{dataStore.getProfileById(itemInfo.profile) ? dataStore.getProfileById(itemInfo.profile).fullName : "Kein Benutzer ausgewählt"}}
{{profileStore.getProfileById(itemInfo.profile) ? profileStore.getProfileById(itemInfo.profile).fullName : "Kein Benutzer ausgewählt"}}
</template>
</USelectMenu>
</UFormGroup>

View File

@@ -64,7 +64,7 @@
{{row.created_at ? dayjs(row.created_at).format("DD.MM.YY HH:mm") : ''}}
</template>
<template #user-data="{row}">
{{dataStore.profiles.find(i => i.id === row.user) ? dataStore.profiles.find(i => i.id === row.user).fullName : ""}}
{{profileStore.profiles.find(i => i.id === row.user) ? profileStore.profiles.find(i => i.id === row.user).fullName : ""}}
</template>
<template #project-data="{row}">
{{dataStore.projects.find(i => i.id === row.project) ? dataStore.projects.find(i => i.id === row.project).name : ""}}
@@ -86,6 +86,7 @@ definePageMeta({
})
const dataStore = useDataStore()
const profileStore = useProfileStore()
const router = useRouter()
defineShortcuts({

View File

@@ -23,6 +23,7 @@ defineShortcuts({
})
const dataStore = useDataStore()
const profileStore = useProfileStore()
const route = useRoute()
const router = useRouter()
const toast = useToast()
@@ -205,7 +206,7 @@ setupPage()
</tr>
<tr>
<td>Fahrer:</td>
<td>{{dataStore.profiles.find(profile => profile.id === itemInfo.driver) ? dataStore.profiles.find(profile => profile.id === itemInfo.driver).fullName : 'Kein Fahrer gewählt'}}</td>
<td>{{profileStore.profiles.find(profile => profile.id === itemInfo.driver) ? profileStore.profiles.find(profile => profile.id === itemInfo.driver).fullName : 'Kein Fahrer gewählt'}}</td>
</tr>
<tr>
<td>Tankvolumen:</td>
@@ -334,13 +335,13 @@ setupPage()
>
<USelectMenu
v-model="itemInfo.driver"
:options="[{id: null, fullName: 'Kein Fahrer'},...dataStore.profiles]"
:options="[{id: null, fullName: 'Kein Fahrer'},...profileStore.profiles]"
option-attribute="fullName"
value-attribute="id"
>
<template #label>
{{dataStore.profiles.find(profile => profile.id === itemInfo.driver) ? dataStore.profiles.find(profile => profile.id === itemInfo.driver).fullName : 'Kein Fahrer ausgewählt'}}
{{profileStore.profiles.find(profile => profile.id === itemInfo.driver) ? profileStore.profiles.find(profile => profile.id === itemInfo.driver).fullName : 'Kein Fahrer ausgewählt'}}
</template>
</USelectMenu>
</UFormGroup>

View File

@@ -21,10 +21,9 @@ defineShortcuts({
})
const dataStore = useDataStore()
const profileStore = useProfileStore()
const route = useRoute()
const router = useRouter()
const toast = useToast()
const id = ref(route.params.id ? route.params.id : null )
const openTab = ref(0)
let currentItem = ref(null)
@@ -33,7 +32,8 @@ let currentItem = ref(null)
//Working
const mode = ref(route.params.mode || "show")
const itemInfo = ref({
infoData: {}
infoData: {},
profiles: [profileStore.activeProfile.id]
})
const oldItemInfo = ref({})
@@ -266,6 +266,23 @@ setupPage()
v-model="itemInfo.infoData.ustid"
/>
</UFormGroup>
<UFormGroup
label="Berechtigte Benutzer:"
>
<USelectMenu
v-model="itemInfo.profiles"
:options="profileStore.profiles"
option-attribute="fullName"
value-attribute="id"
searchable
multipledataStore
:search-attributes="['fullName']"
>
<template #label>
{{itemInfo.profiles.length > 0 ? itemInfo.profiles.map(i => profileStore.getProfileById(i).fullName).join(", ") : "Kein Benutzer ausgewählt"}}
</template>
</USelectMenu>
</UFormGroup>
</UForm>
</template>

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>