mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 22:39:34 +00:00
feat(ongoing tasks): added option to close task along with all it's unfinished timeblocks
This commit is contained in:
1 parent
2b47abadfa
commit
ff8130901d
4 files changed
+217
-3
No files matched your search
@@ -28,6 +28,8 @@
|
||||
|
||||
<td class="task-action">
|
||||
<div class="d-flex justify-start align-center">
|
||||
<img class="pencil-icon mr-3" :class="{'disabled': loadingSubtask[subtask.id]}" :src="checkmarkDouble" @click.stop="handleCompleteTask(subtask)">
|
||||
|
||||
<template v-if="subtask.type == 'office365'">
|
||||
<img class="pencil-icon" :src="eye" @click.stop="editTask(subtask, false)">
|
||||
<img class="office-icon" :src="office365" />
|
||||
@@ -47,7 +49,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { bin, eye, office365 } from '@/plugins/app/_img'
|
||||
import { bin, eye, office365, checkmarkDouble } from '@/plugins/app/_img'
|
||||
|
||||
import { mapGetters } from 'vuex'
|
||||
import moment from 'moment'
|
||||
@@ -64,7 +66,9 @@ export default {
|
||||
return {
|
||||
eye,
|
||||
bin,
|
||||
office365
|
||||
office365,
|
||||
checkmarkDouble,
|
||||
loadingSubtask: {}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -77,6 +81,16 @@ export default {
|
||||
this.$events.emit('show-subtask-modal', {subtask, editMode})
|
||||
},
|
||||
|
||||
async handleCompleteTask(subtask) {
|
||||
const areAllTimeBlocksFinished = subtask.timeblocks.every(tb => tb.is_finished)
|
||||
|
||||
if (!areAllTimeBlocksFinished) {
|
||||
this.$events.emit('show-unable-to-complete-task-modal', { subtask })
|
||||
} else {
|
||||
await this._finishSubtask(subtask)
|
||||
}
|
||||
},
|
||||
|
||||
deleteTask(subtask) {
|
||||
if (subtask.type == 'office365')
|
||||
return this.$events.emit('show-unable-to-edit-office-task-modal', { mode: 'delete' })
|
||||
@@ -110,6 +124,28 @@ export default {
|
||||
const timeblockDeadline = this.getSelectedTimeblockDeadline(subtask.timeblocks)
|
||||
|
||||
return timeblockDeadline !== '' ? timeblockDeadline : 'Žiadny termín'
|
||||
},
|
||||
|
||||
async _finishSubtask(subtask) {
|
||||
const tempSubtask = {...subtask, is_finished: 1, timesheets: subtask?.timesheets.map((timesheet) => {
|
||||
delete timesheet.employee_name
|
||||
return timesheet
|
||||
}) || []}
|
||||
|
||||
try {
|
||||
this.loadingSubtask[subtask.id] = true
|
||||
await this.$axios.put_auth(`v1/subtasks/${tempSubtask.id}`, tempSubtask)
|
||||
|
||||
this.$store.dispatch('tm/removeOngoingSubtask', subtask.id)
|
||||
this.$events.emit('on-subtask-edited', subtask)
|
||||
} catch (error) {
|
||||
this.$toast.error(error.message || error)
|
||||
|
||||
if (process.env.NODE_ENV === 'development')
|
||||
console.log('[a-ongoing-table.vue] Error: ', error)
|
||||
} finally {
|
||||
this.loadingSubtask[subtask.id] = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -134,6 +170,10 @@ v-table, th, td
|
||||
margin: 6px
|
||||
padding: 6px
|
||||
|
||||
.disabled
|
||||
opacity: 0.5
|
||||
pointer-events: none
|
||||
|
||||
tbody
|
||||
tr:hover
|
||||
background: rgba(0,0,0,.1)
|
||||
|
||||
Reference in new issue
Block a user