mirror of
https://github.com/plankanban/planka.git
synced 2025-07-19 13:19:44 +02:00
Fix members and labels creation when transfer card to another board
This commit is contained in:
parent
35f9631326
commit
c5b44598f9
2 changed files with 31 additions and 60 deletions
|
@ -143,7 +143,7 @@ module.exports = {
|
|||
const labelByNameMap = _.keyBy(labels, 'name');
|
||||
|
||||
const labelIds = await Promise.all(
|
||||
await prevLabels.map(async (prevLabel) => {
|
||||
prevLabels.map(async (prevLabel) => {
|
||||
if (labelByNameMap[prevLabel.name]) {
|
||||
return labelByNameMap[prevLabel.name].id;
|
||||
}
|
||||
|
@ -157,49 +157,41 @@ module.exports = {
|
|||
}),
|
||||
);
|
||||
|
||||
labelIds.forEach(async (labelId) => {
|
||||
await CardLabel.create({
|
||||
labelId,
|
||||
cardId: card.id,
|
||||
})
|
||||
.tolerate('E_UNIQUE')
|
||||
.fetch();
|
||||
});
|
||||
await Promise.all(
|
||||
labelIds.map(async (labelId) => {
|
||||
await CardLabel.create({
|
||||
labelId,
|
||||
cardId: card.id,
|
||||
})
|
||||
.tolerate('E_UNIQUE')
|
||||
.fetch();
|
||||
}),
|
||||
);
|
||||
|
||||
const cardMemberships = await sails.helpers.getMembershipsForCard(card.id);
|
||||
const cardLabels = await sails.helpers.getCardLabelsForCard(card.id);
|
||||
const tasks = await sails.helpers.getTasksForCard(card.id);
|
||||
const attachments = await sails.helpers.getAttachmentsForCard(card.id);
|
||||
|
||||
sails.sockets.broadcast(
|
||||
`board:${card.boardId}`,
|
||||
'cardCreate',
|
||||
{
|
||||
item: card,
|
||||
included: {
|
||||
cardMemberships,
|
||||
cardLabels,
|
||||
tasks,
|
||||
attachments,
|
||||
},
|
||||
sails.sockets.broadcast(`board:${card.boardId}`, 'cardCreate', {
|
||||
item: card,
|
||||
included: {
|
||||
cardMemberships,
|
||||
cardLabels,
|
||||
tasks,
|
||||
attachments,
|
||||
},
|
||||
inputs.request,
|
||||
);
|
||||
});
|
||||
|
||||
const userIds = await sails.helpers.getSubscriptionUserIdsForCard(card.id);
|
||||
|
||||
userIds.forEach((userId) => {
|
||||
sails.sockets.broadcast(
|
||||
`user:${userId}`,
|
||||
'cardUpdate',
|
||||
{
|
||||
item: {
|
||||
id: card.id,
|
||||
isSubscribed: true,
|
||||
},
|
||||
sails.sockets.broadcast(`user:${userId}`, 'cardUpdate', {
|
||||
item: {
|
||||
id: card.id,
|
||||
isSubscribed: true,
|
||||
},
|
||||
inputs.request,
|
||||
);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
sails.sockets.broadcast(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue