diff --git a/app/Controller/Config.php b/app/Controller/Config.php
index 1e6b3dc8f..206237c0f 100644
--- a/app/Controller/Config.php
+++ b/app/Controller/Config.php
@@ -104,6 +104,7 @@ class Config extends Base
$this->common('project');
$this->response->html($this->layout('config/project', array(
+ 'colors' => $this->color->getList(),
'default_columns' => implode(', ', $this->board->getDefaultColumns()),
'title' => t('Settings').' > '.t('Project settings'),
)));
diff --git a/app/Controller/Task.php b/app/Controller/Task.php
index db12a0c76..6e525b136 100644
--- a/app/Controller/Task.php
+++ b/app/Controller/Task.php
@@ -122,7 +122,7 @@ class Task extends Base
$values = array(
'swimlane_id' => $this->request->getIntegerParam('swimlane_id', key($swimlanes_list)),
'column_id' => $this->request->getIntegerParam('column_id'),
- 'color_id' => $this->request->getStringParam('color_id'),
+ 'color_id' => $this->request->getStringParam('color_id', $this->color->getDefaultColor()),
'owner_id' => $this->request->getIntegerParam('owner_id'),
'another_task' => $this->request->getIntegerParam('another_task'),
);
diff --git a/app/Locale/da_DK/translations.php b/app/Locale/da_DK/translations.php
index 5f55f3e86..a85ef96c2 100644
--- a/app/Locale/da_DK/translations.php
+++ b/app/Locale/da_DK/translations.php
@@ -998,4 +998,5 @@ return array(
// 'Gitlab issue comment created' => '',
// 'New remote user' => '',
// 'New local user' => '',
+ // 'Default task color' => '',
);
diff --git a/app/Locale/de_DE/translations.php b/app/Locale/de_DE/translations.php
index 90c029ba4..cb6cc8e3f 100644
--- a/app/Locale/de_DE/translations.php
+++ b/app/Locale/de_DE/translations.php
@@ -998,4 +998,5 @@ return array(
// 'Gitlab issue comment created' => '',
// 'New remote user' => '',
// 'New local user' => '',
+ // 'Default task color' => '',
);
diff --git a/app/Locale/es_ES/translations.php b/app/Locale/es_ES/translations.php
index 03661d75c..2f5e9b9a6 100644
--- a/app/Locale/es_ES/translations.php
+++ b/app/Locale/es_ES/translations.php
@@ -998,4 +998,5 @@ return array(
// 'Gitlab issue comment created' => '',
// 'New remote user' => '',
// 'New local user' => '',
+ // 'Default task color' => '',
);
diff --git a/app/Locale/fi_FI/translations.php b/app/Locale/fi_FI/translations.php
index ddbb26c35..ab857645b 100644
--- a/app/Locale/fi_FI/translations.php
+++ b/app/Locale/fi_FI/translations.php
@@ -998,4 +998,5 @@ return array(
// 'Gitlab issue comment created' => '',
// 'New remote user' => '',
// 'New local user' => '',
+ // 'Default task color' => '',
);
diff --git a/app/Locale/fr_FR/translations.php b/app/Locale/fr_FR/translations.php
index 1c4c76eef..db950a207 100644
--- a/app/Locale/fr_FR/translations.php
+++ b/app/Locale/fr_FR/translations.php
@@ -1000,4 +1000,5 @@ return array(
'Gitlab issue comment created' => 'Commentaire créé sur un ticket Gitlab',
'New remote user' => 'Créer un utilisateur distant',
'New local user' => 'Créer un utilisateur local',
+ 'Default task color' => 'Couleur par défaut des tâches',
);
diff --git a/app/Locale/hu_HU/translations.php b/app/Locale/hu_HU/translations.php
index f1bd1453f..ffc66324e 100644
--- a/app/Locale/hu_HU/translations.php
+++ b/app/Locale/hu_HU/translations.php
@@ -998,4 +998,5 @@ return array(
// 'Gitlab issue comment created' => '',
// 'New remote user' => '',
// 'New local user' => '',
+ // 'Default task color' => '',
);
diff --git a/app/Locale/it_IT/translations.php b/app/Locale/it_IT/translations.php
index 6dd60c183..b232bdcbf 100644
--- a/app/Locale/it_IT/translations.php
+++ b/app/Locale/it_IT/translations.php
@@ -998,4 +998,5 @@ return array(
// 'Gitlab issue comment created' => '',
// 'New remote user' => '',
// 'New local user' => '',
+ // 'Default task color' => '',
);
diff --git a/app/Locale/ja_JP/translations.php b/app/Locale/ja_JP/translations.php
index e52f82b67..89d317ed0 100644
--- a/app/Locale/ja_JP/translations.php
+++ b/app/Locale/ja_JP/translations.php
@@ -998,4 +998,5 @@ return array(
// 'Gitlab issue comment created' => '',
// 'New remote user' => '',
// 'New local user' => '',
+ // 'Default task color' => '',
);
diff --git a/app/Locale/nl_NL/translations.php b/app/Locale/nl_NL/translations.php
index ed8be05b5..bf43a9a72 100644
--- a/app/Locale/nl_NL/translations.php
+++ b/app/Locale/nl_NL/translations.php
@@ -998,4 +998,5 @@ return array(
// 'Gitlab issue comment created' => '',
// 'New remote user' => '',
// 'New local user' => '',
+ // 'Default task color' => '',
);
diff --git a/app/Locale/pl_PL/translations.php b/app/Locale/pl_PL/translations.php
index 9f8641a0f..6b4b411b1 100644
--- a/app/Locale/pl_PL/translations.php
+++ b/app/Locale/pl_PL/translations.php
@@ -998,4 +998,5 @@ return array(
// 'Gitlab issue comment created' => '',
// 'New remote user' => '',
// 'New local user' => '',
+ // 'Default task color' => '',
);
diff --git a/app/Locale/pt_BR/translations.php b/app/Locale/pt_BR/translations.php
index 68de0368d..ebe5466fc 100644
--- a/app/Locale/pt_BR/translations.php
+++ b/app/Locale/pt_BR/translations.php
@@ -998,4 +998,5 @@ return array(
// 'Gitlab issue comment created' => '',
// 'New remote user' => '',
// 'New local user' => '',
+ // 'Default task color' => '',
);
diff --git a/app/Locale/ru_RU/translations.php b/app/Locale/ru_RU/translations.php
index 3b7d678cc..75dd15c03 100644
--- a/app/Locale/ru_RU/translations.php
+++ b/app/Locale/ru_RU/translations.php
@@ -998,4 +998,5 @@ return array(
// 'Gitlab issue comment created' => '',
// 'New remote user' => '',
// 'New local user' => '',
+ // 'Default task color' => '',
);
diff --git a/app/Locale/sr_Latn_RS/translations.php b/app/Locale/sr_Latn_RS/translations.php
index f33693411..706efbb0a 100644
--- a/app/Locale/sr_Latn_RS/translations.php
+++ b/app/Locale/sr_Latn_RS/translations.php
@@ -998,4 +998,5 @@ return array(
// 'Gitlab issue comment created' => '',
// 'New remote user' => '',
// 'New local user' => '',
+ // 'Default task color' => '',
);
diff --git a/app/Locale/sv_SE/translations.php b/app/Locale/sv_SE/translations.php
index db552359b..a03aadfdf 100644
--- a/app/Locale/sv_SE/translations.php
+++ b/app/Locale/sv_SE/translations.php
@@ -998,4 +998,5 @@ return array(
// 'Gitlab issue comment created' => '',
// 'New remote user' => '',
// 'New local user' => '',
+ // 'Default task color' => '',
);
diff --git a/app/Locale/th_TH/translations.php b/app/Locale/th_TH/translations.php
index c4d608bdd..8c24aa65c 100644
--- a/app/Locale/th_TH/translations.php
+++ b/app/Locale/th_TH/translations.php
@@ -998,4 +998,5 @@ return array(
// 'Gitlab issue comment created' => '',
// 'New remote user' => '',
// 'New local user' => '',
+ // 'Default task color' => '',
);
diff --git a/app/Locale/tr_TR/translations.php b/app/Locale/tr_TR/translations.php
index afb887449..e9fb19cd3 100644
--- a/app/Locale/tr_TR/translations.php
+++ b/app/Locale/tr_TR/translations.php
@@ -998,4 +998,5 @@ return array(
// 'Gitlab issue comment created' => '',
// 'New remote user' => '',
// 'New local user' => '',
+ // 'Default task color' => '',
);
diff --git a/app/Locale/zh_CN/translations.php b/app/Locale/zh_CN/translations.php
index cd2518fd1..d1eec36f8 100644
--- a/app/Locale/zh_CN/translations.php
+++ b/app/Locale/zh_CN/translations.php
@@ -998,4 +998,5 @@ return array(
// 'Gitlab issue comment created' => '',
// 'New remote user' => '',
// 'New local user' => '',
+ // 'Default task color' => '',
);
diff --git a/app/Model/Color.php b/app/Model/Color.php
index 1fd81b85c..73e5d6294 100644
--- a/app/Model/Color.php
+++ b/app/Model/Color.php
@@ -147,7 +147,7 @@ class Color extends Base
*/
public function getDefaultColor()
{
- return 'yellow'; // TODO: make this parameter configurable
+ return $this->config->get('default_color', 'yellow');
}
/**
diff --git a/app/Schema/Mysql.php b/app/Schema/Mysql.php
index 769a7425c..c62f3a724 100644
--- a/app/Schema/Mysql.php
+++ b/app/Schema/Mysql.php
@@ -6,7 +6,12 @@ use PDO;
use Core\Security;
use Model\Link;
-const VERSION = 79;
+const VERSION = 80;
+
+function version_80($pdo)
+{
+ $pdo->exec("INSERT INTO settings VALUES ('default_color', 'yellow')");
+}
function version_79($pdo)
{
diff --git a/app/Schema/Postgres.php b/app/Schema/Postgres.php
index fca877666..b436db1b2 100644
--- a/app/Schema/Postgres.php
+++ b/app/Schema/Postgres.php
@@ -6,7 +6,12 @@ use PDO;
use Core\Security;
use Model\Link;
-const VERSION = 59;
+const VERSION = 60;
+
+function version_60($pdo)
+{
+ $pdo->exec("INSERT INTO settings VALUES ('default_color', 'yellow')");
+}
function version_59($pdo)
{
diff --git a/app/Schema/Sqlite.php b/app/Schema/Sqlite.php
index 9981e72fa..23097b551 100644
--- a/app/Schema/Sqlite.php
+++ b/app/Schema/Sqlite.php
@@ -6,7 +6,12 @@ use Core\Security;
use PDO;
use Model\Link;
-const VERSION = 75;
+const VERSION = 76;
+
+function version_76($pdo)
+{
+ $pdo->exec("INSERT INTO settings VALUES ('default_color', 'yellow')");
+}
function version_75($pdo)
{
diff --git a/app/Template/config/project.php b/app/Template/config/project.php
index 1ab69e264..b762de243 100644
--- a/app/Template/config/project.php
+++ b/app/Template/config/project.php
@@ -6,6 +6,9 @@
= $this->form->csrf() ?>
+ = $this->form->label(t('Default task color'), 'default_color') ?>
+ = $this->form->select('default_color', $colors, $values, $errors) ?>
+
= $this->form->label(t('Default columns for new projects (Comma-separated)'), 'board_columns') ?>
= $this->form->text('board_columns', $values, $errors) ?>
= t('Default values are "%s"', $default_columns) ?>
diff --git a/tests/units/TaskCreationTest.php b/tests/units/TaskCreationTest.php index 03a85b642..2dc67ad44 100644 --- a/tests/units/TaskCreationTest.php +++ b/tests/units/TaskCreationTest.php @@ -2,6 +2,7 @@ require_once __DIR__.'/Base.php'; +use Model\Config; use Model\Task; use Model\TaskCreation; use Model\TaskFinder; @@ -383,4 +384,27 @@ class TaskCreationTest extends Base $this->assertNotFalse($task); $this->assertEquals(3, $task['score']); } + + public function testDefaultColor() + { + $p = new Project($this->container); + $tc = new TaskCreation($this->container); + $tf = new TaskFinder($this->container); + $c = new Config($this->container); + + $this->assertEquals(1, $p->create(array('name' => 'test'))); + $this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test1'))); + + $task = $tf->getById(1); + $this->assertNotEmpty($task); + $this->assertEquals('yellow', $task['color_id']); + + $this->assertTrue($c->save(array('default_color' => 'orange'))); + + $this->assertEquals(2, $tc->create(array('project_id' => 1, 'title' => 'test2'))); + + $task = $tf->getById(2); + $this->assertNotEmpty($task); + $this->assertEquals('orange', $task['color_id']); + } }