1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-08-04 21:15:25 +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

@ -39,6 +39,15 @@ module.exports = {
await sails.helpers.taskLists.deleteRelated(taskLists);
await Task.qm.update(
{
linkedCardId: cardIdOrIds,
},
{
linkedCardId: null,
},
);
const { fileReferences } = await Attachment.qm.delete({
cardId: cardIdOrIds,
});

View file

@ -147,7 +147,7 @@ module.exports = {
const nextTaskLists = await TaskList.qm.create(nextTaskListsValues);
const nextTasksValues = tasks.map((task) => ({
..._.pick(task, ['assigneeUserId', 'position', 'name', 'isCompleted']),
..._.pick(task, ['linkedCardId', 'assigneeUserId', 'position', 'name', 'isCompleted']),
taskListId: nextTaskListIdByTaskListId[task.taskListId],
}));
@ -172,9 +172,9 @@ module.exports = {
const nextCoverAttachmentId = nextAttachmentIdByAttachmentId[inputs.record.coverAttachmentId];
if (nextCoverAttachmentId) {
card = await Card.qm.updateOne(card.id, {
({ card } = await Card.qm.updateOne(card.id, {
coverAttachmentId: nextCoverAttachmentId,
});
}));
}
}

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,