mirror of
https://github.com/plankanban/planka.git
synced 2025-07-19 13:19:44 +02:00
feat: Add ability to link tasks to cards
This commit is contained in:
parent
49203e9d56
commit
230f50e3d9
35 changed files with 761 additions and 243 deletions
|
@ -200,9 +200,69 @@ const getOneById = (id, { listId } = {}) => {
|
|||
return Card.findOne(criteria);
|
||||
};
|
||||
|
||||
const update = (criteria, values) => Card.update(criteria).set(values).fetch();
|
||||
const update = async (criteria, values) => {
|
||||
if (!_.isUndefined(values.isClosed)) {
|
||||
return sails.getDatastore().transaction(async (db) => {
|
||||
const cards = await Card.update(criteria).set(values).fetch().usingConnection(db);
|
||||
|
||||
const updateOne = (criteria, values) => Card.updateOne(criteria).set({ ...values });
|
||||
let tasks = [];
|
||||
if (card) {
|
||||
tasks = await Task.update({
|
||||
linkedCardId: sails.helpers.utils.mapRecords(cards),
|
||||
})
|
||||
.set({
|
||||
isCompleted: card.isClosed,
|
||||
})
|
||||
.fetch()
|
||||
.usingConnection(db);
|
||||
}
|
||||
|
||||
return {
|
||||
cards,
|
||||
tasks,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
const cards = await Card.update(criteria).set(values).fetch();
|
||||
|
||||
return {
|
||||
cards,
|
||||
};
|
||||
};
|
||||
|
||||
const updateOne = async (criteria, values) => {
|
||||
if (!_.isUndefined(values.isClosed)) {
|
||||
return sails.getDatastore().transaction(async (db) => {
|
||||
const card = await Card.updateOne(criteria)
|
||||
.set({ ...values })
|
||||
.usingConnection(db);
|
||||
|
||||
let tasks = [];
|
||||
if (card) {
|
||||
tasks = await Task.update({
|
||||
linkedCardId: card.id,
|
||||
})
|
||||
.set({
|
||||
isCompleted: card.isClosed,
|
||||
})
|
||||
.fetch()
|
||||
.usingConnection(db);
|
||||
}
|
||||
|
||||
return {
|
||||
card,
|
||||
tasks,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
const card = await Card.updateOne(criteria).set({ ...values });
|
||||
|
||||
return {
|
||||
card,
|
||||
};
|
||||
};
|
||||
|
||||
// eslint-disable-next-line no-underscore-dangle
|
||||
const delete_ = (criteria) => Card.destroy(criteria).fetch();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue