mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 22:39:34 +00:00
[Unscheduled time] Added unscheduled time to tasks and teams
This commit is contained in:
1 parent
d93e356265
commit
e3b1460c83
5 files changed
+78
-34
No files matched your search
@@ -11,10 +11,7 @@ export default {
|
||||
|
||||
const blockers = this._generateBlockers()
|
||||
|
||||
console.log([...this._generateNonWorking(), ...this._generateTasks(), ...blockers.filter(blocker => blocker.type != 'home_office')])
|
||||
|
||||
return {
|
||||
unscheduledTime: 333,
|
||||
tasks: [...this._generateNonWorking(), ...this._generateTasks(), ...blockers.filter(blocker => blocker.type != 'home_office')],
|
||||
homeoffices: [...blockers.filter(blocker => blocker.type == 'home_office')]
|
||||
}
|
||||
@@ -23,15 +20,30 @@ export default {
|
||||
splitDays() {
|
||||
const days = []
|
||||
const homeoffice = {}
|
||||
const now = moment()
|
||||
|
||||
this.filter.team.employees.forEach((employee, index) => {
|
||||
let workingHours = 0
|
||||
const selectedDate = moment(this.filter.start)
|
||||
const capacityMinutes = this._getRemainingWorkCapacityMinutes(employee)
|
||||
let scheduledCapacityMinutes = 0
|
||||
|
||||
this.calendarData.tasks.forEach(task => {
|
||||
if ((task.subtask?.employee?.id != employee.id) && (task.blocker?.employee?.id != employee.id))
|
||||
// console.log(task)
|
||||
if ((task.subtask?.employee_id != employee.id) && (task.blocker?.employee?.id != employee.id))
|
||||
return
|
||||
|
||||
workingHours += timelineUtils._getDifferenceInHours(task.end, task.start)
|
||||
if (task.type == 'non-working-hours' || task.subtask?.is_finished || task.blocker?.is_finished)
|
||||
return
|
||||
|
||||
if (selectedDate.isBefore(moment(), 'days')) {
|
||||
// Past
|
||||
return
|
||||
} else if (selectedDate.isSame(moment(), 'days')) {
|
||||
// Today
|
||||
|
||||
} else {
|
||||
scheduledCapacityMinutes += timelineUtils._getDifferenceInMinutes(task._real_end, task._real_start)
|
||||
}
|
||||
})
|
||||
|
||||
this.calendarData.homeoffices.forEach(task => {
|
||||
@@ -40,12 +52,14 @@ export default {
|
||||
homeoffice[task.split] = true
|
||||
})
|
||||
|
||||
const unscheduledTime = capacityMinutes - scheduledCapacityMinutes
|
||||
|
||||
days.push({
|
||||
id: index + 1,
|
||||
name: employee.name,
|
||||
fullname: `${employee.name} ${employee.surname}`,
|
||||
initials: employee.name.charAt(0).toUpperCase() + employee.surname.charAt(0).toUpperCase(),
|
||||
unscheduledTime: workingHours,
|
||||
unscheduledTime: unscheduledTime > 0 ? (unscheduledTime / 60).toFixed(1) : 0,
|
||||
isHomeoffice: homeoffice[index + 1] ? true : false
|
||||
})
|
||||
})
|
||||
@@ -122,8 +136,11 @@ export default {
|
||||
initials: employee?.name?.charAt(0)?.toUpperCase() + employee?.surname?.charAt(0)?.toUpperCase(),
|
||||
split: split,
|
||||
project_code: subtask.project_code,
|
||||
type: 'subtask',
|
||||
subtask,
|
||||
_timeblock_id: timeblock.id
|
||||
_timeblock_id: timeblock.id,
|
||||
_real_start: new Date(timeblock.start),
|
||||
_real_end: new Date(timeblock.end)
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -157,6 +174,8 @@ export default {
|
||||
color: '#B00020',
|
||||
draggable: false,
|
||||
isWeekend: moment(blocker.start).day() % 6 == 0,
|
||||
_real_start: new Date(blocker.start),
|
||||
_real_end: new Date(blocker.end)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -173,6 +192,31 @@ export default {
|
||||
_setMinutesToDate(minutes, date = new Date(this.filter.start)) {
|
||||
date.setHours(Math.floor(minutes / 60), minutes % 60, 0, 0)
|
||||
return date
|
||||
},
|
||||
|
||||
_getRemainingWorkCapacityMinutes(employee) {
|
||||
const date = moment(this.filter.start)
|
||||
const now = moment()
|
||||
|
||||
if (now.isAfter(date, 'days')) {
|
||||
// Past dates
|
||||
return 0
|
||||
} else if (now.isBefore(date, 'days')) {
|
||||
// Future dates
|
||||
return (employee.work_end - employee.work_start) * 60
|
||||
}
|
||||
|
||||
// Today
|
||||
const workStartMinutes = employee.work_start * 60
|
||||
const workEndMinutes = employee.work_end * 60
|
||||
const elapsedMinutesOfCurrenyDay = now.diff(moment().startOf('day'), 'minutes')
|
||||
|
||||
if (workStartMinutes > elapsedMinutesOfCurrenyDay)
|
||||
return workEndMinutes - workStartMinutes
|
||||
else if (workEndMinutes < elapsedMinutesOfCurrenyDay)
|
||||
return 0
|
||||
else
|
||||
return workEndMinutes - elapsedMinutesOfCurrenyDay
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user