Many Changes

This commit is contained in:
2024-02-18 19:51:00 +01:00
parent 1a0b7288df
commit fa0eb73363
11 changed files with 720 additions and 322 deletions

View File

@@ -163,6 +163,7 @@ export const useDataStore = defineStore('data', () => {
const workingtimes = ref([])
const phasesTemplates = ref([])
const emailAccounts = ref([])
const texttemplates =ref([])
const rights = ref({
@@ -277,6 +278,7 @@ export const useDataStore = defineStore('data', () => {
await fetchWorkingTimes()
await fetchPhasesTemplates()
await fetchEmailAccounts()
await fetchTextTemplates()
loaded.value = true
}
@@ -318,6 +320,7 @@ export const useDataStore = defineStore('data', () => {
workingtimes.value = []
phasesTemplates.value = []
emailAccounts.value = []
texttemplates.value = []
}
function hasRight (right) {
@@ -574,6 +577,10 @@ export const useDataStore = defineStore('data', () => {
emailAccounts.value = (await supabase.from("emailAccounts").select().eq('tenant', currentTenant.value)).data
}
async function fetchTextTemplates() {
texttemplates.value = (await supabase.from("textTemplates").select().eq('tenant', currentTenant.value)).data
}
async function fetchDocuments () {
let tempDocuments = (await supabase.from("documents").select().eq('tenant', currentTenant.value)).data
@@ -680,6 +687,10 @@ export const useDataStore = defineStore('data', () => {
return documents.value.filter(item => item.product === itemId && !item.tags.includes("Archiviert"))
})
const getDocumentsByVendorId = computed(() => (itemId) => {
return documents.value.filter(item => item.vendor === itemId && !item.tags.includes("Archiviert"))
})
const getEventsByProjectId = computed(() => (projectId) => {
return events.value.filter(item => item.project === projectId)
})
@@ -712,6 +723,10 @@ export const useDataStore = defineStore('data', () => {
return messages.value.filter(i => i.destination === chatId)
})
const getTextTemplatesByDocumentType = computed(() => (documentType) => {
return texttemplates.value.filter(i => i.documentType === documentType)
})
const getStockByProductId = computed(() => (productId) => {
let productMovements = movements.value.filter(movement => movement.productId === productId)
@@ -1006,6 +1021,7 @@ export const useDataStore = defineStore('data', () => {
workingtimes,
phasesTemplates,
emailAccounts,
texttemplates,
documentTypesForCreation,
//Functions
@@ -1057,6 +1073,7 @@ export const useDataStore = defineStore('data', () => {
getDocumentsByContractId,
getDocumentsByVehicleId,
getDocumentsByProductId,
getDocumentsByVendorId,
getEventsByProjectId,
getTimesByProjectId,
getTasksByProjectId,
@@ -1064,6 +1081,7 @@ export const useDataStore = defineStore('data', () => {
getProjectsByPlantId,
getMovementsBySpaceId,
getMessagesByChatId,
getTextTemplatesByDocumentType,
getStockByProductId,
getIncomingInvoicesByVehicleId,
getEventTypes,