Commit 4b41a46e authored by Jan Provaznik's avatar Jan Provaznik

Allow repositioning epics on epic boards

* allows moving epics between lists
* disables resorting of epics by position (this is done on server side)
parent 8da3c665
import { sortBy } from 'lodash';
import { FiltersInfo as FiltersInfoCE } from '~/boards/boards_util'; import { FiltersInfo as FiltersInfoCE } from '~/boards/boards_util';
import { getIdFromGraphQLId } from '~/graphql_shared/utils'; import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import { urlParamsToObject } from '~/lib/utils/common_utils'; import { urlParamsToObject } from '~/lib/utils/common_utils';
...@@ -44,10 +43,9 @@ export function formatListEpics(listEpics) { ...@@ -44,10 +43,9 @@ export function formatListEpics(listEpics) {
const listData = listEpics.nodes.reduce((map, list) => { const listData = listEpics.nodes.reduce((map, list) => {
listItemsCount = list.epicsCount; listItemsCount = list.epicsCount;
let sortedEpics = list.epics.edges.map((epicNode) => ({ const sortedEpics = list.epics.edges.map((epicNode) => ({
...epicNode.node, ...epicNode.node,
})); }));
sortedEpics = sortBy(sortedEpics, 'relativePosition');
return { return {
...map, ...map,
......
...@@ -3,9 +3,18 @@ mutation EpicMoveList( ...@@ -3,9 +3,18 @@ mutation EpicMoveList(
$boardId: BoardsEpicBoardID! $boardId: BoardsEpicBoardID!
$fromListId: BoardsEpicListID! $fromListId: BoardsEpicListID!
$toListId: BoardsEpicListID! $toListId: BoardsEpicListID!
$moveAfterId: EpicID
$moveBeforeId: EpicID
) { ) {
epicMoveList( epicMoveList(
input: { epicId: $epicId, boardId: $boardId, fromListId: $fromListId, toListId: $toListId } input: {
epicId: $epicId
boardId: $boardId
fromListId: $fromListId
toListId: $toListId
moveAfterId: $moveAfterId
moveBeforeId: $moveBeforeId
}
) { ) {
errors errors
} }
......
...@@ -405,6 +405,8 @@ export default { ...@@ -405,6 +405,8 @@ export default {
boardId: fullEpicBoardId(boardId), boardId: fullEpicBoardId(boardId),
fromListId, fromListId,
toListId, toListId,
moveAfterId: moveAfterId ? fullEpicId(moveAfterId) : undefined,
moveBeforeId: moveBeforeId ? fullEpicId(moveBeforeId) : undefined,
}, },
}) })
.then(({ data }) => { .then(({ data }) => {
......
...@@ -87,14 +87,29 @@ RSpec.describe 'epic boards', :js do ...@@ -87,14 +87,29 @@ RSpec.describe 'epic boards', :js do
expect(find('.board:nth-child(3) .board-card')).to have_content(epic3.title) expect(find('.board:nth-child(3) .board-card')).to have_content(epic3.title)
end end
it 'moves epic between lists' do it 'moves to the bottom of another list' do
expect(find('.board:nth-child(1)')).to have_content(epic3.title) expect(find_board_list(1)).to have_content(epic3.title)
drag(list_from_index: 0, list_to_index: 1) drag(list_from_index: 0, list_to_index: 1, to_index: 1)
wait_for_all_requests wait_for_all_requests
expect(find_board_list(1)).not_to have_content(epic3.title) expect(find_board_list(1)).not_to have_content(epic3.title)
expect(find_board_list(2)).to have_content(epic3.title) page.within(find_board_list(2)) do
expect(all('.board-card')[1]).to have_content(epic3.title)
end
end
it 'moves to the top of another list' do
expect(find_board_list(1)).to have_content(epic3.title)
drag(list_from_index: 0, list_to_index: 1, to_index: 0)
wait_for_all_requests
expect(find_board_list(1)).not_to have_content(epic3.title)
page.within(find_board_list(2)) do
expect(all('.board-card')[0]).to have_content(epic3.title)
end
end end
context 'lists' do context 'lists' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment