mirror of
https://github.com/plankanban/planka.git
synced 2025-12-27 17:25:02 +03:00
Preserve members and labels when transfer card to another board
This commit is contained in:
@@ -26,9 +26,19 @@ export function* createCardRequest(listId, localId, data) {
|
||||
);
|
||||
|
||||
try {
|
||||
const { item } = yield call(request, api.createCard, listId, data);
|
||||
const {
|
||||
item,
|
||||
included: { cardMemberships, cardLabels, tasks, attachments },
|
||||
} = yield call(request, api.createCard, listId, data);
|
||||
|
||||
const action = createCardSucceeded(localId, item);
|
||||
const action = createCardSucceeded(
|
||||
localId,
|
||||
item,
|
||||
cardMemberships,
|
||||
cardLabels,
|
||||
tasks,
|
||||
attachments,
|
||||
);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
|
||||
@@ -2,11 +2,19 @@ import { call, put, select } from 'redux-saga/effects';
|
||||
|
||||
import { goToBoardService } from './router';
|
||||
import { createCardRequest, deleteCardRequest, updateCardRequest } from '../requests';
|
||||
import { nextCardPositionSelector, pathSelector } from '../../../selectors';
|
||||
import {
|
||||
boardByIdSelector,
|
||||
cardByIdSelector,
|
||||
listByIdSelector,
|
||||
nextCardPositionSelector,
|
||||
pathSelector,
|
||||
} from '../../../selectors';
|
||||
import { createCard, deleteCard, updateCard } from '../../../actions';
|
||||
import { createLocalId } from '../../../utils/local-id';
|
||||
|
||||
export function* createCardService(listId, data) {
|
||||
const { boardId } = yield select(listByIdSelector, listId);
|
||||
|
||||
const nextData = {
|
||||
...data,
|
||||
position: yield select(nextCardPositionSelector, listId),
|
||||
@@ -18,6 +26,7 @@ export function* createCardService(listId, data) {
|
||||
createCard({
|
||||
...nextData,
|
||||
listId,
|
||||
boardId,
|
||||
id: localId,
|
||||
}),
|
||||
);
|
||||
@@ -52,19 +61,40 @@ export function* moveCurrentCardService(listId, index) {
|
||||
}
|
||||
|
||||
export function* transferCardService(id, boardId, listId, index) {
|
||||
const position = yield select(nextCardPositionSelector, listId, index, id);
|
||||
const { cardId: currentCardId, boardId: currentBoardId } = yield select(pathSelector);
|
||||
|
||||
yield call(updateCardService, id, {
|
||||
boardId,
|
||||
listId,
|
||||
position,
|
||||
});
|
||||
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, boardId: currentBoardId } = yield select(pathSelector);
|
||||
const { cardId } = yield select(pathSelector);
|
||||
|
||||
yield call(goToBoardService, currentBoardId);
|
||||
yield call(transferCardService, cardId, boardId, listId, index);
|
||||
}
|
||||
|
||||
|
||||
@@ -163,8 +163,8 @@ export function* deleteLabelReceivedService(label) {
|
||||
yield put(deleteLabelReceived(label));
|
||||
}
|
||||
|
||||
export function* createCardReceivedService(card) {
|
||||
yield put(createCardReceived(card));
|
||||
export function* createCardReceivedService(card, cardMemberships, cardLabels, tasks, attachments) {
|
||||
yield put(createCardReceived(card, cardMemberships, cardLabels, tasks, attachments));
|
||||
}
|
||||
|
||||
export function* updateCardReceivedService(card) {
|
||||
|
||||
@@ -116,9 +116,11 @@ const createSocketEventsChannel = () =>
|
||||
emit([deleteLabelReceivedService, item]);
|
||||
};
|
||||
|
||||
const handleCardCreate = api.makeHandleCardCreate(({ item }) => {
|
||||
emit([createCardReceivedService, item]);
|
||||
});
|
||||
const handleCardCreate = api.makeHandleCardCreate(
|
||||
({ item, included: { cardMemberships, cardLabels, tasks, attachments } }) => {
|
||||
emit([createCardReceivedService, item, cardMemberships, cardLabels, tasks, attachments]);
|
||||
},
|
||||
);
|
||||
|
||||
const handleCardUpdate = api.makeHandleCardUpdate(({ item }) => {
|
||||
emit([updateCardReceivedService, item]);
|
||||
|
||||
Reference in New Issue
Block a user