mirror of
https://github.com/plankanban/planka.git
synced 2025-12-19 09:13:20 +03:00
feat: Add ability to link tasks to cards
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user