Files
jandl-taskmanager-app/app/src/plugins/tm@dashboard/teams/teams.vue
T
2023-09-21 17:04:50 +02:00

105 lines
2.4 KiB
Vue

<template>
<div ref="page">
<A-team-filter v-if="$store.getters['tm/isInitialized']" :split-days="calendarData ? splitDays : null" @filter-changed="onFilterChanged" />
<Z-timeline v-if="calendarData && !hideCal" :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 moment from 'moment'
import TeamsCalendar from './_mixins/TeamsCalendar.mixin'
import FilterMixin from '../_mixins/Filter.mixin'
import { mapGetters } from 'vuex'
export default {
mixins: [TeamsCalendar, FilterMixin],
components: {
ATeamFilter,
ZTimeline,
},
data() {
return {
hideCal: false,
filter: null,
subtasks: null,
blockers: null,
calendarConfig: {
date: new Date(),
scrollHour: 7,
}
}
},
computed: {
...mapGetters('auth', ['user']),
},
mounted() {
this.$events.on('on-subtask-edited', () => {
this.onFilterChanged(this.filter)
})
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: {
async onFilterChanged(filter) {
this.filter = filter
const urlQueryObject = {}
if (filter.start) urlQueryObject.start = moment(filter.start).format('YYYY-MM-DD')
if (filter.end) urlQueryObject.end = moment(filter.end).format('YYYY-MM-DD')
if (filter.team) urlQueryObject.team_id = filter.team.id
const queryParameters = new URLSearchParams(urlQueryObject).toString()
try {
const { subtasks, blockers } = await this.$axios.get_auth(`v1/subtasks?${queryParameters}`)
this.subtasks = subtasks
this.blockers = blockers
this.hideCal = true
setTimeout(() => { this.hideCal = false }, 0);
} catch (error) {
this.$toast.error('Nepodarilo sa nacitat data!')
}
this._initScrollListener()
}
}
}
</script>
<style lang="sass" scoped>
.w-loadable
text-align: center
padding-top: 20px
height: calc( 100% - 121px )
@media (max-width: 1312px)
.w-loadable
height: calc( 100% - 202px )
</style>