Add tags parameter to task API calls

This commit is contained in:
Frederic Guillot 2016-12-18 18:19:25 -05:00
parent bc5641da8b
commit 2decbe28b5
3 changed files with 47 additions and 16 deletions

View File

@ -87,9 +87,9 @@ class TaskProcedure extends BaseProcedure
}
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, $priority = 0,
$recurrence_status = 0, $recurrence_trigger = 0, $recurrence_factor = 0, $recurrence_timeframe = 0,
$recurrence_basedate = 0, $reference = '')
$date_due = '', $description = '', $category_id = 0, $score = 0, $swimlane_id = 0, $priority = 0,
$recurrence_status = 0, $recurrence_trigger = 0, $recurrence_factor = 0, $recurrence_timeframe = 0,
$recurrence_basedate = 0, $reference = '', array $tags = array())
{
ProjectAuthorization::getInstance($this->container)->check($this->getClassName(), 'createTask', $project_id);
@ -120,6 +120,7 @@ class TaskProcedure extends BaseProcedure
'recurrence_basedate' => $recurrence_basedate,
'reference' => $reference,
'priority' => $priority,
'tags' => $tags,
);
list($valid, ) = $this->taskValidator->validateCreation($values);
@ -128,9 +129,9 @@ class TaskProcedure extends BaseProcedure
}
public function updateTask($id, $title = null, $color_id = null, $owner_id = null,
$date_due = null, $description = null, $category_id = null, $score = null, $priority = null,
$recurrence_status = null, $recurrence_trigger = null, $recurrence_factor = null,
$recurrence_timeframe = null, $recurrence_basedate = null, $reference = null)
$date_due = null, $description = null, $category_id = null, $score = null, $priority = null,
$recurrence_status = null, $recurrence_trigger = null, $recurrence_factor = null,
$recurrence_timeframe = null, $recurrence_basedate = null, $reference = null, $tags = null)
{
TaskAuthorization::getInstance($this->container)->check($this->getClassName(), 'updateTask', $id);
$project_id = $this->taskFinderModel->getProjectId($id);
@ -159,6 +160,7 @@ class TaskProcedure extends BaseProcedure
'recurrence_basedate' => $recurrence_basedate,
'reference' => $reference,
'priority' => $priority,
'tags' => $tags,
));
list($valid) = $this->taskValidator->validateApiModification($values);

View File

@ -17,11 +17,12 @@ API Task Procedures
- **score** (integer, optional)
- **swimlane_id** (integer, optional)
- **priority** (integer, optional)
- **recurrence_status** (integer, optional)
- **recurrence_trigger** (integer, optional)
- **recurrence_factor** (integer, optional)
- **recurrence_timeframe** (integer, optional)
- **recurrence_basedate** (integer, optional)
- **recurrence_status** (integer, optional)
- **recurrence_trigger** (integer, optional)
- **recurrence_factor** (integer, optional)
- **recurrence_timeframe** (integer, optional)
- **recurrence_basedate** (integer, optional)
- **tags** ([]string, optional)
- Result on success: **task_id**
- Result on failure: **false**
@ -400,11 +401,12 @@ Response example:
- **category_id** (integer, optional)
- **score** (integer, optional)
- **priority** (integer, optional)
- **recurrence_status** (integer, optional)
- **recurrence_trigger** (integer, optional)
- **recurrence_factor** (integer, optional)
- **recurrence_timeframe** (integer, optional)
- **recurrence_basedate** (integer, optional)
- **recurrence_status** (integer, optional)
- **recurrence_trigger** (integer, optional)
- **recurrence_factor** (integer, optional)
- **recurrence_timeframe** (integer, optional)
- **recurrence_basedate** (integer, optional)
- **tags** ([]string, optional)
- Result on success: **true**
- Result on failure: **false**

View File

@ -12,6 +12,8 @@ class TaskTagProcedureTest extends BaseProcedureTest
$this->assertCreateTask();
$this->assertSetTaskTags();
$this->assertGetTaskTags();
$this->assertCreateTaskWithTags();
$this->assertUpdateTaskWithTags();
}
public function assertSetTaskTags()
@ -24,4 +26,29 @@ class TaskTagProcedureTest extends BaseProcedureTest
$tags = $this->app->getTaskTags($this->taskId);
$this->assertEquals(array('tag1', 'tag2'), array_values($tags));
}
public function assertCreateTaskWithTags()
{
$this->taskId = $this->app->createTask(array(
'title' => $this->taskTitle,
'project_id' => $this->projectId,
'tags' => array('tag A', 'tag B'),
));
$this->assertNotFalse($this->taskId);
$tags = $this->app->getTaskTags($this->taskId);
$this->assertEquals(array('tag A', 'tag B'), array_values($tags));
}
public function assertUpdateTaskWithTags()
{
$this->assertTrue($this->app->updateTask(array(
'id' => $this->taskId,
'tags' => array('tag C'),
)));
$tags = $this->app->getTaskTags($this->taskId);
$this->assertEquals(array('tag C'), array_values($tags));
}
}