feat: Labels reordering

Closes #289
This commit is contained in:
Maksim Eltyshev
2023-01-09 12:17:06 +01:00
parent d627a19935
commit aa69bb8d1e
33 changed files with 370 additions and 104 deletions

View File

@@ -108,10 +108,13 @@ export const selectLabelsForCurrentBoard = createSelector(
return boardModel;
}
return boardModel.labels.toRefArray().map((label) => ({
...label,
isPersisted: !isLocalId(label.id),
}));
return boardModel
.getOrderedLabelsQuerySet()
.toRefArray()
.map((label) => ({
...label,
isPersisted: !isLocalId(label.id),
}));
},
);

View File

@@ -49,6 +49,22 @@ export const selectNextBoardPosition = createSelector(
},
);
export const selectNextLabelPosition = createSelector(
orm,
(_, boardId) => boardId,
(_, __, index) => index,
(_, __, ___, excludedId) => excludedId,
({ Board }, boardId, index, excludedId) => {
const boardModel = Board.withId(boardId);
if (!boardModel) {
return boardModel;
}
return nextPosition(boardModel.getOrderedLabelsQuerySet().toRefArray(), index, excludedId);
},
);
export const selectNextListPosition = createSelector(
orm,
(_, boardId) => boardId,
@@ -102,6 +118,7 @@ export default {
selectIsCoreInitializing,
selectIsLogouting,
selectNextBoardPosition,
selectNextLabelPosition,
selectNextListPosition,
selectNextCardPosition,
selectNextTaskPosition,

View File

@@ -7,6 +7,7 @@ import projects from './projects';
import projectManagers from './project-managers';
import boards from './boards';
import boardMemberships from './board-memberships';
import labels from './labels';
import lists from './lists';
import cards from './cards';
import tasks from './tasks';
@@ -22,6 +23,7 @@ export default {
...projectManagers,
...boards,
...boardMemberships,
...labels,
...lists,
...cards,
...tasks,

View File

@@ -0,0 +1,25 @@
import { createSelector } from 'redux-orm';
import orm from '../orm';
export const makeSelectLabelById = () =>
createSelector(
orm,
(_, id) => id,
({ Label }, id) => {
const labelModel = Label.withId(id);
if (!labelModel) {
return labelModel;
}
return labelModel.ref;
},
);
export const selectLabelById = makeSelectLabelById();
export default {
makeSelectLabelById,
selectLabelById,
};