From c93df3eb1ac8f9b24e4c87b2dfcf6fca28f4028f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Glasn=C3=A1k?= Date: Fri, 18 Oct 2024 11:40:33 +0200 Subject: [PATCH] [Master Task] Remove team eployess after team is removed --- .../tm@modal/master-task/z-master-task-modal.vue | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/src/plugins/tm@modal/master-task/z-master-task-modal.vue b/app/src/plugins/tm@modal/master-task/z-master-task-modal.vue index b44d7c9..a704351 100644 --- a/app/src/plugins/tm@modal/master-task/z-master-task-modal.vue +++ b/app/src/plugins/tm@modal/master-task/z-master-task-modal.vue @@ -432,6 +432,17 @@ export default { } }, deep: true + }, + 'mastertask.team_id': { + handler(value, oldValue) { + if (this.editMode && (!value && oldValue)) { + // Removes only employees from the old team when team_id is removed + const oldTeamEmployeesIds = this.teams.find(team => team.id == oldValue)?.employees.map(employee => employee?.id) || [] + const employeesNotInOldTeam = this.mastertask.employees.filter(employee => !oldTeamEmployeesIds.includes(employee?.id)) + this.mastertask.employees = employeesNotInOldTeam + } + }, + deep: true } } }