summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2014-09-08 19:40:13 +0200
committerFrédéric Guillot <fred@kanboard.net>2014-09-08 19:40:13 +0200
commit9d39943bd43e2e0651bda3df7a32940a26f5e8ec (patch)
treec736f1d9ec858f6112f2e561093cadb778409f7a /app
parent5d5b4711e3783f9d75fba99695930aa09119a051 (diff)
Fix bug when moving tasks position in the same column
Diffstat (limited to 'app')
-rw-r--r--app/Model/Task.php16
1 files changed, 11 insertions, 5 deletions
diff --git a/app/Model/Task.php b/app/Model/Task.php
index d326c382..6eb24281 100644
--- a/app/Model/Task.php
+++ b/app/Model/Task.php
@@ -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) {