From 77e0b4526b9eaabca444555077a7019812882b4f Mon Sep 17 00:00:00 2001 From: Denis Bykhov Date: Tue, 23 Apr 2024 18:08:30 +0500 Subject: [PATCH] Fix todo creating on assignee change (#5435) --- server-plugins/time-resources/src/index.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/server-plugins/time-resources/src/index.ts b/server-plugins/time-resources/src/index.ts index 7e4651fa12..df6f5fd2d8 100644 --- a/server-plugins/time-resources/src/index.ts +++ b/server-plugins/time-resources/src/index.ts @@ -501,9 +501,21 @@ async function changeIssueAssigneeHandler ( if (issue !== undefined) { const status = (await control.findAll(core.class.Status, { _id: issue.status }))[0] if (status === undefined) return [] - if (status.category === task.statusCategory.Active) { + if (status.category === task.statusCategory.Active || status.category === task.statusCategory.ToDo) { + const res: Tx[] = [] + const todos = await control.findAll(time.class.ToDo, { + attachedTo: issue._id + }) + const now = Date.now() + for (const todo of todos) { + if (todo.doneOn != null) continue + res.push(control.txFactory.createTxUpdateDoc(todo._class, todo.space, todo._id, { doneOn: now })) + } const tx = await getCreateToDoTx(issue, newAssignee, control) - if (tx !== undefined) return [tx] + if (tx !== undefined) { + res.push(tx) + } + return res } } return []