mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-22 06:49:35 +00:00
[Tasks] Unscheduled time fix
This commit is contained in:
1 parent
aac8620a0f
commit
e2a401b938
3 files changed
+64
-14
No files matched your search
@@ -36,36 +36,78 @@ export default {
|
||||
]),
|
||||
|
||||
splitDays() {
|
||||
const days = []
|
||||
const workingHours = {}
|
||||
const homeoffice = {}
|
||||
const days = []
|
||||
const homeoffice = {}
|
||||
const schedulesCapacityBySplit = {}
|
||||
|
||||
const now = moment()
|
||||
const dailyCapacityMinutes = this.user.work_end - this.user.work_start
|
||||
|
||||
this.timelineData.tasks.forEach(task => {
|
||||
if (!workingHours[task.split])
|
||||
workingHours[task.split] = 0
|
||||
|
||||
if (task.type == 'non-working-hours' || task.subtask?.is_finished || task.blocker?.is_finished)
|
||||
return
|
||||
|
||||
workingHours[task.split] += timelineUtils._getDifferenceInHours(task.end, task.start)
|
||||
if (!schedulesCapacityBySplit[task.split])
|
||||
schedulesCapacityBySplit[task.split] = 0
|
||||
|
||||
if (now.isAfter(moment(task._real_end))) {
|
||||
// Ignore elapsed task
|
||||
return
|
||||
}
|
||||
else if (now.isAfter(moment(task._real_start) && now.isBefore(moment(task._real_end)))) {
|
||||
// Task in progress
|
||||
schedulesCapacityBySplit[task.split] += timelineUtils._getDifferenceInMinutes(task._real_end, new Date())
|
||||
}
|
||||
else {
|
||||
// Future task
|
||||
schedulesCapacityBySplit[task.split] += timelineUtils._getDifferenceInMinutes(task._real_end, task._real_start)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
schedulesCapacityBySplit[1] = 0 // Set YESTERDAY value to 0
|
||||
|
||||
this.timelineData.homeoffices.forEach(task => {
|
||||
homeoffice[task.split] = true
|
||||
})
|
||||
|
||||
for (let i = 0; i < 7; i++) {
|
||||
if (!schedulesCapacityBySplit[i + 1])
|
||||
schedulesCapacityBySplit[i + 1] = 0
|
||||
|
||||
let unscheduledTime
|
||||
|
||||
if (i == 0) {
|
||||
// Yesterday
|
||||
unscheduledTime = 0
|
||||
} else if (i == 1) {
|
||||
// Today
|
||||
const elapsedMinutes = now.diff(now.clone().startOf('day'), 'minutes')
|
||||
const workStart = this.user.work_start > elapsedMinutes ? this.user.workStart : elapsedMinutes
|
||||
const todayCapacityMinutes = this.user.work_end - workStart
|
||||
unscheduledTime = todayCapacityMinutes - schedulesCapacityBySplit[i + 1] < 0 ? 0 : todayCapacityMinutes - schedulesCapacityBySplit[i + 1]
|
||||
} else {
|
||||
// Future
|
||||
unscheduledTime = dailyCapacityMinutes - schedulesCapacityBySplit[i + 1]
|
||||
}
|
||||
|
||||
console.log(unscheduledTime)
|
||||
|
||||
days.push({
|
||||
id: i + 1,
|
||||
fullname: `${this.filter.employee.name} ${this.filter.employee.surname}`,
|
||||
initials: this.filter.employee.name.charAt(0).toUpperCase() + this.filter.employee.surname.charAt(0).toUpperCase(),
|
||||
unscheduledTime: workingHours[i + 1],
|
||||
unscheduledTime: (unscheduledTime / 60).toFixed(1),
|
||||
date: addDays(this.filter.start, i),
|
||||
isHomeoffice: homeoffice[i],
|
||||
isWeekend: timelineUtils.isWeekend(addDays(this.filter.start, i))
|
||||
})
|
||||
}
|
||||
|
||||
console.log(days)
|
||||
|
||||
return days
|
||||
},
|
||||
|
||||
|
||||
Reference in new issue
Block a user