Allow issues in boards to be ordered
Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/21264.
Based on approach described in https://gitlab.com/gitlab-org/gitlab-ce/issues/21264#note_22464646.
We sort on a relative_position
float, which effectively maintains a global ordering of issues, where it's simple to insert issue X between issues Y and Z: set x.relative_position
to any value between y.relative_position
and z.relative_position
. With floats rather than integer values, these values are plenty and easy to find.
Note that currently, when no issues have been ordered yet, and you order 1 issue, only that issue and the 2 issues around it will get their position set, because we assume that that’s the 3 whose relative ordering you care about. That means that if you refresh the page, those 3 will be at the top in the right order, but the other issues will stay at the bottom until you assign them a place too. This feels like a bug and will be fixed by todo number 2.
To do
-
Set relative_position
on issues that don't have one yet when they are loaded into view in theProjects::Boards::IssuesController
. This way we don't need to backfill all issues, we just have to set the value on those we actually view. Since issues without a position are always displayed at the end of the list, we can simply callissue.move_to_end
to set the appropriate position. -
Optional: Automatically update the frontend so that if an issue occurs in multiple lists and the issue is moved in one list, it will also automatically move in another list. The frontend would need access to the relative_position
of the moved issue and its neighbours. -
Add tests -
Ruby unit tests -
Feature specs
-
I invite anyone to pick it up and finish it, because I likely won't have time to do so for 8.17 or 9.0 :)