Add settings option to define the default task color

This commit is contained in:
Frederic Guillot 2015-07-19 14:14:05 -04:00
parent 9eeb7d1820
commit d1bfc29f1b
25 changed files with 65 additions and 5 deletions

View File

@ -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'),
)));

View File

@ -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'),
);

View File

@ -998,4 +998,5 @@ return array(
// 'Gitlab issue comment created' => '',
// 'New remote user' => '',
// 'New local user' => '',
// 'Default task color' => '',
);

View File

@ -998,4 +998,5 @@ return array(
// 'Gitlab issue comment created' => '',
// 'New remote user' => '',
// 'New local user' => '',
// 'Default task color' => '',
);

View File

@ -998,4 +998,5 @@ return array(
// 'Gitlab issue comment created' => '',
// 'New remote user' => '',
// 'New local user' => '',
// 'Default task color' => '',
);

View File

@ -998,4 +998,5 @@ return array(
// 'Gitlab issue comment created' => '',
// 'New remote user' => '',
// 'New local user' => '',
// 'Default task color' => '',
);

View File

@ -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',
);

View File

@ -998,4 +998,5 @@ return array(
// 'Gitlab issue comment created' => '',
// 'New remote user' => '',
// 'New local user' => '',
// 'Default task color' => '',
);

View File

@ -998,4 +998,5 @@ return array(
// 'Gitlab issue comment created' => '',
// 'New remote user' => '',
// 'New local user' => '',
// 'Default task color' => '',
);

View File

@ -998,4 +998,5 @@ return array(
// 'Gitlab issue comment created' => '',
// 'New remote user' => '',
// 'New local user' => '',
// 'Default task color' => '',
);

View File

@ -998,4 +998,5 @@ return array(
// 'Gitlab issue comment created' => '',
// 'New remote user' => '',
// 'New local user' => '',
// 'Default task color' => '',
);

View File

@ -998,4 +998,5 @@ return array(
// 'Gitlab issue comment created' => '',
// 'New remote user' => '',
// 'New local user' => '',
// 'Default task color' => '',
);

View File

@ -998,4 +998,5 @@ return array(
// 'Gitlab issue comment created' => '',
// 'New remote user' => '',
// 'New local user' => '',
// 'Default task color' => '',
);

View File

@ -998,4 +998,5 @@ return array(
// 'Gitlab issue comment created' => '',
// 'New remote user' => '',
// 'New local user' => '',
// 'Default task color' => '',
);

View File

@ -998,4 +998,5 @@ return array(
// 'Gitlab issue comment created' => '',
// 'New remote user' => '',
// 'New local user' => '',
// 'Default task color' => '',
);

View File

@ -998,4 +998,5 @@ return array(
// 'Gitlab issue comment created' => '',
// 'New remote user' => '',
// 'New local user' => '',
// 'Default task color' => '',
);

View File

@ -998,4 +998,5 @@ return array(
// 'Gitlab issue comment created' => '',
// 'New remote user' => '',
// 'New local user' => '',
// 'Default task color' => '',
);

View File

@ -998,4 +998,5 @@ return array(
// 'Gitlab issue comment created' => '',
// 'New remote user' => '',
// 'New local user' => '',
// 'Default task color' => '',
);

View File

@ -998,4 +998,5 @@ return array(
// 'Gitlab issue comment created' => '',
// 'New remote user' => '',
// 'New local user' => '',
// 'Default task color' => '',
);

View File

@ -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');
}
/**

View File

@ -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)
{

View File

@ -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)
{

View File

@ -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)
{

View File

@ -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) ?><br/>
<p class="form-help"><?= t('Default values are "%s"', $default_columns) ?></p>

View File

@ -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']);
}
}