mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 14:29:34 +00:00
[Timeblocks] Option to close time block
This commit is contained in:
1 parent
f3ed454d6f
commit
3e8cbfb3e4
5 files changed
+55
-15
No files matched your search
@@ -223,13 +223,38 @@ export default {
|
||||
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) {
|
||||
if (!event.timeblock.is_finished)
|
||||
this.$events.emit('show-task-add-time-modal', { subtask: event.subtask })
|
||||
const subtask = event.subtask
|
||||
const timeblock = subtask.timeblocks.find(originalTimeblock => originalTimeblock.id == event._timeblock_id)
|
||||
|
||||
timeblock.is_finished = timeblock.is_finished ? 0 : 1
|
||||
|
||||
try {
|
||||
await this.$axios.put_auth(`v1/timeblocks/${event._timeblock_id}`, {is_finished: !event.timeblock.is_finished})
|
||||
// TODO: Co mi to vrati? A updatenut
|
||||
const {data: newTimeblock} = await this.$axios.put_auth(`v1/timeblocks/${timeblock.id}`, timeblock)
|
||||
|
||||
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) {
|
||||
this.$toast.error(error.message || error)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user