-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']"
>
- {{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"}}
diff --git a/pages/chats/show/[id].vue b/pages/chats/show/[id].vue
index ee17f99..2b480d6 100644
--- a/pages/chats/show/[id].vue
+++ b/pages/chats/show/[id].vue
@@ -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 () => {
diff --git a/pages/communication/historyItems/index.vue b/pages/communication/historyItems/index.vue
index 968cf1c..8c81f86 100644
--- a/pages/communication/historyItems/index.vue
+++ b/pages/communication/historyItems/index.vue
@@ -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) => {
diff --git a/pages/contacts/[mode]/[[id]].vue b/pages/contacts/[mode]/[[id]].vue
index e4fc1d1..65f491f 100644
--- a/pages/contacts/[mode]/[[id]].vue
+++ b/pages/contacts/[mode]/[[id]].vue
@@ -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()
+
+
+
+ {{itemInfo.profiles.length > 0 ? itemInfo.profiles.map(i => profileStore.getProfileById(i).fullName).join(", ") : "Kein Benutzer ausgewählt"}}
+
+
+
@@ -307,6 +326,7 @@ setupPage()
v-model="itemInfo.notes"
/>
+
diff --git a/pages/contracts/[mode]/[[id]].vue b/pages/contracts/[mode]/[[id]].vue
index 3524ff6..a9eb614 100644
--- a/pages/contracts/[mode]/[[id]].vue
+++ b/pages/contracts/[mode]/[[id]].vue
@@ -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()
Eigene Felder: |
- | {{dataStore.ownTenant.ownFields.contracts.find(i => i.key === fieldKey).label}} |
+ {{profileStore.ownTenant.ownFields.contracts.find(i => i.key === fieldKey).label}} |
{{itemInfo.ownFields[fieldKey]}} |
@@ -491,14 +492,14 @@ setupPage()
Eigene Felder
diff --git a/pages/createDocument/edit/[[id]].vue b/pages/createDocument/edit/[[id]].vue
index 5551f94..eb4a76d 100644
--- a/pages/createDocument/edit/[[id]].vue
+++ b/pages/createDocument/edit/[[id]].vue
@@ -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:"
>
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"
>
- {{row.product ? dataStore.getProductById(row.product).name : "Kein Produkt ausgewählt" }}
+ {{row.product ? products.find(i => i.id === row.product).name : "Kein Produkt ausgewählt" }}
{
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()
-
| {
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))
}
diff --git a/pages/createDocument/show/[id].vue b/pages/createDocument/show/[id].vue
index eae1a75..00bd902 100644
--- a/pages/createDocument/show/[id].vue
+++ b/pages/createDocument/show/[id].vue
@@ -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)
}
diff --git a/pages/customers/[mode]/[[id]].vue b/pages/customers/[mode]/[[id]].vue
index fbe2abb..74310b6 100644
--- a/pages/customers/[mode]/[[id]].vue
+++ b/pages/customers/[mode]/[[id]].vue
@@ -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"
/>
+
+
+
+ {{itemInfo.profiles.length > 0 ? itemInfo.profiles.map(i => profileStore.getProfileById(i).fullName).join(", ") : "Kein Benutzer ausgewählt"}}
+
+
+
diff --git a/pages/users/[mode]/[[id]].vue b/pages/deprecated/users/[mode]/[[id]].vue
similarity index 98%
rename from pages/users/[mode]/[[id]].vue
rename to pages/deprecated/users/[mode]/[[id]].vue
index a4d2b19..08f498a 100644
--- a/pages/users/[mode]/[[id]].vue
+++ b/pages/deprecated/users/[mode]/[[id]].vue
@@ -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()
{{dayjs(row.end).format("HH:mm")}}
- {{dataStore.getProfileById(row.user) ? dataStore.getProfileById(row.user).fullName : ""}}
+ {{profileStore.getProfileById(row.user) ? profileStore.getProfileById(row.user).fullName : ""}}
{{ getDuration(row).composed}} Std
diff --git a/pages/users/index.vue b/pages/deprecated/users/index.vue
similarity index 100%
rename from pages/users/index.vue
rename to pages/deprecated/users/index.vue
diff --git a/pages/documents.vue b/pages/documents.vue
index eee0793..9753c16 100644
--- a/pages/documents.vue
+++ b/pages/documents.vue
@@ -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)
diff --git a/pages/email/index.vue b/pages/email/index.vue
index 13ce4f0..f0f4e30 100644
--- a/pages/email/index.vue
+++ b/pages/email/index.vue
@@ -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) {
diff --git a/pages/email/new.vue b/pages/email/new.vue
index cfce0cd..8e935d6 100644
--- a/pages/email/new.vue
+++ b/pages/email/new.vue
@@ -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 = `${dataStore.activeProfile.emailSignature}`
+ preloadedContent.value = `${profileStore.activeProfile.emailSignature}`
//Check Query
if(route.query.to) emailData.value.to = route.query.to
diff --git a/pages/employees/timetracking.vue b/pages/employees/timetracking.vue
index 257356d..88d2c4a 100644
--- a/pages/employees/timetracking.vue
+++ b/pages/employees/timetracking.vue
@@ -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) => {
- {{dataStore.getProfileById(filterUser) ? dataStore.getProfileById(filterUser).fullName : "Kein Benutzer ausgewählt"}}
+ {{profileStore.getProfileById(filterUser) ? profileStore.getProfileById(filterUser).fullName : "Kein Benutzer ausgewählt"}}
@@ -339,14 +340,14 @@ const setState = async (newState) => {
label="Benutzer:"
>
- {{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"}}
@@ -444,7 +445,7 @@ const setState = async (newState) => {
>{{row.state}}
- {{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 }}
diff --git a/pages/events/[mode]/[[id]].vue b/pages/events/[mode]/[[id]].vue
index b10130f..411314b 100644
--- a/pages/events/[mode]/[[id]].vue
+++ b/pages/events/[mode]/[[id]].vue
@@ -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 => {
diff --git a/pages/index.vue b/pages/index.vue
index b9e1bd3..df0bf44 100644
--- a/pages/index.vue
+++ b/pages/index.vue
@@ -18,7 +18,7 @@
title="Anwesenheiten"
v-if="dataStore.getStartedWorkingTimes().length > 0"
>
- {{dataStore.getProfileById(time.profile).fullName}}
+ {{profileStore.getProfileById(time.profile).fullName}}
|