@@ -7,11 +7,16 @@ import api from '../../../api';
|
||||
import { createLocalId } from '../../../utils/local-id';
|
||||
|
||||
export function* createLabel(boardId, data) {
|
||||
const nextData = {
|
||||
...data,
|
||||
position: yield select(selectors.selectNextLabelPosition, boardId),
|
||||
};
|
||||
|
||||
const localId = yield call(createLocalId);
|
||||
|
||||
yield put(
|
||||
actions.createLabel({
|
||||
...data,
|
||||
...nextData,
|
||||
boardId,
|
||||
id: localId,
|
||||
}),
|
||||
@@ -19,7 +24,7 @@ export function* createLabel(boardId, data) {
|
||||
|
||||
let label;
|
||||
try {
|
||||
({ item: label } = yield call(request, api.createLabel, boardId, data));
|
||||
({ item: label } = yield call(request, api.createLabel, boardId, nextData));
|
||||
} catch (error) {
|
||||
yield put(actions.createLabel.failure(localId, error));
|
||||
return;
|
||||
@@ -56,6 +61,15 @@ export function* handleLabelUpdate(label) {
|
||||
yield put(actions.handleLabelUpdate(label));
|
||||
}
|
||||
|
||||
export function* moveLabel(id, index) {
|
||||
const { boardId } = yield select(selectors.selectLabelById, id);
|
||||
const position = yield select(selectors.selectNextLabelPosition, boardId, index, id);
|
||||
|
||||
yield call(updateLabel, id, {
|
||||
position,
|
||||
});
|
||||
}
|
||||
|
||||
export function* deleteLabel(id) {
|
||||
yield put(actions.deleteLabel(id));
|
||||
|
||||
@@ -150,6 +164,7 @@ export default {
|
||||
handleLabelCreate,
|
||||
updateLabel,
|
||||
handleLabelUpdate,
|
||||
moveLabel,
|
||||
deleteLabel,
|
||||
handleLabelDelete,
|
||||
addLabelToCard,
|
||||
|
||||
Reference in New Issue
Block a user