1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-19 05:09:43 +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

@ -33,28 +33,6 @@ module.exports = {
async fn(inputs) {
const { values } = inputs;
if (values.type) {
let isClosed;
if (values.type === List.Types.CLOSED) {
if (inputs.record.type === List.Types.ACTIVE) {
isClosed = true;
}
} else if (inputs.record.type === List.Types.CLOSED) {
isClosed = false;
}
if (!_.isUndefined(isClosed)) {
await Card.qm.update(
{
listId: inputs.record.id,
},
{
isClosed,
},
);
}
}
if (!_.isUndefined(values.position)) {
const lists = await sails.helpers.boards.getFiniteListsById(
inputs.board.id,
@ -94,7 +72,7 @@ module.exports = {
}
}
const list = await List.qm.updateOne(inputs.record.id, values);
const { list, tasks } = await List.qm.updateOne(inputs.record.id, values);
if (list) {
sails.sockets.broadcast(
@ -106,6 +84,32 @@ module.exports = {
inputs.request,
);
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
}
const webhooks = await Webhook.qm.getAll();
sails.helpers.utils.sendWebhooks.with({