mirror of
https://github.com/plankanban/planka.git
synced 2025-07-19 13:19:44 +02:00
Initial commit
This commit is contained in:
commit
36fe34e8e1
583 changed files with 91539 additions and 0 deletions
93
client/src/sagas/app/services/label.js
Normal file
93
client/src/sagas/app/services/label.js
Normal file
|
@ -0,0 +1,93 @@
|
|||
import { call, put, select } from 'redux-saga/effects';
|
||||
|
||||
import {
|
||||
createCardLabelRequest,
|
||||
createLabelRequest,
|
||||
deleteCardLabelRequest,
|
||||
deleteLabelRequest,
|
||||
updateLabelRequest,
|
||||
} from '../requests';
|
||||
import { maxIdSelector, pathSelector } from '../../../selectors';
|
||||
import {
|
||||
addLabelToBoardFilter,
|
||||
addLabelToCard,
|
||||
createLabel,
|
||||
deleteLabel,
|
||||
removeLabelFromBoardFilter,
|
||||
removeLabelFromCard,
|
||||
updateLabel,
|
||||
} from '../../../actions';
|
||||
import { nextLocalId } from '../../../utils/local-id';
|
||||
import { Label } from '../../../models';
|
||||
|
||||
export function* createLabelService(boardId, data) {
|
||||
const localId = nextLocalId(yield select(maxIdSelector, Label.modelName));
|
||||
|
||||
yield put(
|
||||
createLabel({
|
||||
...data,
|
||||
boardId,
|
||||
id: localId,
|
||||
}),
|
||||
);
|
||||
|
||||
yield call(createLabelRequest, boardId, localId, data);
|
||||
}
|
||||
|
||||
export function* createLabelInCurrentBoardService(data) {
|
||||
const { boardId } = yield select(pathSelector);
|
||||
|
||||
yield call(createLabelService, boardId, data);
|
||||
}
|
||||
|
||||
export function* updateLabelService(id, data) {
|
||||
yield put(updateLabel(id, data));
|
||||
yield call(updateLabelRequest, id, data);
|
||||
}
|
||||
|
||||
export function* deleteLabelService(id) {
|
||||
yield put(deleteLabel(id));
|
||||
yield call(deleteLabelRequest, id);
|
||||
}
|
||||
|
||||
export function* addLabelToCardService(id, cardId) {
|
||||
yield put(addLabelToCard(id, cardId));
|
||||
yield call(createCardLabelRequest, cardId, id);
|
||||
}
|
||||
|
||||
export function* addLabelToCurrentCardService(id) {
|
||||
const { cardId } = yield select(pathSelector);
|
||||
|
||||
yield call(addLabelToCardService, id, cardId);
|
||||
}
|
||||
|
||||
export function* removeLabelFromCardService(id, cardId) {
|
||||
yield put(removeLabelFromCard(id, cardId));
|
||||
yield call(deleteCardLabelRequest, cardId, id);
|
||||
}
|
||||
|
||||
export function* removeLabelFromCurrentCardService(id) {
|
||||
const { cardId } = yield select(pathSelector);
|
||||
|
||||
yield call(removeLabelFromCardService, id, cardId);
|
||||
}
|
||||
|
||||
export function* addLabelToBoardFilterService(id, boardId) {
|
||||
yield put(addLabelToBoardFilter(id, boardId));
|
||||
}
|
||||
|
||||
export function* addLabelToFilterInCurrentBoardService(id) {
|
||||
const { boardId } = yield select(pathSelector);
|
||||
|
||||
yield call(addLabelToBoardFilterService, id, boardId);
|
||||
}
|
||||
|
||||
export function* removeLabelFromBoardFilterService(id, boardId) {
|
||||
yield put(removeLabelFromBoardFilter(id, boardId));
|
||||
}
|
||||
|
||||
export function* removeLabelFromFilterInCurrentBoardService(id) {
|
||||
const { boardId } = yield select(pathSelector);
|
||||
|
||||
yield call(removeLabelFromBoardFilterService, id, boardId);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue