1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-18 20:59:44 +02:00

feat: Add ability to link tasks to cards

This commit is contained in:
Maksim Eltyshev 2025-07-11 01:04:02 +02:00
parent 49203e9d56
commit 230f50e3d9
35 changed files with 761 additions and 243 deletions

View file

@ -397,7 +397,10 @@ module.exports = {
values.listChangedAt = new Date().toISOString();
}
card = await Card.qm.updateOne(inputs.record.id, values);
const updateResult = await Card.qm.updateOne(inputs.record.id, values);
({ card } = updateResult);
const { tasks } = updateResult;
if (!card) {
return card;
@ -491,6 +494,32 @@ module.exports = {
}
}
if (tasks) {
const taskListIds = sails.helpers.utils.mapRecords(tasks, 'taskListId', true);
const taskLists = await TaskList.qm.getByIds(taskListIds);
const taskListById = _.keyBy(taskLists, 'id');
const cardIds = sails.helpers.utils.mapRecords(taskLists, 'cardId', true);
const cards = await Card.qm.getByIds(cardIds);
const cardById = _.keyBy(cards, 'id');
const boardIdByTaskId = tasks.reduce(
(result, task) => ({
...result,
[task.id]: cardById[taskListById[task.taskListId].cardId].boardId,
}),
{},
);
tasks.forEach((task) => {
sails.sockets.broadcast(`board:${boardIdByTaskId[task.id]}`, 'taskUpdate', {
item: task,
});
});
// TODO: send webhooks
}
sails.helpers.utils.sendWebhooks.with({
webhooks,
event: Webhook.Events.CARD_UPDATE,