Merge branch 'main' of bitbucket.org:studiotem/jandl-taskmanager-app

This commit is contained in:
StudioTem committed 2023-05-23 14:58:25 +02:00
commit 86424d1b3d
5 files changed
+55 -15

No files matched your search

@@ -223,13 +223,38 @@ export default {
this.$events.emit('show-complete-task-modal', { subtask }) this.$events.emit('show-complete-task-modal', { subtask })
}, },
// async toggleTimeblockIsFinished(event) {
// if (!event.timeblock.is_finished)
// this.$events.emit('show-task-add-time-modal', { subtask: event.subtask })
// try {
// await this.$axios.put_auth(`v1/timeblocks/${event._timeblock_id}`, {is_finished: !event.timeblock.is_finished})
// // TODO: Co mi to vrati? A updatenut
// } catch (error) {
// this.$toast.error(error.message || error)
// }
// },
async toggleTimeblockIsFinished(event) { async toggleTimeblockIsFinished(event) {
if (!event.timeblock.is_finished) const subtask = event.subtask
this.$events.emit('show-task-add-time-modal', { subtask: event.subtask }) const timeblock = subtask.timeblocks.find(originalTimeblock => originalTimeblock.id == event._timeblock_id)
timeblock.is_finished = timeblock.is_finished ? 0 : 1
try { try {
await this.$axios.put_auth(`v1/timeblocks/${event._timeblock_id}`, {is_finished: !event.timeblock.is_finished}) const {data: newTimeblock} = await this.$axios.put_auth(`v1/timeblocks/${timeblock.id}`, timeblock)
// TODO: Co mi to vrati? A updatenut
subtask.timeblocks = subtask.timeblocks.map(originalTimeblock => {
if (originalTimeblock.id == newTimeblock.id)
return newTimeblock
return originalTimeblock
})
this.$events.emit('on-subtask-edited', subtask)
if (timeblock.is_finished)
this.$events.emit('show-task-add-time-modal', { subtask })
} catch (error) { } catch (error) {
this.$toast.error(error.message || error) this.$toast.error(error.message || error)
} }
@@ -53,6 +53,8 @@ import Datepicker from '@vuepic/vue-datepicker'
import moment from 'moment' import moment from 'moment'
export default { export default {
emits: ['update-subtask'],
components: { components: {
Datepicker Datepicker
}, },
@@ -119,16 +121,23 @@ export default {
const subtask = JSON.parse(JSON.stringify(this.subtask)) const subtask = JSON.parse(JSON.stringify(this.subtask))
const timeblock = JSON.parse(JSON.stringify(originalTimeblock)) const timeblock = JSON.parse(JSON.stringify(originalTimeblock))
console.log(subtask) timeblock.is_finished = timeblock.is_finished == 1 ? 0 : 1
console.log(timeblock)
if (!timeblock.is_finished)
this.$events.emit('show-task-add-time-modal', { subtask })
timeblock.is_finished = !timeblock.is_finished
try { try {
await this.$axios.put_auth(`v1/timeblocks/${timeblock.id}`, timeblock) const {data: newTimeblock} = await this.$axios.put_auth(`v1/timeblocks/${timeblock.id}`, timeblock)
// TODO: Co mi to vrati? A updatenut
subtask.timeblocks = subtask.timeblocks.map(originalTimeblock => {
if (originalTimeblock.id == newTimeblock.id)
return newTimeblock
return originalTimeblock
})
this.$events.emit('on-subtask-edited', subtask)
this.$emit('update-subtask', subtask)
if (timeblock.is_finished)
this.$events.emit('show-task-add-time-modal', { subtask })
} catch (error) { } catch (error) {
this.$toast.error(error.message || error) this.$toast.error(error.message || error)
} }
@@ -1,7 +1,7 @@
<template> <template>
<A-mastertask-name :name="subtask._master_task.name" :id="subtask.master_task_id" :color="subtask._master_task.color" @close-modal="$emit('close-modal')" /> <A-mastertask-name :name="subtask._master_task.name" :id="subtask.master_task_id" :color="subtask._master_task.color" @close-modal="$emit('close-modal')" />
<A-mastertask-status :status="subtask.is_finished" /> <A-mastertask-status :status="subtask.is_finished" />
<A-task-timeblocks :timeblocks="subtask.timeblocks" :subtask="subtask" /> <A-task-timeblocks :timeblocks="subtask.timeblocks" :subtask="subtask" @update-subtask="$emit('update-subtask', $event)" />
<Z-created-by :employee-id="subtask.created_by" /> <Z-created-by :employee-id="subtask.created_by" />
<A-task-assigned-employee :employee="subtask._employee" /> <A-task-assigned-employee :employee="subtask._employee" />
<A-task-planned-time :hours="subtask.duration" /> <A-task-planned-time :hours="subtask.duration" />
@@ -24,7 +24,7 @@ import ATaskDescription from './_components/a-task-description.vue'
import ZFiles from '@/plugins/tm@modal/_components/read-only/z-files.vue' import ZFiles from '@/plugins/tm@modal/_components/read-only/z-files.vue'
export default { export default {
emits: ['close-modal'], emits: ['close-modal', 'update-subtask'],
components: { components: {
ZFiles, ZFiles,
@@ -46,6 +46,7 @@ export default {
async showModal({ subtask }) { async showModal({ subtask }) {
this.subtask = subtask this.subtask = subtask
this.visible = true this.visible = true
this.form.hours = null
this.$nextTick(() => this.v$.$reset()) this.$nextTick(() => this.v$.$reset())
}, },
@@ -53,7 +53,7 @@
<v-card-actions class="d-flex flex-column modal-content"> <v-card-actions class="d-flex flex-column modal-content">
<div class="w-100"> <div class="w-100">
<Z-task-readonly-info :subtask="subtask" @close-modal="closeModal" /> <Z-task-readonly-info :subtask="subtask" @close-modal="closeModal" @update-subtask="updateSubtask" />
<div class="d-flex justify-start align-center mt-8"> <div class="d-flex justify-start align-center mt-8">
<v-btn class="done-btn" v-if="!subtask.is_finished" @click.stop="showCompleteTaskModal()">Dokončiť</v-btn> <v-btn class="done-btn" v-if="!subtask.is_finished" @click.stop="showCompleteTaskModal()">Dokončiť</v-btn>
@@ -216,6 +216,11 @@ export default {
this.subtask.files = files this.subtask.files = files
}, },
updateSubtask(subtask) {
console.log('UPDATE SUBTASK: ', subtask.timeblocks[0])
this.subtask = subtask
},
_enrichTask(subtask) { _enrichTask(subtask) {
return { return {
...subtask, ...subtask,