Added Chat
Restructured Calendar Some Changes in Timetracking
This commit is contained in:
@@ -51,6 +51,9 @@ export const useDataStore = defineStore('data', () => {
|
||||
const accounts = ref([])
|
||||
const taxTypes = ref([])
|
||||
const plants = ref([])
|
||||
const inventoryItems = ref([])
|
||||
const chats = ref([])
|
||||
const messages = ref([])
|
||||
|
||||
async function fetchData () {
|
||||
fetchDocuments()
|
||||
@@ -82,6 +85,9 @@ export const useDataStore = defineStore('data', () => {
|
||||
await fetchAccounts()
|
||||
await fetchTaxTypes()
|
||||
await fetchPlants()
|
||||
await fetchInventoryItems()
|
||||
await fetchChats()
|
||||
await fetchMessages()
|
||||
loaded.value = true
|
||||
}
|
||||
|
||||
@@ -116,6 +122,9 @@ export const useDataStore = defineStore('data', () => {
|
||||
accounts.value = []
|
||||
taxTypes.value = []
|
||||
plants.value = []
|
||||
inventoryItems.value = []
|
||||
chats.value = []
|
||||
messages.value = []
|
||||
}
|
||||
|
||||
async function fetchOwnTenant () {
|
||||
@@ -201,6 +210,15 @@ export const useDataStore = defineStore('data', () => {
|
||||
async function fetchPlants () {
|
||||
plants.value = (await supabase.from("plants").select()).data
|
||||
}
|
||||
async function fetchInventoryItems () {
|
||||
inventoryItems.value = (await supabase.from("inventoryItems").select()).data
|
||||
}
|
||||
async function fetchChats() {
|
||||
chats.value = (await supabase.from("chats").select()).data
|
||||
}
|
||||
async function fetchMessages() {
|
||||
messages.value = (await supabase.from("messages").select().order('created_at', {ascending:true})).data
|
||||
}
|
||||
|
||||
async function fetchDocuments () {
|
||||
documents.value = (await supabase.from("documents").select()).data
|
||||
@@ -257,6 +275,10 @@ export const useDataStore = defineStore('data', () => {
|
||||
return documents.value.filter(item => item.project === projectId)
|
||||
})
|
||||
|
||||
const getEventsByProjectId = computed(() => (projectId:string) => {
|
||||
return events.value.filter(item => item.project === projectId)
|
||||
})
|
||||
|
||||
const getTimesByProjectId = computed(() => (projectId:string) => {
|
||||
return times.value.filter(time => time.projectId === projectId)
|
||||
})
|
||||
@@ -281,6 +303,10 @@ export const useDataStore = defineStore('data', () => {
|
||||
return movements.value.filter(movement => movement.spaceId === spaceId)
|
||||
})
|
||||
|
||||
const getMessagesByChatId = computed(() => (chatId:string) => {
|
||||
return messages.value.filter(i => i.destination === chatId)
|
||||
})
|
||||
|
||||
const getStockByProductId = computed(() => (productId:string) => {
|
||||
let productMovements = movements.value.filter(movement => movement.productId === productId)
|
||||
|
||||
@@ -322,7 +348,14 @@ export const useDataStore = defineStore('data', () => {
|
||||
return {
|
||||
type: 'Fahrzeug',
|
||||
title: vehicle.licensePlate,
|
||||
id: vehicle.licensePlate
|
||||
id: `F-${vehicle.id}`
|
||||
}
|
||||
}),
|
||||
...inventoryItems.value.filter(i=> i.usePlanning).map(item => {
|
||||
return {
|
||||
type: 'Inventar',
|
||||
title: item.name,
|
||||
id: `I-${item.id}`
|
||||
}
|
||||
})
|
||||
]
|
||||
@@ -333,6 +366,72 @@ export const useDataStore = defineStore('data', () => {
|
||||
...events.value.map(event => {
|
||||
let eventColor = ownTenant.value.calendarConfig.eventTypes.find(type => type.label === event.type).color
|
||||
|
||||
let title = ""
|
||||
if(event.title) {
|
||||
title = event.title
|
||||
} else if(event.project) {
|
||||
projects.value.find(i => i.id === event.project) ? projects.value.find(i => i.id === event.project).name : ""
|
||||
}
|
||||
|
||||
return {
|
||||
...event,
|
||||
title: title,
|
||||
borderColor: eventColor,
|
||||
textColor: eventColor,
|
||||
backgroundColor: "black"
|
||||
}
|
||||
}),
|
||||
...absenceRequests.value.map(absence => {
|
||||
return {
|
||||
resourceId: absence.user,
|
||||
resourceType: "person",
|
||||
title: absence.reason,
|
||||
start: dayjs(absence.start).toDate(),
|
||||
end: dayjs(absence.end).add(1,'day').toDate(),
|
||||
allDay: true
|
||||
}
|
||||
})
|
||||
]
|
||||
})
|
||||
|
||||
const getEventsByResource = computed(() => {
|
||||
let tempEvents = []
|
||||
events.value.forEach(event => {
|
||||
event.resources.forEach(resource => {
|
||||
let eventColor = ownTenant.value.calendarConfig.eventTypes.find(type => type.label === event.type).color
|
||||
|
||||
let title = ""
|
||||
if(event.title) {
|
||||
title = event.title
|
||||
} else if(event.project) {
|
||||
projects.value.find(i => i.id === event.project) ? projects.value.find(i => i.id === event.project).name : ""
|
||||
}
|
||||
|
||||
|
||||
|
||||
tempEvents.push({
|
||||
...event,
|
||||
resourceId: resource.type !== 'Mitarbeiter' ? `${resource.type[0]}-${resource.id}`: resource.id,
|
||||
resourceType: resource.type,
|
||||
title: title,
|
||||
borderColor: eventColor,
|
||||
textColor: eventColor,
|
||||
backgroundColor: "black"
|
||||
})
|
||||
|
||||
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
|
||||
return [
|
||||
...tempEvents,
|
||||
/*...events.value.map(event => {
|
||||
|
||||
|
||||
let eventColor = ownTenant.value.calendarConfig.eventTypes.find(type => type.label === event.type).color
|
||||
|
||||
return {
|
||||
...event,
|
||||
title: !event.title ? projects.value.find(i => i.id === event.project).name : event.title,
|
||||
@@ -340,7 +439,7 @@ export const useDataStore = defineStore('data', () => {
|
||||
textColor: eventColor,
|
||||
backgroundColor: "black"
|
||||
}
|
||||
}),
|
||||
}),*/
|
||||
...absenceRequests.value.map(absence => {
|
||||
return {
|
||||
resourceId: absence.user,
|
||||
@@ -479,6 +578,9 @@ export const useDataStore = defineStore('data', () => {
|
||||
accounts,
|
||||
taxTypes,
|
||||
plants,
|
||||
inventoryItems,
|
||||
chats,
|
||||
messages,
|
||||
//Functions
|
||||
fetchData,
|
||||
clearStore,
|
||||
@@ -508,6 +610,9 @@ export const useDataStore = defineStore('data', () => {
|
||||
fetchDocuments,
|
||||
fetchAbsenceRequests,
|
||||
fetchPlants,
|
||||
fetchInventoryItems,
|
||||
fetchChats,
|
||||
fetchMessages,
|
||||
addHistoryItem,
|
||||
//Getters
|
||||
getOpenTasksCount,
|
||||
@@ -515,11 +620,13 @@ export const useDataStore = defineStore('data', () => {
|
||||
getContactsByCustomerId,
|
||||
getContactsByVendorId,
|
||||
getDocumentsByProjectId,
|
||||
getEventsByProjectId,
|
||||
getTimesByProjectId,
|
||||
getTasksByProjectId,
|
||||
getTasksByPlantId,
|
||||
getProjectsByPlantId,
|
||||
getMovementsBySpaceId,
|
||||
getMessagesByChatId,
|
||||
getStockByProductId,
|
||||
getIncomingInvoicesByVehicleId,
|
||||
getEventTypes,
|
||||
@@ -528,6 +635,7 @@ export const useDataStore = defineStore('data', () => {
|
||||
getMeasures,
|
||||
getResources,
|
||||
getEvents,
|
||||
getEventsByResource,
|
||||
getCostCentresComposed,
|
||||
getProductById,
|
||||
getVendorById,
|
||||
|
||||
Reference in New Issue
Block a user