mirror of
https://github.com/plankanban/planka.git
synced 2025-07-19 05:09:43 +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
|
@ -2,13 +2,7 @@ import { call, put, select } from 'redux-saga/effects';
|
|||
|
||||
import { goToBoardService } from './router';
|
||||
import { createCardRequest, deleteCardRequest, updateCardRequest } from '../requests';
|
||||
import {
|
||||
boardByIdSelector,
|
||||
cardByIdSelector,
|
||||
listByIdSelector,
|
||||
nextCardPositionSelector,
|
||||
pathSelector,
|
||||
} from '../../../selectors';
|
||||
import { listByIdSelector, nextCardPositionSelector, pathSelector } from '../../../selectors';
|
||||
import { createCard, deleteCard, updateCard } from '../../../actions';
|
||||
import { createLocalId } from '../../../utils/local-id';
|
||||
|
||||
|
@ -62,35 +56,20 @@ export function* moveCurrentCardService(listId, index) {
|
|||
|
||||
export function* transferCardService(id, boardId, listId, index) {
|
||||
const { cardId: currentCardId, boardId: currentBoardId } = yield select(pathSelector);
|
||||
const position = yield select(nextCardPositionSelector, listId, index, id);
|
||||
|
||||
if (id === currentCardId) {
|
||||
yield call(goToBoardService, currentBoardId);
|
||||
}
|
||||
|
||||
const card = yield select(cardByIdSelector, id);
|
||||
const board = yield select(boardByIdSelector, boardId);
|
||||
|
||||
yield put(deleteCard(id));
|
||||
|
||||
if (board.isFetching === false) {
|
||||
const position = yield select(nextCardPositionSelector, listId, index, id);
|
||||
|
||||
yield put(
|
||||
createCard({
|
||||
...card,
|
||||
listId,
|
||||
boardId,
|
||||
position,
|
||||
}),
|
||||
);
|
||||
|
||||
yield call(updateCardRequest, id, {
|
||||
listId,
|
||||
boardId,
|
||||
position,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export function* transferCurrentCardService(boardId, listId, index) {
|
||||
const { cardId } = yield select(pathSelector);
|
||||
|
|
|
@ -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,24 +157,23 @@ module.exports = {
|
|||
}),
|
||||
);
|
||||
|
||||
labelIds.forEach(async (labelId) => {
|
||||
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',
|
||||
{
|
||||
sails.sockets.broadcast(`board:${card.boardId}`, 'cardCreate', {
|
||||
item: card,
|
||||
included: {
|
||||
cardMemberships,
|
||||
|
@ -182,24 +181,17 @@ module.exports = {
|
|||
tasks,
|
||||
attachments,
|
||||
},
|
||||
},
|
||||
inputs.request,
|
||||
);
|
||||
});
|
||||
|
||||
const userIds = await sails.helpers.getSubscriptionUserIdsForCard(card.id);
|
||||
|
||||
userIds.forEach((userId) => {
|
||||
sails.sockets.broadcast(
|
||||
`user:${userId}`,
|
||||
'cardUpdate',
|
||||
{
|
||||
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