1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-24 15:49:46 +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

@ -29,7 +29,7 @@ module.exports = {
async fn(inputs) {
const trashList = await List.qm.getOneTrashByBoardId(inputs.board.id);
const cards = await Card.qm.update(
const { cards } = await Card.qm.update(
{
listId: inputs.record.id,
},

View file

@ -55,7 +55,7 @@ module.exports = {
values.prevListId = null;
}
const cards = await Card.qm.update(
const { cards } = await Card.qm.update(
{
listId: inputs.record.id,
},

View file

@ -78,8 +78,8 @@ module.exports = {
}
cards = await Promise.all(
cards.map((card, index) =>
Card.qm.updateOne(
cards.map(async (card, index) => {
const { card: nextCard } = await Card.qm.updateOne(
{
id: card.id,
listId: card.listId,
@ -87,8 +87,10 @@ module.exports = {
{
position: POSITION_GAP * (index + 1),
},
),
),
);
return nextCard;
}),
);
sails.sockets.broadcast(

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({