Rebuild Times in Projects

Added Icons
Rebuild Time Duration
This commit is contained in:
2023-12-07 12:14:19 +01:00
parent 36371f94e8
commit 5182959881
6 changed files with 118 additions and 17 deletions

View File

@@ -122,8 +122,35 @@ export const useDataStore = defineStore('data', {
getOpenTasksCount: (state) => state.tasks.filter(task => task.categorie != "Erledigt").length,
movementsBySpace: (state) => (spaceId:number) => state.movements.filter(move => move.spaceId === spaceId),
getProductById: (state) => (productId:number) => state.products.find(product => product.id === productId),
getProjectById: (state) => (projectId:number) => state.projects.find(project => project.id === projectId),
getProjectById: (state) => (projectId:number) => {
let project = state.projects.find(project => project.id === projectId)
let projectHours = 0
let projectTimes = state.times.filter(time => time.projectId === projectId)
projectTimes.forEach(time => projectHours += time.duration)
project.projectHours = projectHours
return project
},
getCustomerById: (state) => (customerId:number) => state.customers.find(customer => customer.id === customerId),
getTimesByProjectId: (state) => (projectId:number) => {
let times = state.times.filter(time => time.projectId === projectId)
console.log(times.length)
/*const mapNumRange = (num, inMin, inMax, outMin, outMax) =>
((num - inMin) * (outMax - outMin)) / (inMax - inMin) + outMin;
times.forEach((time,index) => {
times[index].duration = Math.round(mapNumRange(Math.abs(new Date(time.end) - new Date(time.start))/1000/60,0,60,0,1)*100)/100
})*/
return times
},
getFormSubmitsWithLabelProp: (state) => (state.formSubmits.map(submit => {return{...submit, label: submit.id}})),
getResources: (state) => {
return [