Add settings field to control project columns (pull-request #244)
This commit is contained in:
@@ -118,6 +118,7 @@ Contributors:
|
|||||||
- Kiswa: https://github.com/kiswa
|
- Kiswa: https://github.com/kiswa
|
||||||
- Kralo: https://github.com/kralo
|
- Kralo: https://github.com/kralo
|
||||||
- Levlaz: https://github.com/levlaz
|
- Levlaz: https://github.com/levlaz
|
||||||
|
- Lim Yuen Hoe: https://github.com/jasonmoofang
|
||||||
- Mathgl67: https://github.com/mathgl67
|
- Mathgl67: https://github.com/mathgl67
|
||||||
- Matthieu Keller: https://github.com/maggick
|
- Matthieu Keller: https://github.com/maggick
|
||||||
- Mauro Mariño: https://github.com/moromarino
|
- Mauro Mariño: https://github.com/moromarino
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ class Config extends Base
|
|||||||
'menu' => 'config',
|
'menu' => 'config',
|
||||||
'title' => t('Settings'),
|
'title' => t('Settings'),
|
||||||
'timezones' => $this->config->getTimezones(),
|
'timezones' => $this->config->getTimezones(),
|
||||||
|
'default_columns' => implode(', ', $this->board->getDefaultColumns()),
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,6 +59,7 @@ class Config extends Base
|
|||||||
'menu' => 'config',
|
'menu' => 'config',
|
||||||
'title' => t('Settings'),
|
'title' => t('Settings'),
|
||||||
'timezones' => $this->config->getTimezones(),
|
'timezones' => $this->config->getTimezones(),
|
||||||
|
'default_columns' => implode(', ', $this->board->getDefaultColumns()),
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -494,4 +494,6 @@ return array(
|
|||||||
// '%s moved the task #%d to the column "%s"' => '',
|
// '%s moved the task #%d to the column "%s"' => '',
|
||||||
// '%s moved the task #%d to the position %d in the column "%s"' => '',
|
// '%s moved the task #%d to the position %d in the column "%s"' => '',
|
||||||
// 'Activity' => '',
|
// 'Activity' => '',
|
||||||
|
// 'Default values are "%s"' => '',
|
||||||
|
// 'Default columns for new projects (Comma-separated)' => '',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -494,4 +494,6 @@ return array(
|
|||||||
// '%s moved the task #%d to the column "%s"' => '',
|
// '%s moved the task #%d to the column "%s"' => '',
|
||||||
// '%s moved the task #%d to the position %d in the column "%s"' => '',
|
// '%s moved the task #%d to the position %d in the column "%s"' => '',
|
||||||
// 'Activity' => '',
|
// 'Activity' => '',
|
||||||
|
// 'Default values are "%s"' => '',
|
||||||
|
// 'Default columns for new projects (Comma-separated)' => '',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -494,4 +494,6 @@ return array(
|
|||||||
// '%s moved the task #%d to the column "%s"' => '',
|
// '%s moved the task #%d to the column "%s"' => '',
|
||||||
// '%s moved the task #%d to the position %d in the column "%s"' => '',
|
// '%s moved the task #%d to the position %d in the column "%s"' => '',
|
||||||
// 'Activity' => '',
|
// 'Activity' => '',
|
||||||
|
// 'Default values are "%s"' => '',
|
||||||
|
// 'Default columns for new projects (Comma-separated)' => '',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -494,4 +494,6 @@ return array(
|
|||||||
'%s moved the task #%d to the column "%s"' => '%s a déplacé la tâche n°%d dans la colonne « %s »',
|
'%s moved the task #%d to the column "%s"' => '%s a déplacé la tâche n°%d dans la colonne « %s »',
|
||||||
'%s moved the task #%d to the position %d in the column "%s"' => '%s a déplacé la tâche n°%d à la position n°%d dans la colonne « %s »',
|
'%s moved the task #%d to the position %d in the column "%s"' => '%s a déplacé la tâche n°%d à la position n°%d dans la colonne « %s »',
|
||||||
'Activity' => 'Activité',
|
'Activity' => 'Activité',
|
||||||
|
'Default values are "%s"' => 'Les valeurs par défaut sont « %s »',
|
||||||
|
'Default columns for new projects (Comma-separated)' => 'Colonnes par défaut pour les nouveaux projets (séparé par des virgules)',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -494,4 +494,6 @@ return array(
|
|||||||
// '%s moved the task #%d to the column "%s"' => '',
|
// '%s moved the task #%d to the column "%s"' => '',
|
||||||
// '%s moved the task #%d to the position %d in the column "%s"' => '',
|
// '%s moved the task #%d to the position %d in the column "%s"' => '',
|
||||||
// 'Activity' => '',
|
// 'Activity' => '',
|
||||||
|
// 'Default values are "%s"' => '',
|
||||||
|
// 'Default columns for new projects (Comma-separated)' => '',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -494,4 +494,6 @@ return array(
|
|||||||
// '%s moved the task #%d to the column "%s"' => '',
|
// '%s moved the task #%d to the column "%s"' => '',
|
||||||
// '%s moved the task #%d to the position %d in the column "%s"' => '',
|
// '%s moved the task #%d to the position %d in the column "%s"' => '',
|
||||||
// 'Activity' => '',
|
// 'Activity' => '',
|
||||||
|
// 'Default values are "%s"' => '',
|
||||||
|
// 'Default columns for new projects (Comma-separated)' => '',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -494,4 +494,6 @@ return array(
|
|||||||
// '%s moved the task #%d to the column "%s"' => '',
|
// '%s moved the task #%d to the column "%s"' => '',
|
||||||
// '%s moved the task #%d to the position %d in the column "%s"' => '',
|
// '%s moved the task #%d to the position %d in the column "%s"' => '',
|
||||||
// 'Activity' => '',
|
// 'Activity' => '',
|
||||||
|
// 'Default values are "%s"' => '',
|
||||||
|
// 'Default columns for new projects (Comma-separated)' => '',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -494,4 +494,6 @@ return array(
|
|||||||
// '%s moved the task #%d to the column "%s"' => '',
|
// '%s moved the task #%d to the column "%s"' => '',
|
||||||
// '%s moved the task #%d to the position %d in the column "%s"' => '',
|
// '%s moved the task #%d to the position %d in the column "%s"' => '',
|
||||||
// 'Activity' => '',
|
// 'Activity' => '',
|
||||||
|
// 'Default values are "%s"' => '',
|
||||||
|
// 'Default columns for new projects (Comma-separated)' => '',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -494,4 +494,6 @@ return array(
|
|||||||
// '%s moved the task #%d to the column "%s"' => '',
|
// '%s moved the task #%d to the column "%s"' => '',
|
||||||
// '%s moved the task #%d to the position %d in the column "%s"' => '',
|
// '%s moved the task #%d to the position %d in the column "%s"' => '',
|
||||||
// 'Activity' => '',
|
// 'Activity' => '',
|
||||||
|
// 'Default values are "%s"' => '',
|
||||||
|
// 'Default columns for new projects (Comma-separated)' => '',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -494,4 +494,6 @@ return array(
|
|||||||
// '%s moved the task #%d to the column "%s"' => '',
|
// '%s moved the task #%d to the column "%s"' => '',
|
||||||
// '%s moved the task #%d to the position %d in the column "%s"' => '',
|
// '%s moved the task #%d to the position %d in the column "%s"' => '',
|
||||||
// 'Activity' => '',
|
// 'Activity' => '',
|
||||||
|
// 'Default values are "%s"' => '',
|
||||||
|
// 'Default columns for new projects (Comma-separated)' => '',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -20,6 +20,17 @@ class Board extends Base
|
|||||||
*/
|
*/
|
||||||
const TABLE = 'columns';
|
const TABLE = 'columns';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Kanboard default columns
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getDefaultColumns()
|
||||||
|
{
|
||||||
|
return array(t('Backlog'), t('Ready'), t('Work in progress'), t('Done'));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a board with default columns, must be executed inside a transaction
|
* Create a board with default columns, must be executed inside a transaction
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ class Config extends Base
|
|||||||
$_SESSION['config'] = $this->getAll();
|
$_SESSION['config'] = $this->getAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_SESSION['config'][$name])) {
|
if (! empty($_SESSION['config'][$name])) {
|
||||||
return $_SESSION['config'][$name];
|
return $_SESSION['config'][$name];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -496,14 +496,19 @@ class Project extends Base
|
|||||||
}
|
}
|
||||||
|
|
||||||
$project_id = $this->db->getConnection()->getLastId();
|
$project_id = $this->db->getConnection()->getLastId();
|
||||||
|
$column_names = explode(',', $this->config->get('default_columns', implode(',', $this->board->getDefaultColumns())));
|
||||||
|
$columns = array();
|
||||||
|
|
||||||
$this->board->create($project_id, array(
|
foreach ($column_names as $column_name) {
|
||||||
array('title' => t('Backlog'), 'task_limit' => 0),
|
|
||||||
array('title' => t('Ready'), 'task_limit' => 0),
|
|
||||||
array('title' => t('Work in progress'), 'task_limit' => 0),
|
|
||||||
array('title' => t('Done'), 'task_limit' => 0),
|
|
||||||
));
|
|
||||||
|
|
||||||
|
$column_name = trim($column_name);
|
||||||
|
|
||||||
|
if (! empty($column_name)) {
|
||||||
|
$columns[] = array('title' => $column_name, 'task_limit' => 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->board->create($project_id, $columns);
|
||||||
$this->db->closeTransaction();
|
$this->db->closeTransaction();
|
||||||
|
|
||||||
return (int) $project_id;
|
return (int) $project_id;
|
||||||
|
|||||||
@@ -4,7 +4,12 @@ namespace Schema;
|
|||||||
|
|
||||||
use Core\Security;
|
use Core\Security;
|
||||||
|
|
||||||
const VERSION = 25;
|
const VERSION = 26;
|
||||||
|
|
||||||
|
function version_26($pdo)
|
||||||
|
{
|
||||||
|
$pdo->exec("ALTER TABLE config ADD COLUMN default_columns VARCHAR(255) DEFAULT ''");
|
||||||
|
}
|
||||||
|
|
||||||
function version_25($pdo)
|
function version_25($pdo)
|
||||||
{
|
{
|
||||||
@@ -100,7 +105,8 @@ function version_20($pdo)
|
|||||||
|
|
||||||
function version_19($pdo)
|
function version_19($pdo)
|
||||||
{
|
{
|
||||||
$pdo->exec("ALTER TABLE config ADD COLUMN api_token VARCHAR(255) DEFAULT '".Security::generateToken()."'");
|
$pdo->exec("ALTER TABLE config ADD COLUMN api_token VARCHAR(255) DEFAULT ''");
|
||||||
|
$pdo->exec("UPDATE config SET api_token='".Security::generateToken()."'");
|
||||||
}
|
}
|
||||||
|
|
||||||
function version_18($pdo)
|
function version_18($pdo)
|
||||||
@@ -205,7 +211,7 @@ function version_1($pdo)
|
|||||||
$pdo->exec("
|
$pdo->exec("
|
||||||
CREATE TABLE config (
|
CREATE TABLE config (
|
||||||
language CHAR(5) DEFAULT 'en_US',
|
language CHAR(5) DEFAULT 'en_US',
|
||||||
webhooks_token VARCHAR(255),
|
webhooks_token VARCHAR(255) DEFAULT '',
|
||||||
timezone VARCHAR(50) DEFAULT 'UTC'
|
timezone VARCHAR(50) DEFAULT 'UTC'
|
||||||
) ENGINE=InnoDB CHARSET=utf8
|
) ENGINE=InnoDB CHARSET=utf8
|
||||||
");
|
");
|
||||||
|
|||||||
@@ -4,7 +4,12 @@ namespace Schema;
|
|||||||
|
|
||||||
use Core\Security;
|
use Core\Security;
|
||||||
|
|
||||||
const VERSION = 6;
|
const VERSION = 7;
|
||||||
|
|
||||||
|
function version_7($pdo)
|
||||||
|
{
|
||||||
|
$pdo->exec("ALTER TABLE config ADD COLUMN default_columns VARCHAR(255) DEFAULT ''");
|
||||||
|
}
|
||||||
|
|
||||||
function version_6($pdo)
|
function version_6($pdo)
|
||||||
{
|
{
|
||||||
@@ -95,9 +100,9 @@ function version_1($pdo)
|
|||||||
$pdo->exec("
|
$pdo->exec("
|
||||||
CREATE TABLE config (
|
CREATE TABLE config (
|
||||||
language CHAR(5) DEFAULT 'en_US',
|
language CHAR(5) DEFAULT 'en_US',
|
||||||
webhooks_token VARCHAR(255),
|
webhooks_token VARCHAR(255) DEFAULT '',
|
||||||
timezone VARCHAR(50) DEFAULT 'UTC',
|
timezone VARCHAR(50) DEFAULT 'UTC',
|
||||||
api_token VARCHAR(255)
|
api_token VARCHAR(255) DEFAULT ''
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE users (
|
CREATE TABLE users (
|
||||||
|
|||||||
@@ -4,7 +4,12 @@ namespace Schema;
|
|||||||
|
|
||||||
use Core\Security;
|
use Core\Security;
|
||||||
|
|
||||||
const VERSION = 25;
|
const VERSION = 26;
|
||||||
|
|
||||||
|
function version_26($pdo)
|
||||||
|
{
|
||||||
|
$pdo->exec("ALTER TABLE config ADD COLUMN default_columns TEXT DEFAULT ''");
|
||||||
|
}
|
||||||
|
|
||||||
function version_25($pdo)
|
function version_25($pdo)
|
||||||
{
|
{
|
||||||
@@ -97,7 +102,8 @@ function version_20($pdo)
|
|||||||
|
|
||||||
function version_19($pdo)
|
function version_19($pdo)
|
||||||
{
|
{
|
||||||
$pdo->exec("ALTER TABLE config ADD COLUMN api_token TEXT DEFAULT '".Security::generateToken()."'");
|
$pdo->exec("ALTER TABLE config ADD COLUMN api_token TEXT DEFAULT ''");
|
||||||
|
$pdo->exec("UPDATE config SET api_token='".Security::generateToken()."'");
|
||||||
}
|
}
|
||||||
|
|
||||||
function version_18($pdo)
|
function version_18($pdo)
|
||||||
@@ -307,8 +313,8 @@ function version_1($pdo)
|
|||||||
{
|
{
|
||||||
$pdo->exec("
|
$pdo->exec("
|
||||||
CREATE TABLE config (
|
CREATE TABLE config (
|
||||||
language TEXT,
|
language TEXT DEFAULT 'en_US',
|
||||||
webhooks_token TEXT
|
webhooks_token TEXT DEFAULT ''
|
||||||
)
|
)
|
||||||
");
|
");
|
||||||
|
|
||||||
@@ -366,7 +372,7 @@ function version_1($pdo)
|
|||||||
|
|
||||||
$pdo->exec("
|
$pdo->exec("
|
||||||
INSERT INTO config
|
INSERT INTO config
|
||||||
(language, webhooks_token)
|
(webhooks_token)
|
||||||
VALUES ('en_US', '".Security::generateToken()."')
|
VALUES ('".Security::generateToken()."')
|
||||||
");
|
");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,10 @@
|
|||||||
<?= Helper\form_label(t('Webhook URL for task modification'), 'webhooks_url_task_modification') ?>
|
<?= Helper\form_label(t('Webhook URL for task modification'), 'webhooks_url_task_modification') ?>
|
||||||
<?= Helper\form_text('webhooks_url_task_modification', $values, $errors) ?><br/>
|
<?= Helper\form_text('webhooks_url_task_modification', $values, $errors) ?><br/>
|
||||||
|
|
||||||
|
<?= Helper\form_label(t('Default columns for new projects (Comma-separated)'), 'default_columns') ?>
|
||||||
|
<?= Helper\form_text('default_columns', $values, $errors) ?><br/>
|
||||||
|
<p class="form-help"><?= t('Default values are "%s"', $default_columns) ?></p>
|
||||||
|
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<input type="submit" value="<?= t('Save') ?>" class="btn btn-blue"/>
|
<input type="submit" value="<?= t('Save') ?>" class="btn btn-blue"/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ require_once __DIR__.'/../../app/translator.php';
|
|||||||
require_once __DIR__.'/../../app/helpers.php';
|
require_once __DIR__.'/../../app/helpers.php';
|
||||||
|
|
||||||
require_once __DIR__.'/../../app/Model/Base.php';
|
require_once __DIR__.'/../../app/Model/Base.php';
|
||||||
|
require_once __DIR__.'/../../app/Model/Config.php';
|
||||||
require_once __DIR__.'/../../app/Model/Task.php';
|
require_once __DIR__.'/../../app/Model/Task.php';
|
||||||
require_once __DIR__.'/../../app/Model/Acl.php';
|
require_once __DIR__.'/../../app/Model/Acl.php';
|
||||||
require_once __DIR__.'/../../app/Model/Comment.php';
|
require_once __DIR__.'/../../app/Model/Comment.php';
|
||||||
|
|||||||
@@ -4,9 +4,41 @@ require_once __DIR__.'/Base.php';
|
|||||||
|
|
||||||
use Model\Project;
|
use Model\Project;
|
||||||
use Model\Board;
|
use Model\Board;
|
||||||
|
use Model\Config;
|
||||||
|
|
||||||
class BoardTest extends Base
|
class BoardTest extends Base
|
||||||
{
|
{
|
||||||
|
public function testCreation()
|
||||||
|
{
|
||||||
|
$p = new Project($this->registry);
|
||||||
|
$b = new Board($this->registry);
|
||||||
|
$c = new Config($this->registry);
|
||||||
|
|
||||||
|
// Default columns
|
||||||
|
|
||||||
|
$this->assertEquals(1, $p->create(array('name' => 'UnitTest1')));
|
||||||
|
$columns = $b->getColumnsList(1);
|
||||||
|
|
||||||
|
$this->assertTrue(is_array($columns));
|
||||||
|
$this->assertEquals(4, count($columns));
|
||||||
|
$this->assertEquals('Backlog', $columns[1]);
|
||||||
|
$this->assertEquals('Ready', $columns[2]);
|
||||||
|
$this->assertEquals('Work in progress', $columns[3]);
|
||||||
|
$this->assertEquals('Done', $columns[4]);
|
||||||
|
|
||||||
|
// Custom columns: spaces should be trimed and no empty columns
|
||||||
|
|
||||||
|
$this->assertTrue($c->save(array('default_columns' => ' column #1 , column #2, ')));
|
||||||
|
|
||||||
|
$this->assertEquals(2, $p->create(array('name' => 'UnitTest2')));
|
||||||
|
$columns = $b->getColumnsList(2);
|
||||||
|
|
||||||
|
$this->assertTrue(is_array($columns));
|
||||||
|
$this->assertEquals(2, count($columns));
|
||||||
|
$this->assertEquals('column #1', $columns[5]);
|
||||||
|
$this->assertEquals('column #2', $columns[6]);
|
||||||
|
}
|
||||||
|
|
||||||
public function testMoveColumns()
|
public function testMoveColumns()
|
||||||
{
|
{
|
||||||
$p = new Project($this->registry);
|
$p = new Project($this->registry);
|
||||||
|
|||||||
32
tests/units/ConfigTest.php
Normal file
32
tests/units/ConfigTest.php
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once __DIR__.'/Base.php';
|
||||||
|
|
||||||
|
use Model\Config;
|
||||||
|
|
||||||
|
class ConfigTest extends Base
|
||||||
|
{
|
||||||
|
public function testDefaultValues()
|
||||||
|
{
|
||||||
|
$c = new Config($this->registry);
|
||||||
|
|
||||||
|
$this->assertEquals('en_US', $c->get('language'));
|
||||||
|
$this->assertEquals('UTC', $c->get('timezone'));
|
||||||
|
|
||||||
|
$this->assertEmpty($c->get('webhooks_url_task_modification'));
|
||||||
|
$this->assertEmpty($c->get('webhooks_url_task_creation'));
|
||||||
|
$this->assertEmpty($c->get('default_columns'));
|
||||||
|
|
||||||
|
$this->assertNotEmpty($c->get('webhooks_token'));
|
||||||
|
$this->assertNotEmpty($c->get('api_token'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGet()
|
||||||
|
{
|
||||||
|
$c = new Config($this->registry);
|
||||||
|
|
||||||
|
$this->assertEquals('', $c->get('default_columns'));
|
||||||
|
$this->assertEquals('test', $c->get('default_columns', 'test'));
|
||||||
|
$this->assertEquals(0, $c->get('default_columns', 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user