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

@ -47,7 +47,61 @@ const getOneTrashByBoardId = (boardId) =>
type: List.Types.TRASH,
});
const updateOne = (criteria, values) => List.updateOne(criteria).set({ ...values });
const updateOne = async (criteria, values) => {
if (values.type) {
return sails.getDatastore().transaction(async (db) => {
const list = await List.updateOne(criteria)
.set({ ...values })
.usingConnection(db);
let cards = [];
let tasks = [];
if (list) {
let isClosed;
if (list.type === List.Types.ACTIVE) {
isClosed = false;
} else if (list.type === List.Types.CLOSED) {
isClosed = true;
}
if (!_.isUndefined(isClosed)) {
cards = await Card.update({
listId: list.id,
})
.set({
isClosed,
})
.fetch()
.usingConnection(db);
if (cards.length > 0) {
tasks = await Task.update({
linkedCardId: sails.helpers.utils.mapRecords(cards),
})
.set({
isCompleted: isClosed,
})
.fetch()
.usingConnection(db);
}
}
}
return {
list,
cards,
tasks,
};
});
}
const list = await List.updateOne(criteria).set({ ...values });
return {
list,
};
};
// eslint-disable-next-line no-underscore-dangle
const delete_ = (criteria) => List.destroy(criteria).fetch();