tasks and teams overview subheader refactor

This commit is contained in:
Filip Kaluža committed 2023-01-12 18:22:48 +01:00
1 parent c542ea7760
commit a05d69eedc
4 files changed
+68 -32

No files matched your search

@@ -33,9 +33,9 @@ import { addDays, subDays } from 'date-fns'
export default {
props: {
unscheduledTime: {
type: Number,
type: String,
default() {
return 0
return '0'
}
}
},
@@ -59,11 +59,17 @@ export default {
},
created() {
this._getEmployees()
this._getWeek()
this._getData()
},
methods: {
async _getData() {
await this._getEmployees()
this._getWeek()
this.$nextTick(() => {
this.$emit('dataChanged', {firstDay: this.firstDay, employeeId: this.selectedEmployee})
})
},
async _getEmployees() {
this.employees = await this.$axios.get_auth_data('v1/employees')
this.employees.forEach(employee => {
@@ -71,12 +77,12 @@ export default {
})
},
_getWeek() {
_getWeek(emitDataChanged = true) {
this.firstDay = subDays(this.date, 1)
this.lastDay = addDays(this.date, 5)
this.$emit('weekChange', {firstDay: this.firstDay, lastDay: this.lastDay})
this.selectedDate = String(this.firstDay.toLocaleDateString('sk-SK') + ' - ' + this.lastDay.toLocaleDateString('sk-SK'))
if (emitDataChanged) this.$emit('dataChanged', {firstDay: this.firstDay, employeeId: this.selectedEmployee})
},
prevWeek() {
@@ -88,6 +94,12 @@ export default {
this.date = addDays(this.date, 7)
this._getWeek()
}
},
watch: {
selectedTeam() {
this.$emit('dataChanged', {firstDay: this.firstDay, employeeId: this.selectedEmployee})
}
}
}
</script>
+8 -7
View File
@@ -1,6 +1,6 @@
<template>
<div>
<A-task-filter :unscheduledTime="unscheduledTime" @weekChange="getWeekData" />
<A-task-filter :unscheduledTime="unscheduledTime" @dataChanged="getTimelineData" />
<W-loadable :content="timelineData" class="w-loadable" empty-message="Nepodarilo sa nacitat data!">
<Z-timeline :calData="timelineData" :calConfig="config" :splits="splitDays" @eventMoved="onEventMoved" @completeTask="completeTask" @deleteTask="deleteTask" />
@@ -33,13 +33,14 @@ export default {
},
methods: {
async getWeekData(week) {
this.config.date = week.firstDay
async getTimelineData(data) {
this.config.date = data.firstDay
const lastDay = addDays(data.firstDay, 6)
try {
this.timelineData = await this.$axios.get_auth_data('v1/overview/tasks')
this.formatTimelineDataToTimelineFormat(week.firstDay)
this.generateDays(week.firstDay)
this.generateNonWorkingHours(week.firstDay)
this.timelineData = await this.$axios.get_auth_data('v1/overview/tasks', {firstDay: data.firstDay, lastDay: lastDay, employeeId: data.employeeId})
this.formatTimelineDataToTimelineFormat(data.firstDay)
this.generateDays(data.firstDay)
this.generateNonWorkingHours(data.firstDay)
} catch (error) {
this.timelineData = {error: error || 'Nepodarilo sa nacitat data!'}
console.error(error)