mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-22 06:49:35 +00:00
[Calendar] Fixed non working hours, added blockers to teams
This commit is contained in:
1 parent
f3f86261f4
commit
11c73b2b37
8 files changed
+281
-212
No files matched your search
@@ -1,20 +1,20 @@
|
||||
<template>
|
||||
<div>
|
||||
<A-team-filter v-if="$store.getters['tm/isInitialized']" :unscheduledTime="timelineData?.unscheduledTime || 0" @filter-changed="onFilterChanged" />
|
||||
<A-team-filter v-if="$store.getters['tm/isInitialized']" :unscheduledTime="calendarData?.unscheduledTime || 0" @filter-changed="onFilterChanged" />
|
||||
|
||||
<Z-timeline v-if="timelineData" :calData="timelineData" :calConfig="config" :splits="splitDays" />
|
||||
<Z-timeline v-if="calendarData" :cal-data="calendarData" :cal-config="calendarConfig" :splits="splitDays" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import ATeamFilter from './_components/a-team-filter.vue'
|
||||
import ZTimeline from '@/plugins/tm@dashboard/_components/z-timeline.vue'
|
||||
|
||||
import { setHours, setMinutes, addDays } from 'date-fns'
|
||||
import moment from 'moment'
|
||||
import timelineUtils from '../tasks/_utils/timeline.utils'
|
||||
import TeamsCalendar from './_mixins/TeamsCalendar.mixin'
|
||||
|
||||
export default {
|
||||
mixins: [TeamsCalendar],
|
||||
|
||||
components: {
|
||||
ATeamFilter,
|
||||
ZTimeline,
|
||||
@@ -24,48 +24,14 @@ export default {
|
||||
return {
|
||||
filter: null,
|
||||
subtasks: null,
|
||||
config: {
|
||||
blockers: null,
|
||||
calendarConfig: {
|
||||
date: new Date(),
|
||||
scrollHour: 7,
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
splitDays() {
|
||||
const days = []
|
||||
|
||||
this.filter.team.employees.forEach((employee, index) => {
|
||||
let workingHours = 0
|
||||
|
||||
this.timelineData.tasks.forEach(task => {
|
||||
if (task?.subtask?.employee_id == employee.id)
|
||||
workingHours += timelineUtils._getDifferenceInHours(task.end, task.start)
|
||||
})
|
||||
|
||||
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
|
||||
})
|
||||
})
|
||||
|
||||
return days
|
||||
},
|
||||
|
||||
timelineData() {
|
||||
if (!this.subtasks)
|
||||
return
|
||||
|
||||
return {
|
||||
unscheduledTime: 333,
|
||||
tasks: [...this._generateNonWorking(), ...this._generateTasks()]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.$events.on('on-subtask-edited', () => {
|
||||
this.onFilterChanged(this.filter)
|
||||
@@ -74,91 +40,24 @@ export default {
|
||||
this.$events.on('on-subtask-deleted', () => {
|
||||
this.onFilterChanged(this.filter)
|
||||
})
|
||||
|
||||
this.$events.on('on-blocker-edited', () => {
|
||||
this.onFilterChanged(this.filter)
|
||||
})
|
||||
|
||||
this.$events.on('on-blocker-deleted', () => {
|
||||
this.onFilterChanged(this.filter)
|
||||
})
|
||||
},
|
||||
|
||||
unmounted() {
|
||||
this.$events.off('on-subtask-edited')
|
||||
this.$events.off('on-subtask-deleted')
|
||||
this.$events.off('on-blocker-edited')
|
||||
this.$events.off('on-blocker-deleted')
|
||||
},
|
||||
|
||||
methods: {
|
||||
_generateTasks() {
|
||||
const tasks = []
|
||||
const calendarDate = moment(this.filter.start).format('DD-MM-YYYY')
|
||||
|
||||
this.subtasks.forEach(subtask => {
|
||||
// TODO Implement blockers
|
||||
if (subtask.type == 'blocker') return
|
||||
|
||||
let split = null
|
||||
let employee = null
|
||||
|
||||
this.filter.team.employees.forEach((e, index) => {
|
||||
if (e.id == subtask.employee_id) {
|
||||
split = index + 1
|
||||
employee = e
|
||||
}
|
||||
})
|
||||
|
||||
subtask.timeblocks.forEach(timeblock => {
|
||||
const formattedDate = moment(timeblock.start).format('DD-MM-YYYY')
|
||||
|
||||
if (formattedDate == calendarDate) {
|
||||
tasks.push({
|
||||
id: subtask.id,
|
||||
start: new Date(timeblock.start),
|
||||
end: new Date(timeblock.end),
|
||||
master_task: subtask.master_task,
|
||||
name: employee?.name,
|
||||
surname: employee?.surname,
|
||||
// date: new Date(timeblock.start),
|
||||
isWeekend: moment(timeblock.start).day() % 6 == 0,
|
||||
initials: employee?.name?.charAt(0)?.toUpperCase() + employee?.surname?.charAt(0)?.toUpperCase(),
|
||||
split: split,
|
||||
project_code: subtask.project_code,
|
||||
subtask: subtask,
|
||||
_timeblock_id: timeblock.id
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
return tasks
|
||||
},
|
||||
|
||||
_generateNonWorking() {
|
||||
const tasks = []
|
||||
const date = new Date(this.filter.start)
|
||||
let earliestStartHour = null
|
||||
this.config.date = date
|
||||
|
||||
this.filter.team.employees.forEach((employee, index) => {
|
||||
if (!earliestStartHour || employee.work_start < earliestStartHour)
|
||||
earliestStartHour = employee.work_start
|
||||
|
||||
tasks.push({
|
||||
title: "Non working hours",
|
||||
start: setMinutes(setHours(date, 0), 0),
|
||||
end: setMinutes(setHours(date, employee.work_start), 0),
|
||||
split: index + 1,
|
||||
type: 'non-working-hours',
|
||||
draggable: false
|
||||
})
|
||||
|
||||
tasks.push({
|
||||
title: "Non working hours",
|
||||
start: setMinutes(setHours(date, employee.work_end), 0),
|
||||
end: setMinutes(setHours(date, 23), 59),
|
||||
split: index + 1,
|
||||
type: 'non-working-hours',
|
||||
draggable: false
|
||||
})
|
||||
})
|
||||
|
||||
this.config.scrollHour = earliestStartHour - 1
|
||||
return tasks
|
||||
},
|
||||
|
||||
async onFilterChanged(filter) {
|
||||
this.filter = filter
|
||||
|
||||
@@ -172,7 +71,8 @@ export default {
|
||||
|
||||
try {
|
||||
const { subtasks, blockers } = await this.$axios.get_auth(`v1/subtasks?${queryParameters}`)
|
||||
this.subtasks = [...subtasks, ...blockers.map(blocker => ({...blocker, type: 'blocker'}))]
|
||||
this.subtasks = subtasks
|
||||
this.blockers = blockers
|
||||
} catch (error) {
|
||||
this.$toast.error('Nepodarilo sa nacitat data!')
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user