mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 14:29:34 +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
@@ -85,12 +85,12 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="event-footer d-flex">
|
<div class="event-footer d-flex">
|
||||||
<template v-if="event.type == 'blocker'">
|
<template v-if="event.type == 'adhoc'">
|
||||||
<v-btn rounded class="event-footer-button me-2" @click.stop="editBlocker(event)"><img :src="require('@/plugins/app/_img/icons/pencil.svg')" alt=""></v-btn>
|
<v-btn rounded class="event-footer-button me-2" @click.stop="editBlocker(event)"><img :src="require('@/plugins/app/_img/icons/pencil.svg')" alt=""></v-btn>
|
||||||
<v-btn rounded class="event-footer-button me-2" @click.stop="deleteBlocker(event)"><img :src="require('@/plugins/app/_img/icons/bin.svg')" alt=""></v-btn>
|
<v-btn rounded class="event-footer-button me-2" @click.stop="deleteBlocker(event)"><img :src="require('@/plugins/app/_img/icons/bin.svg')" alt=""></v-btn>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-else>
|
<template v-else-if="event.type == 'subtask'">
|
||||||
<v-btn rounded class="event-footer-button me-2" :class="{'completed': event.subtask?.is_finished}" @click.stop="completeTask(event)"><img :src="require('@/plugins/app/_img/icons/checkmark.svg')" alt=""></v-btn>
|
<v-btn rounded class="event-footer-button me-2" :class="{'completed': event.subtask?.is_finished}" @click.stop="completeTask(event)"><img :src="require('@/plugins/app/_img/icons/checkmark.svg')" alt=""></v-btn>
|
||||||
<v-btn rounded class="event-footer-button me-2" @click.stop="editTask(event)"><img :src="require('@/plugins/app/_img/icons/eye.svg')" alt=""></v-btn>
|
<v-btn rounded class="event-footer-button me-2" @click.stop="editTask(event)"><img :src="require('@/plugins/app/_img/icons/eye.svg')" alt=""></v-btn>
|
||||||
<v-btn rounded class="event-footer-button me-2" @click.stop="deleteTask(event)"><img :src="require('@/plugins/app/_img/icons/bin.svg')" alt=""></v-btn>
|
<v-btn rounded class="event-footer-button me-2" @click.stop="deleteTask(event)"><img :src="require('@/plugins/app/_img/icons/bin.svg')" alt=""></v-btn>
|
||||||
|
|||||||
@@ -61,7 +61,9 @@ export default {
|
|||||||
project_code: subtask.project_code,
|
project_code: subtask.project_code,
|
||||||
subtask: subtask,
|
subtask: subtask,
|
||||||
type: 'subtask',
|
type: 'subtask',
|
||||||
_timeblock_id: timeblock.id
|
_timeblock_id: timeblock.id,
|
||||||
|
_real_start: new Date(timeblock.start),
|
||||||
|
_real_end: new Date(timeblock.end)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -85,7 +87,9 @@ export default {
|
|||||||
isBlocker: true,
|
isBlocker: true,
|
||||||
initials: `${blocker.employee?.name[0]}${blocker.employee?.surname[0]}`,
|
initials: `${blocker.employee?.name[0]}${blocker.employee?.surname[0]}`,
|
||||||
color: '#B00020',
|
color: '#B00020',
|
||||||
draggable: false
|
draggable: false,
|
||||||
|
_real_start: dStart,
|
||||||
|
_real_end: dEnd
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -136,8 +140,12 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_getDifferenceInHours(date1, date2) {
|
_getDifferenceInHours(date1, date2) {
|
||||||
let diff =(date1.getTime() - date2.getTime()) / 1000;
|
return this._getDifferenceInMinutes(date1, date2) / 60
|
||||||
diff /= (60 * 60)
|
},
|
||||||
|
|
||||||
|
_getDifferenceInMinutes(date1, date2) {
|
||||||
|
let diff = (date1.getTime() - date2.getTime()) / 1000
|
||||||
|
diff /= 60
|
||||||
return Math.abs(Math.round(diff))
|
return Math.abs(Math.round(diff))
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -36,36 +36,78 @@ export default {
|
|||||||
]),
|
]),
|
||||||
|
|
||||||
splitDays() {
|
splitDays() {
|
||||||
const days = []
|
const days = []
|
||||||
const workingHours = {}
|
const homeoffice = {}
|
||||||
const homeoffice = {}
|
const schedulesCapacityBySplit = {}
|
||||||
|
|
||||||
|
const now = moment()
|
||||||
|
const dailyCapacityMinutes = this.user.work_end - this.user.work_start
|
||||||
|
|
||||||
this.timelineData.tasks.forEach(task => {
|
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)
|
if (task.type == 'non-working-hours' || task.subtask?.is_finished || task.blocker?.is_finished)
|
||||||
return
|
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 => {
|
this.timelineData.homeoffices.forEach(task => {
|
||||||
homeoffice[task.split] = true
|
homeoffice[task.split] = true
|
||||||
})
|
})
|
||||||
|
|
||||||
for (let i = 0; i < 7; i++) {
|
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({
|
days.push({
|
||||||
id: i + 1,
|
id: i + 1,
|
||||||
fullname: `${this.filter.employee.name} ${this.filter.employee.surname}`,
|
fullname: `${this.filter.employee.name} ${this.filter.employee.surname}`,
|
||||||
initials: this.filter.employee.name.charAt(0).toUpperCase() + this.filter.employee.surname.charAt(0).toUpperCase(),
|
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),
|
date: addDays(this.filter.start, i),
|
||||||
isHomeoffice: homeoffice[i],
|
isHomeoffice: homeoffice[i],
|
||||||
isWeekend: timelineUtils.isWeekend(addDays(this.filter.start, i))
|
isWeekend: timelineUtils.isWeekend(addDays(this.filter.start, i))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(days)
|
||||||
|
|
||||||
return days
|
return days
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user