fix(z-task-modal): fix edgecase for employees, where employee in the middle is not enterd

This commit is contained in:
Matej Glasnák committed 2025-05-09 13:36:51 +02:00
1 parent 3f75f9d204
commit 6a550006d9
1 file changed
+11 -3
+11 -3
View File
@@ -675,8 +675,12 @@ export default {
this.$store.commit('tm/update_subtask', subtask); this.$store.commit('tm/update_subtask', subtask);
this.$events.emit('on-subtask-edited', this.subtask); this.$events.emit('on-subtask-edited', this.subtask);
} else { } else {
this.subtask.employees.forEach((employee) => { // Filter out employees that don't have both id and duration
if (employee.id) const validEmployees = this.subtask.employees.filter(
(employee) => employee.id && employee.duration,
);
validEmployees.forEach((employee) => {
employee.timeblocks = this.timeblocks employee.timeblocks = this.timeblocks
.filter((timeblock) => timeblock.date) .filter((timeblock) => timeblock.date)
.map((timeblock) => { .map((timeblock) => {
@@ -691,7 +695,11 @@ export default {
}; };
}); });
}); });
const subtaskCopy = this.subtask;
const subtaskCopy = {
...this.subtask,
employees: validEmployees,
};
delete subtaskCopy._master_task; delete subtaskCopy._master_task;
const { subtasks } = await this.$axios.post_auth( const { subtasks } = await this.$axios.post_auth(
`v1/mastertasks/${this.subtask.master_task_id}/subtasks`, `v1/mastertasks/${this.subtask.master_task_id}/subtasks`,