diff --git a/app/src/plugins/tm@dashboard/_components/z-timeline.vue b/app/src/plugins/tm@dashboard/_components/z-timeline.vue index 87ccc18..2fae9f6 100644 --- a/app/src/plugins/tm@dashboard/_components/z-timeline.vue +++ b/app/src/plugins/tm@dashboard/_components/z-timeline.vue @@ -209,15 +209,17 @@ export default { if (this.$route.name == 'Dashboard - Tasks') { const editedSubtask = { ...event.subtask, - timeblocks: [ - ...event.subtask.timeblocks, - { - id: event._timeblock_id, - is_finished: 0, - start: tmUtils.formatDateTimeForBackend(start), - end: tmUtils.formatDateTimeForBackend(end), - }, - ], + timeblocks: event.subtask.timeblocks.map((tb) => { + if (tb.id === event._timeblock_id) { + return { + id: event._timeblock_id, + is_finished: tb.is_finished || 0, + start: tmUtils.formatDateTimeForBackend(start), + end: tmUtils.formatDateTimeForBackend(end), + }; + } + return tb; + }), timesheets: event.subtask.timesheets.map((timesheet) => { delete timesheet.employee_name; return timesheet; @@ -245,15 +247,17 @@ export default { const editedSubtask = { ...event.subtask, employee_id: split.employee_id, - timeblocks: [ - ...event.subtask.timeblocks, - { - id: event._timeblock_id, - is_finished: 0, - start: tmUtils.formatDateTimeForBackend(event.start), - end: tmUtils.formatDateTimeForBackend(event.end), - }, - ], + timeblocks: event.subtask.timeblocks.map((tb) => { + if (tb.id === event._timeblock_id) { + return { + id: event._timeblock_id, + is_finished: tb.is_finished || 0, + start: tmUtils.formatDateTimeForBackend(event.start), + end: tmUtils.formatDateTimeForBackend(event.end), + }; + } + return tb; + }), timesheets: event.subtask.timesheets.map((timesheet) => { delete timesheet.employee_name; return timesheet; diff --git a/app/src/plugins/tm@modal/task/z-task-modal.vue b/app/src/plugins/tm@modal/task/z-task-modal.vue index 0f82a61..fb180d7 100644 --- a/app/src/plugins/tm@modal/task/z-task-modal.vue +++ b/app/src/plugins/tm@modal/task/z-task-modal.vue @@ -628,7 +628,9 @@ export default { // Helper: Get timeblocks for specific employee getEmployeeTimeblocks(employeeId) { if (!this.timeblocks) return []; - return this.timeblocks.filter((tb) => tb.employee_id == employeeId); + return this.timeblocks.filter( + (tb) => Number(tb.employee_id) === Number(employeeId), + ); }, updateEmployeeTimeblocks(updatedTimeblocks, employeeId) { @@ -1040,23 +1042,28 @@ export default { // Convert timeblocks from internal format to BE format for update // Filter out completely empty timeblocks AND timeblocks without all required fields - const timeblocks = this.timeblocks - .filter( - (timeblock) => - timeblock.date && - timeblock.starts_at_time && - timeblock.ends_at_time && - timeblock.employee_id == this.subtask.employee_id, - ) // Only send complete timeblocks for this employee - .map((timeblock) => { - const dateStr = moment(timeblock.date).format('YYYY-MM-DD'); - return { - id: timeblock.id || null, - start: `${dateStr} ${timeblock.starts_at_time}:00`, - end: `${dateStr} ${timeblock.ends_at_time}:00`, - is_finished: timeblock.is_finished || 0, - }; - }); + // Pre draft s multiple employees preskočiť - timeblocks sú v employees array + const timeblocks = + this.subtask.is_draft && this.isDraftWithMultipleEmployees + ? [] + : this.timeblocks + .filter( + (timeblock) => + timeblock.date && + timeblock.starts_at_time && + timeblock.ends_at_time && + Number(timeblock.employee_id) === + Number(this.subtask.employee_id), + ) // Only send complete timeblocks for this employee + .map((timeblock) => { + const dateStr = moment(timeblock.date).format('YYYY-MM-DD'); + return { + id: timeblock.id || null, + start: `${dateStr} ${timeblock.starts_at_time}:00`, + end: `${dateStr} ${timeblock.ends_at_time}:00`, + is_finished: timeblock.is_finished || 0, + }; + }); const payload = { ...this.subtask, timesheets, timeblocks }; diff --git a/be/app/Listeners/SendDeletedSubTaskNotification.php b/be/app/Listeners/SendDeletedSubTaskNotification.php index efb287d..c8e2112 100644 --- a/be/app/Listeners/SendDeletedSubTaskNotification.php +++ b/be/app/Listeners/SendDeletedSubTaskNotification.php @@ -27,6 +27,11 @@ class SendDeletedSubTaskNotification */ public function handle(SubTaskDeleted $event) { + // Neposielame notifikacie pri mazani konceptov (draftov) + if ($event->subtask->is_draft) { + return; + } + $receiversArray[] = $event->subtask->user->email; $creator = \App\Models\User::find($event->subtask->created_by); diff --git a/be/app/Listeners/SendEditedSubTaskNotification.php b/be/app/Listeners/SendEditedSubTaskNotification.php index 44ade1b..5fd3cc1 100644 --- a/be/app/Listeners/SendEditedSubTaskNotification.php +++ b/be/app/Listeners/SendEditedSubTaskNotification.php @@ -31,6 +31,11 @@ class SendEditedSubTaskNotification implements ShouldQueue */ public function handle(SubTaskEdited $event) { + // Neposielame notifikacie pre koncepty (drafty) + if ($event->subtask->is_draft) { + return; + } + // emailova notifikacia sa posiela len ak subtask bol upraveny inym uzivatelom if ($event->subtask->updated_by == $event->subtask->user_id) { return; diff --git a/be/app/Listeners/SendNewSubTaskEmailNotification.php b/be/app/Listeners/SendNewSubTaskEmailNotification.php index f2fc44c..bfc46a4 100644 --- a/be/app/Listeners/SendNewSubTaskEmailNotification.php +++ b/be/app/Listeners/SendNewSubTaskEmailNotification.php @@ -31,6 +31,11 @@ class SendNewSubTaskEmailNotification implements ShouldQueue */ public function handle(SubTaskCreated $event) { + // Neposielame notifikacie pre koncepty (drafty) + if ($event->subtask->is_draft) { + return; + } + // flag na urovni subtasku - notification_sent // ak existuje este nejaky subtask v ramci master tasku, co ma prazdnu notification_sent, tak mu nastavim 0 a skippujem posielanie emailu // az ked neexistuje uz iny subtask, co ma flag prazdny, tak poslem email a nastavim notification_sent na 1