summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2014-09-09 07:13:48 +0200
committerFrédéric Guillot <fred@kanboard.net>2014-09-09 07:13:48 +0200
commit0d4b6525dd86f837eb9e931e48a92fc6a0033e11 (patch)
treec876d0bdcb8f36b47442d020ea0e1572e21b7b3c
parente383c069f1aeba49ea9905f77a51bf663e614b0e (diff)
The color is not mandatory for task creation through the API
-rw-r--r--app/Controller/Task.php2
-rw-r--r--app/Model/Task.php6
-rw-r--r--jsonrpc.php2
-rw-r--r--tests/units/TaskTest.php1
4 files changed, 8 insertions, 3 deletions
diff --git a/app/Controller/Task.php b/app/Controller/Task.php
index 97751947..b0bb9d5b 100644
--- a/app/Controller/Task.php
+++ b/app/Controller/Task.php
@@ -30,7 +30,7 @@ class Task extends Base
$values = array(
'title' => $this->request->getStringParam('title'),
'description' => $this->request->getStringParam('description'),
- 'color_id' => $this->request->getStringParam('color_id', 'blue'),
+ 'color_id' => $this->request->getStringParam('color_id'),
'project_id' => $this->request->getIntegerParam('project_id', $defaultProject['id']),
'owner_id' => $this->request->getIntegerParam('owner_id'),
'column_id' => $this->request->getIntegerParam('column_id'),
diff --git a/app/Model/Task.php b/app/Model/Task.php
index 09333008..e35bd383 100644
--- a/app/Model/Task.php
+++ b/app/Model/Task.php
@@ -400,6 +400,11 @@ class Task extends Base
$values['column_id'] = $this->board->getFirstColumn($values['project_id']);
}
+ if (empty($values['color_id'])) {
+ $colors = $this->getColors();
+ $values['color_id'] = key($colors);
+ }
+
$values['date_creation'] = time();
$values['date_modification'] = $values['date_creation'];
$values['position'] = $this->countByColumnId($values['project_id'], $values['column_id']) + 1;
@@ -677,7 +682,6 @@ class Task extends Base
public function validateCreation(array $values)
{
$v = new Validator($values, array(
- new Validators\Required('color_id', t('The color is required')),
new Validators\Required('project_id', t('The project is required')),
new Validators\Integer('project_id', t('This value must be an integer')),
new Validators\Integer('column_id', t('This value must be an integer')),
diff --git a/jsonrpc.php b/jsonrpc.php
index e4e2a778..4bb1ffa8 100644
--- a/jsonrpc.php
+++ b/jsonrpc.php
@@ -116,7 +116,7 @@ $server->register('allowUser', function($project_id, $user_id) use ($project) {
/**
* Task procedures
*/
-$server->register('createTask', function($title, $project_id, $color_id, $column_id, $owner_id = 0, $creator_id = 0, $date_due = '', $description = '', $category_id = 0, $score = 0) use ($task) {
+$server->register('createTask', function($title, $project_id, $color_id = '', $column_id = 0, $owner_id = 0, $creator_id = 0, $date_due = '', $description = '', $category_id = 0, $score = 0) use ($task) {
$values = array(
'title' => $title,
diff --git a/tests/units/TaskTest.php b/tests/units/TaskTest.php
index 1269352e..3d1a5e49 100644
--- a/tests/units/TaskTest.php
+++ b/tests/units/TaskTest.php
@@ -21,6 +21,7 @@ class TaskTest extends Base
$this->assertEquals(1, $task['id']);
$this->assertEquals(1, $task['column_id']);
$this->assertEquals(1, $task['position']);
+ $this->assertEquals('yellow', $task['color_id']);
$this->assertEquals(time(), $task['date_creation']);
$this->assertEquals(time(), $task['date_modification']);