Fix bug tasks don't show up on board/swimlanes
This commit is contained in:
parent
198f8d6a8e
commit
27f4537079
|
|
@ -239,15 +239,15 @@ class Board extends Base
|
|||
$columns = $this->getColumns($project_id);
|
||||
$nb_columns = count($columns);
|
||||
|
||||
foreach ($swimlanes as &$swimlane) {
|
||||
for ($i = 0, $ilen = count($swimlanes); $i < $ilen; $i++) {
|
||||
|
||||
foreach ($columns as &$column) {
|
||||
$column['tasks'] = $this->taskFinder->getTasksByColumnAndSwimlane($project_id, $column['id'], $swimlane['id']);
|
||||
$column['nb_tasks'] = count($column['tasks']);
|
||||
$swimlanes[$i]['columns'] = $columns;
|
||||
$swimlanes[$i]['nb_columns'] = $nb_columns;
|
||||
|
||||
for ($j = 0; $j < $nb_columns; $j++) {
|
||||
$swimlanes[$i]['columns'][$j]['tasks'] = $this->taskFinder->getTasksByColumnAndSwimlane($project_id, $columns[$j]['id'], $swimlanes[$i]['id']);
|
||||
$swimlanes[$i]['columns'][$j]['nb_tasks'] = count($swimlanes[$i]['columns'][$j]['tasks']);
|
||||
}
|
||||
|
||||
$swimlane['columns'] = $columns;
|
||||
$swimlane['nb_columns'] = $nb_columns;
|
||||
}
|
||||
|
||||
return $swimlanes;
|
||||
|
|
|
|||
|
|
@ -51,9 +51,10 @@ class TaskCreation extends Base
|
|||
$values['color_id'] = $this->color->getDefaultColor();
|
||||
}
|
||||
|
||||
$values['swimlane_id'] = empty($values['swimlane_id']) ? 0 : $values['swimlane_id'];
|
||||
$values['date_creation'] = time();
|
||||
$values['date_modification'] = $values['date_creation'];
|
||||
$values['position'] = $this->taskFinder->countByColumnId($values['project_id'], $values['column_id']) + 1;
|
||||
$values['position'] = $this->taskFinder->countByColumnAndSwimlaneId($values['project_id'], $values['column_id'], $values['swimlane_id']) + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -229,6 +229,26 @@ class TaskFinder extends Base
|
|||
->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* Count the number of tasks for a given column and swimlane
|
||||
*
|
||||
* @access public
|
||||
* @param integer $project_id Project id
|
||||
* @param integer $column_id Column id
|
||||
* @param integer $swimlane_id Swimlane id
|
||||
* @return integer
|
||||
*/
|
||||
public function countByColumnAndSwimlaneId($project_id, $column_id, $swimlane_id)
|
||||
{
|
||||
return $this->db
|
||||
->table(Task::TABLE)
|
||||
->eq('project_id', $project_id)
|
||||
->eq('column_id', $column_id)
|
||||
->eq('swimlane_id', $swimlane_id)
|
||||
->in('is_active', 1)
|
||||
->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the task exists
|
||||
*
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@ require_once __DIR__.'/Base.php';
|
|||
use Model\Project;
|
||||
use Model\Board;
|
||||
use Model\Config;
|
||||
use Model\TaskCreation;
|
||||
use Model\TaskFinder;
|
||||
use Model\Swimlane;
|
||||
|
||||
class BoardTest extends Base
|
||||
{
|
||||
|
|
@ -58,6 +61,93 @@ class BoardTest extends Base
|
|||
$this->assertTrue(array_key_exists('title', $board[0]['columns'][2]));
|
||||
}
|
||||
|
||||
public function testGetBoardWithSwimlane()
|
||||
{
|
||||
$b = new Board($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
$p = new Project($this->container);
|
||||
$s = new Swimlane($this->container);
|
||||
|
||||
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
|
||||
$this->assertEquals(1, $s->create(1, 'test 1'));
|
||||
$this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1, 'column_id' => 1)));
|
||||
$this->assertEquals(2, $tc->create(array('title' => 'Task #2', 'project_id' => 1, 'column_id' => 3)));
|
||||
$this->assertEquals(3, $tc->create(array('title' => 'Task #3', 'project_id' => 1, 'column_id' => 2, 'swimlane_id' => 1)));
|
||||
$this->assertEquals(4, $tc->create(array('title' => 'Task #4', 'project_id' => 1, 'column_id' => 3)));
|
||||
$this->assertEquals(5, $tc->create(array('title' => 'Task #5', 'project_id' => 1, 'column_id' => 4)));
|
||||
$this->assertEquals(6, $tc->create(array('title' => 'Task #6', 'project_id' => 1, 'column_id' => 4, 'swimlane_id' => 1)));
|
||||
|
||||
$board = $b->getBoard(1);
|
||||
$this->assertNotEmpty($board);
|
||||
$this->assertEquals(2, count($board));
|
||||
$this->assertEquals(4, count($board[0]));
|
||||
$this->assertTrue(array_key_exists('name', $board[0]));
|
||||
$this->assertTrue(array_key_exists('columns', $board[0]));
|
||||
$this->assertTrue(array_key_exists('tasks', $board[0]['columns'][2]));
|
||||
$this->assertTrue(array_key_exists('title', $board[0]['columns'][2]));
|
||||
|
||||
$task = $tf->getById(1);
|
||||
$this->assertEquals(1, $task['id']);
|
||||
$this->assertEquals(1, $task['column_id']);
|
||||
$this->assertEquals(1, $task['position']);
|
||||
$this->assertEquals(0, $task['swimlane_id']);
|
||||
$this->assertEquals(1, $board[0]['columns'][0]['tasks'][0]['id']);
|
||||
$this->assertEquals(1, $board[0]['columns'][0]['tasks'][0]['column_id']);
|
||||
$this->assertEquals(1, $board[0]['columns'][0]['tasks'][0]['position']);
|
||||
$this->assertEquals(0, $board[0]['columns'][0]['tasks'][0]['swimlane_id']);
|
||||
|
||||
$task = $tf->getById(2);
|
||||
$this->assertEquals(2, $task['id']);
|
||||
$this->assertEquals(3, $task['column_id']);
|
||||
$this->assertEquals(1, $task['position']);
|
||||
$this->assertEquals(0, $task['swimlane_id']);
|
||||
$this->assertEquals(2, $board[0]['columns'][2]['tasks'][0]['id']);
|
||||
$this->assertEquals(3, $board[0]['columns'][2]['tasks'][0]['column_id']);
|
||||
$this->assertEquals(1, $board[0]['columns'][2]['tasks'][0]['position']);
|
||||
$this->assertEquals(0, $board[0]['columns'][2]['tasks'][0]['swimlane_id']);
|
||||
|
||||
$task = $tf->getById(3);
|
||||
$this->assertEquals(3, $task['id']);
|
||||
$this->assertEquals(2, $task['column_id']);
|
||||
$this->assertEquals(1, $task['position']);
|
||||
$this->assertEquals(1, $task['swimlane_id']);
|
||||
$this->assertEquals(3, $board[1]['columns'][1]['tasks'][0]['id']);
|
||||
$this->assertEquals(2, $board[1]['columns'][1]['tasks'][0]['column_id']);
|
||||
$this->assertEquals(1, $board[1]['columns'][1]['tasks'][0]['position']);
|
||||
$this->assertEquals(1, $board[1]['columns'][1]['tasks'][0]['swimlane_id']);
|
||||
|
||||
$task = $tf->getById(4);
|
||||
$this->assertEquals(4, $task['id']);
|
||||
$this->assertEquals(3, $task['column_id']);
|
||||
$this->assertEquals(2, $task['position']);
|
||||
$this->assertEquals(0, $task['swimlane_id']);
|
||||
$this->assertEquals(4, $board[0]['columns'][2]['tasks'][1]['id']);
|
||||
$this->assertEquals(3, $board[0]['columns'][2]['tasks'][1]['column_id']);
|
||||
$this->assertEquals(2, $board[0]['columns'][2]['tasks'][1]['position']);
|
||||
$this->assertEquals(0, $board[0]['columns'][2]['tasks'][1]['swimlane_id']);
|
||||
|
||||
$task = $tf->getById(5);
|
||||
$this->assertEquals(5, $task['id']);
|
||||
$this->assertEquals(4, $task['column_id']);
|
||||
$this->assertEquals(1, $task['position']);
|
||||
$this->assertEquals(0, $task['swimlane_id']);
|
||||
$this->assertEquals(5, $board[0]['columns'][3]['tasks'][0]['id']);
|
||||
$this->assertEquals(4, $board[0]['columns'][3]['tasks'][0]['column_id']);
|
||||
$this->assertEquals(1, $board[0]['columns'][3]['tasks'][0]['position']);
|
||||
$this->assertEquals(0, $board[0]['columns'][3]['tasks'][0]['swimlane_id']);
|
||||
|
||||
$task = $tf->getById(6);
|
||||
$this->assertEquals(6, $task['id']);
|
||||
$this->assertEquals(4, $task['column_id']);
|
||||
$this->assertEquals(1, $task['position']);
|
||||
$this->assertEquals(1, $task['swimlane_id']);
|
||||
$this->assertEquals(6, $board[1]['columns'][3]['tasks'][0]['id']);
|
||||
$this->assertEquals(4, $board[1]['columns'][3]['tasks'][0]['column_id']);
|
||||
$this->assertEquals(1, $board[1]['columns'][3]['tasks'][0]['position']);
|
||||
$this->assertEquals(1, $board[1]['columns'][3]['tasks'][0]['swimlane_id']);
|
||||
}
|
||||
|
||||
public function testGetColumn()
|
||||
{
|
||||
$p = new Project($this->container);
|
||||
|
|
|
|||
|
|
@ -396,6 +396,7 @@ class TaskPositionTest extends Base
|
|||
$this->assertEquals(2, $tc->create(array('title' => 'Task #2', 'project_id' => 1, 'column_id' => 1)));
|
||||
$this->assertEquals(3, $tc->create(array('title' => 'Task #3', 'project_id' => 1, 'column_id' => 1)));
|
||||
$this->assertEquals(4, $tc->create(array('title' => 'Task #4', 'project_id' => 1, 'column_id' => 1)));
|
||||
$this->assertEquals(5, $tc->create(array('title' => 'Task #5', 'project_id' => 1, 'column_id' => 1)));
|
||||
|
||||
// Move the task to the swimlane
|
||||
$this->assertTrue($tp->movePosition(1, 1, 2, 1, 1));
|
||||
|
|
@ -452,6 +453,40 @@ class TaskPositionTest extends Base
|
|||
$this->assertEquals(1, $task['column_id']);
|
||||
$this->assertEquals(2, $task['position']);
|
||||
$this->assertEquals(0, $task['swimlane_id']);
|
||||
|
||||
// Move the task 5 to the last column
|
||||
$this->assertTrue($tp->movePosition(1, 5, 4, 1, 0));
|
||||
|
||||
// Check tasks position
|
||||
$task = $tf->getById(1);
|
||||
$this->assertEquals(1, $task['id']);
|
||||
$this->assertEquals(2, $task['column_id']);
|
||||
$this->assertEquals(2, $task['position']);
|
||||
$this->assertEquals(1, $task['swimlane_id']);
|
||||
|
||||
$task = $tf->getById(2);
|
||||
$this->assertEquals(2, $task['id']);
|
||||
$this->assertEquals(2, $task['column_id']);
|
||||
$this->assertEquals(1, $task['position']);
|
||||
$this->assertEquals(1, $task['swimlane_id']);
|
||||
|
||||
$task = $tf->getById(3);
|
||||
$this->assertEquals(3, $task['id']);
|
||||
$this->assertEquals(1, $task['column_id']);
|
||||
$this->assertEquals(1, $task['position']);
|
||||
$this->assertEquals(0, $task['swimlane_id']);
|
||||
|
||||
$task = $tf->getById(4);
|
||||
$this->assertEquals(4, $task['id']);
|
||||
$this->assertEquals(1, $task['column_id']);
|
||||
$this->assertEquals(2, $task['position']);
|
||||
$this->assertEquals(0, $task['swimlane_id']);
|
||||
|
||||
$task = $tf->getById(5);
|
||||
$this->assertEquals(5, $task['id']);
|
||||
$this->assertEquals(4, $task['column_id']);
|
||||
$this->assertEquals(1, $task['position']);
|
||||
$this->assertEquals(0, $task['swimlane_id']);
|
||||
}
|
||||
|
||||
public function testEvents()
|
||||
|
|
|
|||
Loading…
Reference in New Issue