From 68b6e6f75a85d35afb303359f53bd763e3d2a8a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Glasn=C3=A1k?= Date: Tue, 28 Feb 2023 02:06:51 +0100 Subject: [PATCH] [Subtask] Fixed timesheets --- app/src/plugins/app/_config/App.vue | 4 ++++ app/src/plugins/tm@_store/store/index.ts | 9 +++++++++ .../task/_components/_components/a-task-spent-time.vue | 5 ----- .../task/_components/_components/a-task-timeblocks.vue | 4 ---- app/src/plugins/tm@modal/task/z-complete-task-modal.vue | 3 --- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/app/src/plugins/app/_config/App.vue b/app/src/plugins/app/_config/App.vue index 4a31901..d8eb8ba 100644 --- a/app/src/plugins/app/_config/App.vue +++ b/app/src/plugins/app/_config/App.vue @@ -86,6 +86,10 @@ export default { this.$events.on('show-task-add-time-modal', ({subtask}) => { this.$refs['z-task-add-time-modal'].showModal({ subtask }) }) + + this.$events.on('on-subtask-edited', () => { + this.$store.dispatch('tm/reloadSubtasks') + }) }, methods: { diff --git a/app/src/plugins/tm@_store/store/index.ts b/app/src/plugins/tm@_store/store/index.ts index b8055e8..b4bbfe3 100644 --- a/app/src/plugins/tm@_store/store/index.ts +++ b/app/src/plugins/tm@_store/store/index.ts @@ -99,6 +99,15 @@ export default { ]).then(() => commit('initialized')) }, + reloadSubtasks({dispatch}: {dispatch: any}) { + return Promise.all([ + dispatch('loadMastertasks'), + dispatch('loadProjects'), + dispatch('loadUnscheduledSubtasks'), + dispatch('loadOngoingSubtasks') + ]) + }, + loadMastertasks({commit}: {commit: any}) { return new Promise((resolve, reject) => { axios.get_auth_data('v1/mastertasks') diff --git a/app/src/plugins/tm@modal/task/_components/_components/a-task-spent-time.vue b/app/src/plugins/tm@modal/task/_components/_components/a-task-spent-time.vue index c489fb0..f1412c3 100644 --- a/app/src/plugins/tm@modal/task/_components/_components/a-task-spent-time.vue +++ b/app/src/plugins/tm@modal/task/_components/_components/a-task-spent-time.vue @@ -123,12 +123,7 @@ export default { const { subtask } = await this.$axios.put_auth(`v1/subtasks/${task.id}`, task) this.closeModal() - this.$store.commit('tm/update_subtask', subtask) this.$events.emit('on-subtask-edited', subtask) - - this.$store.dispatch('tm/loadMastertasks') - this.$store.dispatch('tm/loadUnscheduledSubtasks') - this.$store.dispatch('tm/loadOngoingSubtasks') } catch (error) { this.$toast.error(error.message || error) } diff --git a/app/src/plugins/tm@modal/task/_components/_components/a-task-timeblocks.vue b/app/src/plugins/tm@modal/task/_components/_components/a-task-timeblocks.vue index 3e5044c..eaca7f9 100644 --- a/app/src/plugins/tm@modal/task/_components/_components/a-task-timeblocks.vue +++ b/app/src/plugins/tm@modal/task/_components/_components/a-task-timeblocks.vue @@ -126,10 +126,6 @@ export default { this.closeModal() this.$events.emit('on-subtask-edited', subtask) - - this.$store.dispatch('tm/loadMastertasks') - this.$store.dispatch('tm/loadUnscheduledSubtasks') - this.$store.dispatch('tm/loadOngoingSubtasks') } catch (error) { this.$toast.error(error.message || error) } diff --git a/app/src/plugins/tm@modal/task/z-complete-task-modal.vue b/app/src/plugins/tm@modal/task/z-complete-task-modal.vue index b113d95..f967872 100644 --- a/app/src/plugins/tm@modal/task/z-complete-task-modal.vue +++ b/app/src/plugins/tm@modal/task/z-complete-task-modal.vue @@ -40,9 +40,6 @@ export default { const { subtask } = await this.$axios.put_auth(`v1/subtasks/${tempSubtask.id}`, tempSubtask) this.visible = false - this.$store.dispatch('tm/loadMastertasks') - this.$store.dispatch('tm/loadUnscheduledSubtasks') - this.$store.dispatch('tm/loadOngoingSubtasks') this.$emit('on-subtask-edited', subtask) } catch (error) { this.$toast.error(error)