diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-01-23 12:29:44 -0500 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-01-23 12:29:44 -0500 |
commit | ba5937b07490160affad8239a7a9e6227979f770 (patch) | |
tree | c9174bed0db928160e1dd55bf06ac7fbc57acab2 | |
parent | 0448fdc56b9d7c58ac78d8375447c59b68702562 (diff) |
Add new API procedures to move and duplicate tasks to another project
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | app/Api/Task.php | 10 | ||||
-rw-r--r-- | doc/api-task-procedures.markdown | 76 | ||||
-rw-r--r-- | tests/integration/TaskTest.php | 38 |
4 files changed, 124 insertions, 2 deletions
@@ -6,7 +6,7 @@ New features: * Forgot Password * Add dropdown menu on each board column title to close all tasks * Add Malay language -* Add new API procedures for groups, roles and project permissions +* Add new API procedures for groups, roles, project permissions and to move/duplicate tasks to another project Improvements: diff --git a/app/Api/Task.php b/app/Api/Task.php index 97d89775..f132bcd6 100644 --- a/app/Api/Task.php +++ b/app/Api/Task.php @@ -64,6 +64,16 @@ class Task extends Base return $this->taskPosition->movePosition($project_id, $task_id, $column_id, $position, $swimlane_id); } + public function moveTaskToProject($task_id, $project_id, $swimlane_id = null, $column_id = null, $category_id = null, $owner_id = null) + { + return $this->taskDuplication->moveToProject($task_id, $project_id, $swimlane_id, $column_id, $category_id, $owner_id); + } + + public function duplicateTaskToProject($task_id, $project_id, $swimlane_id = null, $column_id = null, $category_id = null, $owner_id = null) + { + return $this->taskDuplication->duplicateToProject($task_id, $project_id, $swimlane_id, $column_id, $category_id, $owner_id); + } + public function createTask($title, $project_id, $color_id = '', $column_id = 0, $owner_id = 0, $creator_id = 0, $date_due = '', $description = '', $category_id = 0, $score = 0, $swimlane_id = 0, $recurrence_status = 0, $recurrence_trigger = 0, $recurrence_factor = 0, $recurrence_timeframe = 0, diff --git a/doc/api-task-procedures.markdown b/doc/api-task-procedures.markdown index f2ca54d1..49868e2a 100644 --- a/doc/api-task-procedures.markdown +++ b/doc/api-task-procedures.markdown @@ -525,7 +525,7 @@ Response example: ### moveTaskPosition -- Purpose: **Move a task to another column or another position** +- Purpose: **Move a task to another column, position or swimlane inside the same board** - Parameters: - **project_id** (integer, required) - **task_id** (integer, required) @@ -560,3 +560,77 @@ Response example: "result": true } ``` + +### moveTaskToProject + +- Purpose: **Move a task to another project** +- Parameters: + - **task_id** (integer, required) + - **project_id** (integer, required) + - **swimlane_id** (integer, optional) + - **column_id** (integer, optional) + - **category_id** (integer, optional) + - **owner_id** (integer, optional) +- Result on success: **true** +- Result on failure: **false** + +Request example: + +```json +{ + "jsonrpc": "2.0", + "method": "moveTaskToProject", + "id": 15775829, + "params": [ + 4, + 5 + ] +} +``` + +Response example: + +```json +{ + "jsonrpc": "2.0", + "id": 15775829, + "result": true +} +``` + +### duplicateTaskToProject + +- Purpose: **Move a task to another column or another position** +- Parameters: + - **task_id** (integer, required) + - **project_id** (integer, required) + - **swimlane_id** (integer, optional) + - **column_id** (integer, optional) + - **category_id** (integer, optional) + - **owner_id** (integer, optional) +- Result on success: **task_id** +- Result on failure: **false** + +Request example: + +```json +{ + "jsonrpc": "2.0", + "method": "duplicateTaskToProject", + "id": 1662458687, + "params": [ + 5, + 7 + ] +} +``` + +Response example: + +```json +{ + "jsonrpc": "2.0", + "id": 1662458687, + "result": 6 +} +``` diff --git a/tests/integration/TaskTest.php b/tests/integration/TaskTest.php index 20da12bd..6d500da4 100644 --- a/tests/integration/TaskTest.php +++ b/tests/integration/TaskTest.php @@ -55,4 +55,42 @@ class TaskTest extends Base $task = $this->app->getTask($task_id); $this->assertEquals(0, $task['owner_id']); } + + public function testMoveTaskToAnotherProject() + { + $project_id1 = $this->app->createProject('My project'); + $this->assertNotFalse($project_id1); + + $project_id2 = $this->app->createProject('My project'); + $this->assertNotFalse($project_id2); + + $task_id = $this->app->createTask(array('project_id' => $project_id1, 'title' => 'My task')); + $this->assertNotFalse($task_id); + + $this->assertTrue($this->app->moveTaskToProject($task_id, $project_id2)); + + $task = $this->app->getTask($task_id); + $this->assertEquals($project_id2, $task['project_id']); + } + + public function testMoveCopyToAnotherProject() + { + $project_id1 = $this->app->createProject('My project'); + $this->assertNotFalse($project_id1); + + $project_id2 = $this->app->createProject('My project'); + $this->assertNotFalse($project_id2); + + $task_id1 = $this->app->createTask(array('project_id' => $project_id1, 'title' => 'My task')); + $this->assertNotFalse($task_id1); + + $task_id2 = $this->app->duplicateTaskToProject($task_id1, $project_id2); + $this->assertNotFalse($task_id2); + + $task = $this->app->getTask($task_id1); + $this->assertEquals($project_id1, $task['project_id']); + + $task = $this->app->getTask($task_id2); + $this->assertEquals($project_id2, $task['project_id']); + } } |