Duplicate a project with tasks will copy the new tasks in the same columns
This commit is contained in:
parent
6dba53317c
commit
4785174e43
|
|
@ -21,6 +21,7 @@ Core functionalities moved to plugins:
|
|||
|
||||
Improvements:
|
||||
|
||||
* Duplicate a project with tasks will copy the new tasks in the same columns
|
||||
* Offer alternative method to create Mysql and Postgres databases (import sql dump)
|
||||
* Make sure there is always a trailing slash for application_url
|
||||
* Do not show the checkbox "Show default swimlane" when there is no active swimlanes
|
||||
|
|
|
|||
|
|
@ -64,7 +64,9 @@ class TaskDuplicateAnotherProject extends Base
|
|||
*/
|
||||
public function doAction(array $data)
|
||||
{
|
||||
return (bool) $this->taskDuplication->duplicateToProject($data['task_id'], $this->getParam('project_id'));
|
||||
$destination_column_id = $this->board->getFirstColumn($this->getParam('project_id'));
|
||||
|
||||
return (bool) $this->taskDuplication->duplicateToProject($data['task_id'], $this->getParam('project_id'), null, $destination_column_id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -402,6 +402,18 @@ class Board extends Base
|
|||
return (int) $this->db->table(self::TABLE)->eq('project_id', $project_id)->eq('title', $title)->findOneColumn('id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a column title by the id
|
||||
*
|
||||
* @access public
|
||||
* @param integer $column_id
|
||||
* @return integer
|
||||
*/
|
||||
public function getColumnTitleById($column_id)
|
||||
{
|
||||
return $this->db->table(self::TABLE)->eq('id', $column_id)->findOneColumn('title');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the position of the last column for a given project
|
||||
*
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ class TaskDuplication extends Base
|
|||
{
|
||||
$values = $this->copyFields($task_id);
|
||||
$values['project_id'] = $project_id;
|
||||
$values['column_id'] = $column_id !== null ? $column_id : $this->board->getFirstColumn($project_id);
|
||||
$values['column_id'] = $column_id !== null ? $column_id : $values['column_id'];
|
||||
$values['swimlane_id'] = $swimlane_id !== null ? $swimlane_id : $values['swimlane_id'];
|
||||
$values['category_id'] = $category_id !== null ? $category_id : $values['category_id'];
|
||||
$values['owner_id'] = $owner_id !== null ? $owner_id : $values['owner_id'];
|
||||
|
|
@ -134,7 +134,7 @@ class TaskDuplication extends Base
|
|||
$values = array();
|
||||
$values['is_active'] = 1;
|
||||
$values['project_id'] = $project_id;
|
||||
$values['column_id'] = $column_id !== null ? $column_id : $this->board->getFirstColumn($project_id);
|
||||
$values['column_id'] = $column_id !== null ? $column_id : $task['column_id'];
|
||||
$values['position'] = $this->taskFinder->countByColumnId($project_id, $values['column_id']) + 1;
|
||||
$values['swimlane_id'] = $swimlane_id !== null ? $swimlane_id : $task['swimlane_id'];
|
||||
$values['category_id'] = $category_id !== null ? $category_id : $task['category_id'];
|
||||
|
|
@ -181,6 +181,16 @@ class TaskDuplication extends Base
|
|||
);
|
||||
}
|
||||
|
||||
// Check if the column exists for the destination project
|
||||
if ($values['column_id'] > 0) {
|
||||
$values['column_id'] = $this->board->getColumnIdByTitle(
|
||||
$values['project_id'],
|
||||
$this->board->getColumnTitleById($values['column_id'])
|
||||
);
|
||||
|
||||
$values['column_id'] = $values['column_id'] ?: $this->board->getFirstColumn($values['project_id']);
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ class TaskDuplicationTest extends Base
|
|||
$this->assertEquals(1, $task['owner_id']);
|
||||
$this->assertEquals(0, $task['category_id']);
|
||||
$this->assertEquals(0, $task['swimlane_id']);
|
||||
$this->assertEquals(5, $task['column_id']);
|
||||
$this->assertEquals(6, $task['column_id']);
|
||||
$this->assertEquals(1, $task['position']);
|
||||
$this->assertEquals(2, $task['project_id']);
|
||||
$this->assertEquals('test', $task['title']);
|
||||
|
|
@ -168,7 +168,7 @@ class TaskDuplicationTest extends Base
|
|||
$this->assertEquals(0, $task['owner_id']);
|
||||
$this->assertEquals(2, $task['category_id']);
|
||||
$this->assertEquals(0, $task['swimlane_id']);
|
||||
$this->assertEquals(5, $task['column_id']);
|
||||
$this->assertEquals(6, $task['column_id']);
|
||||
$this->assertEquals(1, $task['position']);
|
||||
$this->assertEquals(2, $task['project_id']);
|
||||
$this->assertEquals('test', $task['title']);
|
||||
|
|
@ -240,7 +240,7 @@ class TaskDuplicationTest extends Base
|
|||
$this->assertEquals(0, $task['owner_id']);
|
||||
$this->assertEquals(0, $task['category_id']);
|
||||
$this->assertEquals(2, $task['swimlane_id']);
|
||||
$this->assertEquals(5, $task['column_id']);
|
||||
$this->assertEquals(6, $task['column_id']);
|
||||
$this->assertEquals(1, $task['position']);
|
||||
$this->assertEquals(2, $task['project_id']);
|
||||
$this->assertEquals('test', $task['title']);
|
||||
|
|
@ -273,7 +273,7 @@ class TaskDuplicationTest extends Base
|
|||
$this->assertEquals(0, $task['owner_id']);
|
||||
$this->assertEquals(0, $task['category_id']);
|
||||
$this->assertEquals(0, $task['swimlane_id']);
|
||||
$this->assertEquals(5, $task['column_id']);
|
||||
$this->assertEquals(6, $task['column_id']);
|
||||
$this->assertEquals(1, $task['position']);
|
||||
$this->assertEquals(2, $task['project_id']);
|
||||
$this->assertEquals('test', $task['title']);
|
||||
|
|
@ -352,7 +352,7 @@ class TaskDuplicationTest extends Base
|
|||
$task = $tf->getById(2);
|
||||
$this->assertNotEmpty($task);
|
||||
$this->assertEquals(0, $task['owner_id']);
|
||||
$this->assertEquals(5, $task['column_id']);
|
||||
$this->assertEquals(6, $task['column_id']);
|
||||
$this->assertEquals(1, $task['position']);
|
||||
$this->assertEquals(2, $task['project_id']);
|
||||
$this->assertEquals('test', $task['title']);
|
||||
|
|
@ -372,6 +372,7 @@ class TaskDuplicationTest extends Base
|
|||
$task = $tf->getById(3);
|
||||
$this->assertNotEmpty($task);
|
||||
$this->assertEquals(2, $task['position']);
|
||||
$this->assertEquals(6, $task['column_id']);
|
||||
$this->assertEquals(2, $task['owner_id']);
|
||||
$this->assertEquals(2, $task['project_id']);
|
||||
|
||||
|
|
@ -381,7 +382,7 @@ class TaskDuplicationTest extends Base
|
|||
|
||||
$task = $tf->getById(5);
|
||||
$this->assertNotEmpty($task);
|
||||
$this->assertEquals(3, $task['position']);
|
||||
$this->assertEquals(1, $task['position']);
|
||||
$this->assertEquals(0, $task['owner_id']);
|
||||
$this->assertEquals(2, $task['project_id']);
|
||||
$this->assertEquals(5, $task['column_id']);
|
||||
|
|
@ -486,7 +487,7 @@ class TaskDuplicationTest extends Base
|
|||
$this->assertEquals(0, $task['owner_id']);
|
||||
$this->assertEquals(2, $task['category_id']);
|
||||
$this->assertEquals(0, $task['swimlane_id']);
|
||||
$this->assertEquals(5, $task['column_id']);
|
||||
$this->assertEquals(6, $task['column_id']);
|
||||
$this->assertEquals(1, $task['position']);
|
||||
$this->assertEquals(2, $task['project_id']);
|
||||
$this->assertEquals('test', $task['title']);
|
||||
|
|
@ -524,7 +525,7 @@ class TaskDuplicationTest extends Base
|
|||
$this->assertEquals(1, $task['position']);
|
||||
$this->assertEquals(2, $task['owner_id']);
|
||||
$this->assertEquals(2, $task['project_id']);
|
||||
$this->assertEquals(5, $task['column_id']);
|
||||
$this->assertEquals(6, $task['column_id']);
|
||||
}
|
||||
|
||||
public function testMoveAnotherProjectWithForbiddenUser()
|
||||
|
|
@ -559,7 +560,7 @@ class TaskDuplicationTest extends Base
|
|||
$this->assertEquals(1, $task['position']);
|
||||
$this->assertEquals(0, $task['owner_id']);
|
||||
$this->assertEquals(2, $task['project_id']);
|
||||
$this->assertEquals(5, $task['column_id']);
|
||||
$this->assertEquals(6, $task['column_id']);
|
||||
}
|
||||
|
||||
public function testMoveAnotherProjectWithSwimlane()
|
||||
|
|
@ -589,7 +590,7 @@ class TaskDuplicationTest extends Base
|
|||
$this->assertEquals(0, $task['owner_id']);
|
||||
$this->assertEquals(0, $task['category_id']);
|
||||
$this->assertEquals(2, $task['swimlane_id']);
|
||||
$this->assertEquals(5, $task['column_id']);
|
||||
$this->assertEquals(6, $task['column_id']);
|
||||
$this->assertEquals(1, $task['position']);
|
||||
$this->assertEquals(2, $task['project_id']);
|
||||
$this->assertEquals('test', $task['title']);
|
||||
|
|
@ -622,7 +623,7 @@ class TaskDuplicationTest extends Base
|
|||
$this->assertEquals(0, $task['owner_id']);
|
||||
$this->assertEquals(0, $task['category_id']);
|
||||
$this->assertEquals(0, $task['swimlane_id']);
|
||||
$this->assertEquals(5, $task['column_id']);
|
||||
$this->assertEquals(6, $task['column_id']);
|
||||
$this->assertEquals(1, $task['position']);
|
||||
$this->assertEquals(2, $task['project_id']);
|
||||
$this->assertEquals('test', $task['title']);
|
||||
|
|
|
|||
Loading…
Reference in New Issue