Fix bug when moving tasks position in the same column

This commit is contained in:
Frédéric Guillot
2014-09-08 19:40:13 +02:00
parent 5d5b4711e3
commit 9d39943bd4
2 changed files with 83 additions and 5 deletions

View File

@@ -560,23 +560,30 @@ class Task extends Base
->eq('project_id', $project_id)
->findAll();
// We sort everything by column and position
$board = $this->board->getColumnsList($project_id);
$columns = array();
$task_id = (int) $task_id;
// Prepare the columns
foreach ($board as $board_column_id => $board_column_name) {
$columns[$board_column_id] = array();
}
// The column must exists
if (! isset($columns[$column_id])) {
return false;
}
// Sort everything by column
foreach ($tasks as &$task) {
if ($task['id'] != $task_id) {
$columns[$task['column_id']][$task['position'] - 1] = (int) $task['id'];
}
}
// The column must exists
if (! isset($columns[$column_id])) {
return false;
// Sort all tasks by position
foreach ($columns as &$column) {
ksort($column);
}
// We put our task to the new position
@@ -601,7 +608,6 @@ class Task extends Base
foreach ($columns as $column_id => $column) {
$position = 1;
ksort($column);
foreach ($column as $task_id) {