mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 14:29:34 +00:00
refactor podla review
This commit is contained in:
1 parent
d46a9151fc
commit
c542ea7760
14 files changed
+89
-182
No files matched your search
@@ -3,24 +3,14 @@
|
||||
<A-team-filter :unscheduledTime="unscheduledTime" @dayChanged="getDayData" />
|
||||
|
||||
<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" @reopenTask="reopenTask" @deleteTask="deleteTask" />
|
||||
<Z-timeline :calData="timelineData" :calConfig="config" :splits="splitDays" @eventMoved="onEventMoved" @completeTask="completeTask" @deleteTask="deleteTask" />
|
||||
</W-loadable>
|
||||
|
||||
<!-- Kaluza: vyhodit toto a nahradit za wToast -->
|
||||
<v-snackbar
|
||||
v-model="errorToast"
|
||||
:timeout="2000"
|
||||
color="red"
|
||||
:rounded="true"
|
||||
>
|
||||
{{ errorToastMessage }}
|
||||
</v-snackbar>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import ATeamFilter from './_components/a-team-filter.vue'
|
||||
import ZTimeline from '../tasks/_components/z-timeline.vue'
|
||||
import ZTimeline from '@/plugins/tm@dashboard/_components/z-timeline.vue'
|
||||
|
||||
import { setHours, setMinutes, setSeconds } from 'date-fns'
|
||||
|
||||
@@ -51,23 +41,22 @@ export default {
|
||||
this.config.date = date
|
||||
try {
|
||||
this.timelineData = await this.$axios.get_auth_data('v1/overview/teams')
|
||||
this.generateSplits()
|
||||
this.formatData()
|
||||
this.generateEmployees()
|
||||
this.formatTimelineDataToTimelineFormat()
|
||||
this.generateNonWorkingHours(date)
|
||||
} catch(error) {
|
||||
// Kaluza: Upravit podla feedbacku v tasks.modal
|
||||
this.timelineData = {}
|
||||
this.timelineData = {error: error || 'Nepodarilo sa nacitat data!'}
|
||||
console.error(error)
|
||||
this.triggerToast("Nepodarilo sa nacitat data!")
|
||||
}
|
||||
},
|
||||
|
||||
generateSplits() {
|
||||
generateEmployees() {
|
||||
this.splitDays = []
|
||||
for (let i = 0; i < this.timelineData.length; i++) {
|
||||
this.timelineData[i].splitId = i + 1
|
||||
this.splitDays.push({
|
||||
id: i + 1,
|
||||
employeeId: this.timelineData[i].id,
|
||||
firstName: this.timelineData[i].name,
|
||||
name: this.timelineData[i].name + " " + this.timelineData[i].surname,
|
||||
initials: this.timelineData[i].name.charAt(0).toUpperCase() + this.timelineData[i].surname.charAt(0).toUpperCase(),
|
||||
@@ -76,8 +65,7 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
// Kaluza: Upravit podla feedbacku v tasks.modal
|
||||
formatData() {
|
||||
formatTimelineDataToTimelineFormat() {
|
||||
this.timelineData.tasks = []
|
||||
this.unscheduledTime = 0
|
||||
|
||||
@@ -132,46 +120,27 @@ export default {
|
||||
this.timelineData.tasks.push(...nonWorkingHours)
|
||||
},
|
||||
|
||||
// Kaluza: Upravit podla feedbacku v tasks.modal
|
||||
triggerToast(message) {
|
||||
this.errorToastMessage = message
|
||||
this.errorToast = true
|
||||
},
|
||||
|
||||
// Kaluza: Upravit podla feedbacku v tasks.modal
|
||||
async onEventMoved(event) {
|
||||
console.log("drag", event)
|
||||
// try {
|
||||
// const newStartDate = addDays(event.event.start, differenceInCalendarDays(this.splitDays.filter((split) => {return split.id == event.newSplit})[0].date, event.event.start))
|
||||
// const newEndDate = addDays(event.event.end, differenceInCalendarDays( newStartDate, event.event.start))
|
||||
// await this.$axios.post_auth_data(`v1/overview/tasks/${event.event.id}`, {start: newStartDate, end: newEndDate})
|
||||
// } catch(error) {
|
||||
// this.triggerToast("Nepodarilo sa presunut ulohu!")
|
||||
// this.timelineData.tasks.filter(e => {
|
||||
// if (e.id == event.event.id) {
|
||||
// e.start = new Date(event.originalEvent.start)
|
||||
// e.end = new Date(event.originalEvent.end)
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
const task = this.timelineData.tasks.find(task => task.id == event.event.id)
|
||||
const newEmployeeId = this.splitDays.find(split => split.id == event.newSplit).employeeId
|
||||
|
||||
try {
|
||||
// await this.$axios.post_auth_data(`v1/overview/tasks/${event.event.id}`, {start: newEmployeeId})
|
||||
task.split = event.newSplit
|
||||
task.start = event.event.start
|
||||
task.end = event.event.end
|
||||
} catch(error) {
|
||||
task.split = event.oldSplit
|
||||
task.start = new Date(event.originalEvent.start)
|
||||
task.end = new Date(event.originalEvent.end)
|
||||
this.$toast.error(error)
|
||||
}
|
||||
},
|
||||
|
||||
// Kaluza: Upravit podla feedbacku v tasks.modal
|
||||
completeTask(id) {
|
||||
this.timelineData.tasks.filter(task => {
|
||||
if (task.id == id) {
|
||||
task.completed = true
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// Kaluza: Upravit podla feedbacku v tasks.modal
|
||||
reopenTask(id) {
|
||||
this.timelineData.tasks.filter(task => {
|
||||
if (task.id == id) {
|
||||
task.completed = false
|
||||
}
|
||||
})
|
||||
const task = this.timelineData.tasks.find(task => task.id == id)
|
||||
task.completed = !task.completed
|
||||
},
|
||||
|
||||
deleteTask(id) {
|
||||
|
||||
Reference in new issue
Block a user