diff --git a/RechteDoku.xlsx b/RechteDoku.xlsx new file mode 100644 index 0000000..c81d021 Binary files /dev/null and b/RechteDoku.xlsx differ diff --git a/app.vue b/app.vue index cec450a..cab9291 100644 --- a/app.vue +++ b/app.vue @@ -6,8 +6,6 @@ const tenants = (await supabase.from("tenants").select()).data const dataStore = useDataStore() const viewport = useViewport() -console.log("1.") - /*watch(viewport.breakpoint, (newBreakpoint, oldBreakpoint) => { console.log('Breakpoint updated:', oldBreakpoint, '->', newBreakpoint) })*/ diff --git a/components/DocumentDisplay.vue b/components/DocumentDisplay.vue index 5411188..e506a33 100644 --- a/components/DocumentDisplay.vue +++ b/components/DocumentDisplay.vue @@ -3,6 +3,7 @@ const toast = useToast() const supabase = useSupabaseClient() const dataStore = useDataStore() +const profileStore = useProfileStore() const router = useRouter() const props = defineProps({ documentData: { @@ -61,7 +62,7 @@ const createVendorInvoice = async () => { .from("incominginvoices") .insert([{ document: documentData.id, - tenant: dataStore.currentTenant + tenant: profileStore.currentTenant }]) .select() if(vendorInvoiceError) { diff --git a/components/DocumentUpload.vue b/components/DocumentUpload.vue index 9f806a3..a7ba1bb 100644 --- a/components/DocumentUpload.vue +++ b/components/DocumentUpload.vue @@ -12,6 +12,7 @@ const props = defineProps({ const {type, elementId} = props const dataStore = useDataStore() +const profileStore = useProfileStore() const tags = dataStore.getDocumentTags const uploadModalOpen = ref(false) @@ -19,7 +20,7 @@ const uploadInProgress = ref(false) const fileUploadFormData = ref({ tags: ["Dokument"], project: null, - tenant: dataStore.currentTenant + tenant: profileStore.currentTenant }) const openModal = () => { diff --git a/components/EntityList.vue b/components/EntityList.vue index b5ba3c7..8dcdc40 100644 --- a/components/EntityList.vue +++ b/components/EntityList.vue @@ -46,6 +46,7 @@ defineShortcuts({ const router = useRouter() const dataStore = useDataStore() +const profileStore = useProfileStore() const dataType = dataStore.dataTypes[type] @@ -81,7 +82,7 @@ const filteredRows = computed(() => { } else if(useRole().checkRight(type)){ console.log("Only Righty to show Own") console.log(tempItems) - tempItems = tempItems.filter(item => item.profiles.includes(dataStore.activeProfile.id)) + tempItems = tempItems.filter(item => item.profiles.includes(profileStore.activeProfile.id)) } else { console.log("No Right to Show") tempItems = [] diff --git a/components/HelpSlideover.vue b/components/HelpSlideover.vue index a635fde..2c273b6 100644 --- a/components/HelpSlideover.vue +++ b/components/HelpSlideover.vue @@ -4,6 +4,7 @@ const { metaSymbol } = useShortcuts() const shortcuts = ref(false) const dataStore = useDataStore() +const profileStore = useProfileStore() const query = ref('') const supabase = useSupabaseClient() const toast = useToast() @@ -101,12 +102,12 @@ const filteredCategories = computed(() => { const contactRequestData = ref({ source: "helpSlideover", - tenant: dataStore.currentTenant, + tenant: profileStore.currentTenant, message: "", title: "", - contactName: dataStore.activeProfile.fullName, - contactTel: dataStore.activeProfile.phoneMobile || dataStore.activeProfile.phoneHome, - contactMail: dataStore.activeProfile.email, + contactName: profileStore.activeProfile.fullName, + contactTel: profileStore.activeProfile.phoneMobile || profileStore.activeProfile.phoneHome, + contactMail: profileStore.activeProfile.email, contactType: "Hilfe", currentPath: router.currentRoute }) @@ -125,12 +126,12 @@ const addContactRequest = async () => { const resetContactRequest = () => { contactRequestData.value = { source: "helpSlideover", - tenant: dataStore.currentTenant, + tenant: profileStore.currentTenant, message: "", title: "", - contactName: dataStore.activeProfile.fullName, - contactTel: dataStore.activeProfile.phoneMobile || dataStore.activeProfile.phoneHome, - contactMail: dataStore.activeProfile.email, + contactName: profileStore.activeProfile.fullName, + contactTel: profileStore.activeProfile.phoneMobile || profileStore.activeProfile.phoneHome, + contactMail: profileStore.activeProfile.email, contactType: "Hilfe" } } diff --git a/components/HistoryDisplay.vue b/components/HistoryDisplay.vue index 774b1b3..feab0fd 100644 --- a/components/HistoryDisplay.vue +++ b/components/HistoryDisplay.vue @@ -14,7 +14,7 @@ const props = defineProps({ } }) const { metaSymbol } = useShortcuts() -const dataStore = useDataStore() +const profileStore = useProfileStore() const user = useSupabaseUser() const supabase = useSupabaseClient() const toast = useToast() @@ -79,13 +79,13 @@ const addHistoryItemData = ref({ const addHistoryItem = async () => { console.log(addHistoryItemData.value) - addHistoryItemData.value.createdBy = dataStore.activeProfile.id + addHistoryItemData.value.createdBy = profileStore.activeProfile.id addHistoryItemData.value[type] = elementId const {data,error} = await supabase .from("historyitems") - .insert([{...addHistoryItemData.value, tenant: dataStore.currentTenant}]) + .insert([{...addHistoryItemData.value, tenant: profileStore.currentTenant}]) .select() if(error) { @@ -100,9 +100,9 @@ const addHistoryItem = async () => { let rawUsername = i[1] return { - tenant: dataStore.currentTenant, + tenant: profileStore.currentTenant, profile: profiles.find(x => x.username === rawUsername).id, - initiatingProfile: dataStore.activeProfile.id, + initiatingProfile: profileStore.activeProfile.id, title: "Sie wurden im Logbuch erwähnt", link: `/${type}s/show/${elementId}`, message: addHistoryItemData.value.text @@ -198,11 +198,11 @@ const renderText = (text) => { :src="colorMode.value === 'light' ? '/Logo.png' : '/Logo_Dark.png' " />
-

{{dataStore.getProfileById(item.createdBy) ? dataStore.getProfileById(item.createdBy).fullName : ""}}

+

{{profileStore.getProfileById(item.createdBy) ? profileStore.getProfileById(item.createdBy).fullName : ""}}

FEDEO Bot


{{dayjs(item.created_at).format("DD.MM.YY HH:mm")}} diff --git a/components/MainNav.vue b/components/MainNav.vue index 8a4c3c3..9bbea02 100644 --- a/components/MainNav.vue +++ b/components/MainNav.vue @@ -1,13 +1,10 @@ \ No newline at end of file diff --git a/components/ProfileSelection.vue b/components/ProfileSelection.vue index 01dbb63..49ce1f3 100644 --- a/components/ProfileSelection.vue +++ b/components/ProfileSelection.vue @@ -1,6 +1,6 @@ @@ -84,6 +84,7 @@ defineShortcuts({ }) const dataStore = useDataStore() +const profileStore = useProfileStore() const router = useRouter() const templateColumns = [ diff --git a/pages/banking/index.vue b/pages/banking/index.vue index 5476542..51b5f87 100644 --- a/pages/banking/index.vue +++ b/pages/banking/index.vue @@ -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 } diff --git a/pages/banking/statements/[mode]/[[id]].vue b/pages/banking/statements/[mode]/[[id]].vue index 6acb7b1..57a42f6 100644 --- a/pages/banking/statements/[mode]/[[id]].vue +++ b/pages/banking/statements/[mode]/[[id]].vue @@ -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) { diff --git a/pages/chat.vue b/pages/chat.vue index 64c8685..421b901 100644 --- a/pages/chat.vue +++ b/pages/chat.vue @@ -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" > @@ -49,13 +50,13 @@ const messageText = ref("") {{message.text}}
-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']" > 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() + + + + + @@ -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:" > @@ -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" /> + + + + + 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")}}
@@ -339,14 +340,14 @@ const setState = async (newState) => { label="Benutzer:" > @@ -444,7 +445,7 @@ const setState = async (newState) => { >{{row.state}}