summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorJulian Maurice <julian.maurice@biblibre.com>2018-08-09 21:35:11 +0200
committerJulian Maurice <julian.maurice@biblibre.com>2018-08-11 10:15:13 +0200
commit9d4cd31e1aae02e9980932c67036fdfe574e3432 (patch)
tree6fca71d93aaed9032a0d771a0b8111d79fdc99b6 /app
parentae3ade0908bae350488260ee5d878a2ffbff605a (diff)
Allow to associate tags to colors
The color is then used as background in the board, list and task details views
Diffstat (limited to 'app')
-rw-r--r--app/Controller/ProjectTagController.php6
-rw-r--r--app/Controller/TagController.php6
-rw-r--r--app/Controller/TaskViewController.php2
-rw-r--r--app/Model/ColorModel.php2
-rw-r--r--app/Model/TagModel.php6
-rw-r--r--app/Model/TaskTagModel.php4
-rw-r--r--app/Schema/Mysql.php7
-rw-r--r--app/Schema/Postgres.php7
-rw-r--r--app/Schema/Sql/mysql.sql1
-rw-r--r--app/Schema/Sql/postgres.sql3
-rw-r--r--app/Schema/Sqlite.php7
-rw-r--r--app/Template/board/task_footer.php2
-rw-r--r--app/Template/project_tag/create.php3
-rw-r--r--app/Template/project_tag/edit.php3
-rw-r--r--app/Template/tag/create.php3
-rw-r--r--app/Template/tag/edit.php3
-rw-r--r--app/Template/task/details.php2
-rw-r--r--app/Template/task_list/task_details.php2
18 files changed, 52 insertions, 17 deletions
diff --git a/app/Controller/ProjectTagController.php b/app/Controller/ProjectTagController.php
index c45e71e1..71985336 100644
--- a/app/Controller/ProjectTagController.php
+++ b/app/Controller/ProjectTagController.php
@@ -28,6 +28,7 @@ class ProjectTagController extends BaseController
$this->response->html($this->template->render('project_tag/create', array(
'project' => $project,
'values' => $values,
+ 'colors' => $this->colorModel->getList(),
'errors' => $errors,
)));
}
@@ -41,7 +42,7 @@ class ProjectTagController extends BaseController
list($valid, $errors) = $this->tagValidator->validateCreation($values);
if ($valid) {
- if ($this->tagModel->create($project['id'], $values['name']) > 0) {
+ if ($this->tagModel->create($project['id'], $values['name'], $values['color_id']) > 0) {
$this->flash->success(t('Tag created successfully.'));
} else {
$this->flash->failure(t('Unable to create this tag.'));
@@ -66,6 +67,7 @@ class ProjectTagController extends BaseController
'project' => $project,
'tag' => $tag,
'values' => $values,
+ 'colors' => $this->colorModel->getList(),
'errors' => $errors,
)));
}
@@ -81,7 +83,7 @@ class ProjectTagController extends BaseController
list($valid, $errors) = $this->tagValidator->validateModification($values);
if ($valid) {
- if ($this->tagModel->update($values['id'], $values['name'])) {
+ if ($this->tagModel->update($values['id'], $values['name'], $values['color_id'])) {
$this->flash->success(t('Tag updated successfully.'));
} else {
$this->flash->failure(t('Unable to update this tag.'));
diff --git a/app/Controller/TagController.php b/app/Controller/TagController.php
index b8389910..b550cf58 100644
--- a/app/Controller/TagController.php
+++ b/app/Controller/TagController.php
@@ -28,6 +28,7 @@ class TagController extends BaseController
$this->response->html($this->template->render('tag/create', array(
'values' => $values,
+ 'colors' => $this->colorModel->getList(),
'errors' => $errors,
)));
}
@@ -38,7 +39,7 @@ class TagController extends BaseController
list($valid, $errors) = $this->tagValidator->validateCreation($values);
if ($valid) {
- if ($this->tagModel->create(0, $values['name']) > 0) {
+ if ($this->tagModel->create(0, $values['name'], $values['color_id']) > 0) {
$this->flash->success(t('Tag created successfully.'));
} else {
$this->flash->failure(t('Unable to create this tag.'));
@@ -62,6 +63,7 @@ class TagController extends BaseController
$this->response->html($this->template->render('tag/edit', array(
'tag' => $tag,
'values' => $values,
+ 'colors' => $this->colorModel->getList(),
'errors' => $errors,
)));
}
@@ -78,7 +80,7 @@ class TagController extends BaseController
}
if ($valid) {
- if ($this->tagModel->update($values['id'], $values['name'])) {
+ if ($this->tagModel->update($values['id'], $values['name'], $values['color_id'])) {
$this->flash->success(t('Tag updated successfully.'));
} else {
$this->flash->failure(t('Unable to update this tag.'));
diff --git a/app/Controller/TaskViewController.php b/app/Controller/TaskViewController.php
index 31b9de11..9a39a3a9 100644
--- a/app/Controller/TaskViewController.php
+++ b/app/Controller/TaskViewController.php
@@ -74,7 +74,7 @@ class TaskViewController extends BaseController
'internal_links' => $this->taskLinkModel->getAllGroupedByLabel($task['id']),
'external_links' => $this->taskExternalLinkModel->getAll($task['id']),
'link_label_list' => $this->linkModel->getList(0, false),
- 'tags' => $this->taskTagModel->getList($task['id']),
+ 'tags' => $this->taskTagModel->getTagsByTask($task['id']),
)));
}
diff --git a/app/Model/ColorModel.php b/app/Model/ColorModel.php
index d0df2ed6..13566fb1 100644
--- a/app/Model/ColorModel.php
+++ b/app/Model/ColorModel.php
@@ -218,7 +218,7 @@ class ColorModel extends Base
$buffer = '';
foreach ($this->default_colors as $color => $values) {
- $buffer .= '.task-board.color-'.$color.', .task-summary-container.color-'.$color.', .color-picker-square.color-'.$color.', .task-board-category.color-'.$color.', .table-list-category.color-'.$color.' {';
+ $buffer .= '.task-board.color-'.$color.', .task-summary-container.color-'.$color.', .color-picker-square.color-'.$color.', .task-board-category.color-'.$color.', .table-list-category.color-'.$color.', .task-tag.color-'.$color.' {';
$buffer .= 'background-color: '.$values['background'].';';
$buffer .= 'border-color: '.$values['border'];
$buffer .= '}';
diff --git a/app/Model/TagModel.php b/app/Model/TagModel.php
index e85c5a87..ece170be 100644
--- a/app/Model/TagModel.php
+++ b/app/Model/TagModel.php
@@ -143,11 +143,12 @@ class TagModel extends Base
* @param string $tag
* @return bool|int
*/
- public function create($project_id, $tag)
+ public function create($project_id, $tag, $color_id = null)
{
return $this->db->table(self::TABLE)->persist(array(
'project_id' => $project_id,
'name' => $tag,
+ 'color_id' => $color_id,
));
}
@@ -159,10 +160,11 @@ class TagModel extends Base
* @param string $tag
* @return bool
*/
- public function update($tag_id, $tag)
+ public function update($tag_id, $tag, $color_id)
{
return $this->db->table(self::TABLE)->eq('id', $tag_id)->update(array(
'name' => $tag,
+ 'color_id' => $color_id,
));
}
diff --git a/app/Model/TaskTagModel.php b/app/Model/TaskTagModel.php
index 78b7a90a..14d2db48 100644
--- a/app/Model/TaskTagModel.php
+++ b/app/Model/TaskTagModel.php
@@ -46,7 +46,7 @@ class TaskTagModel extends Base
public function getTagsByTask($task_id)
{
return $this->db->table(TagModel::TABLE)
- ->columns(TagModel::TABLE.'.id', TagModel::TABLE.'.name')
+ ->columns(TagModel::TABLE.'.id', TagModel::TABLE.'.name', TagModel::TABLE.'.color_id')
->eq(self::TABLE.'.task_id', $task_id)
->join(self::TABLE, 'tag_id', 'id')
->findAll();
@@ -66,7 +66,7 @@ class TaskTagModel extends Base
}
$tags = $this->db->table(TagModel::TABLE)
- ->columns(TagModel::TABLE.'.id', TagModel::TABLE.'.name', self::TABLE.'.task_id')
+ ->columns(TagModel::TABLE.'.id', TagModel::TABLE.'.name', TagModel::TABLE.'.color_id', self::TABLE.'.task_id')
->in(self::TABLE.'.task_id', $task_ids)
->join(self::TABLE, 'tag_id', 'id')
->asc(TagModel::TABLE.'.name')
diff --git a/app/Schema/Mysql.php b/app/Schema/Mysql.php
index a5074a43..5b70f2a3 100644
--- a/app/Schema/Mysql.php
+++ b/app/Schema/Mysql.php
@@ -8,7 +8,12 @@ use PDO;
use Kanboard\Core\Security\Token;
use Kanboard\Core\Security\Role;
-const VERSION = 132;
+const VERSION = 133;
+
+function version_133(PDO $pdo)
+{
+ $pdo->exec('ALTER TABLE `tags` ADD COLUMN `color_id` VARCHAR(50) DEFAULT NULL');
+}
function version_132(PDO $pdo)
{
diff --git a/app/Schema/Postgres.php b/app/Schema/Postgres.php
index cd4e0fac..f66b307d 100644
--- a/app/Schema/Postgres.php
+++ b/app/Schema/Postgres.php
@@ -8,7 +8,12 @@ use PDO;
use Kanboard\Core\Security\Token;
use Kanboard\Core\Security\Role;
-const VERSION = 110;
+const VERSION = 111;
+
+function version_111(PDO $pdo)
+{
+ $pdo->exec('ALTER TABLE "tags" ADD COLUMN "color_id" VARCHAR(50) DEFAULT NULL');
+}
function version_110(PDO $pdo)
{
diff --git a/app/Schema/Sql/mysql.sql b/app/Schema/Sql/mysql.sql
index b626013a..6bf6773f 100644
--- a/app/Schema/Sql/mysql.sql
+++ b/app/Schema/Sql/mysql.sql
@@ -522,6 +522,7 @@ CREATE TABLE `tags` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`project_id` int(11) NOT NULL,
+ `color_id` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `project_id` (`project_id`,`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
diff --git a/app/Schema/Sql/postgres.sql b/app/Schema/Sql/postgres.sql
index c0ea275b..68f78b27 100644
--- a/app/Schema/Sql/postgres.sql
+++ b/app/Schema/Sql/postgres.sql
@@ -927,7 +927,8 @@ ALTER SEQUENCE "swimlanes_id_seq" OWNED BY "swimlanes"."id";
CREATE TABLE "tags" (
"id" integer NOT NULL,
"name" character varying(255) NOT NULL,
- "project_id" integer NOT NULL
+ "project_id" integer NOT NULL,
+ "color_id" character varying(255)
);
diff --git a/app/Schema/Sqlite.php b/app/Schema/Sqlite.php
index 7889b133..1a61c315 100644
--- a/app/Schema/Sqlite.php
+++ b/app/Schema/Sqlite.php
@@ -8,7 +8,12 @@ use Kanboard\Core\Security\Token;
use Kanboard\Core\Security\Role;
use PDO;
-const VERSION = 119;
+const VERSION = 120;
+
+function version_120(PDO $pdo)
+{
+ $pdo->exec('ALTER TABLE tags ADD COLUMN color_id TEXT DEFAULT NULL');
+}
function version_119(PDO $pdo)
{
diff --git a/app/Template/board/task_footer.php b/app/Template/board/task_footer.php
index cdb75a1f..08af52a2 100644
--- a/app/Template/board/task_footer.php
+++ b/app/Template/board/task_footer.php
@@ -25,7 +25,7 @@
<div class="task-tags">
<ul>
<?php foreach ($task['tags'] as $tag): ?>
- <li><?= $this->text->e($tag['name']) ?></li>
+ <li class="task-tag <?= $tag['color_id'] ? "color-{$tag['color_id']}" : '' ?>"><?= $this->text->e($tag['name']) ?></li>
<?php endforeach ?>
</ul>
</div>
diff --git a/app/Template/project_tag/create.php b/app/Template/project_tag/create.php
index d665aa76..61b6e670 100644
--- a/app/Template/project_tag/create.php
+++ b/app/Template/project_tag/create.php
@@ -7,5 +7,8 @@
<?= $this->form->label(t('Name'), 'name') ?>
<?= $this->form->text('name', $values, $errors, array('autofocus', 'required', 'maxlength="191"')) ?>
+ <?= $this->form->label(t('Color'), 'color_id') ?>
+ <?= $this->form->select('color_id', array('' => t('No color')) + $colors, $values, $errors, array(), 'color-picker') ?>
+
<?= $this->modal->submitButtons() ?>
</form>
diff --git a/app/Template/project_tag/edit.php b/app/Template/project_tag/edit.php
index 39b08326..0fab036b 100644
--- a/app/Template/project_tag/edit.php
+++ b/app/Template/project_tag/edit.php
@@ -7,5 +7,8 @@
<?= $this->form->label(t('Name'), 'name') ?>
<?= $this->form->text('name', $values, $errors, array('autofocus', 'required', 'maxlength="191"')) ?>
+ <?= $this->form->label(t('Color'), 'color_id') ?>
+ <?= $this->form->select('color_id', array('' => t('No color')) + $colors, $values, $errors, array(), 'color-picker') ?>
+
<?= $this->modal->submitButtons() ?>
</form>
diff --git a/app/Template/tag/create.php b/app/Template/tag/create.php
index c376eb28..f080f8d8 100644
--- a/app/Template/tag/create.php
+++ b/app/Template/tag/create.php
@@ -8,5 +8,8 @@
<?= $this->form->label(t('Name'), 'name') ?>
<?= $this->form->text('name', $values, $errors, array('autofocus', 'required', 'maxlength="191"')) ?>
+ <?= $this->form->label(t('Color'), 'color_id') ?>
+ <?= $this->form->select('color_id', array('' => t('No color')) + $colors, $values, $errors, array(), 'color-picker') ?>
+
<?= $this->modal->submitButtons() ?>
</form>
diff --git a/app/Template/tag/edit.php b/app/Template/tag/edit.php
index a0e54843..93ce0c94 100644
--- a/app/Template/tag/edit.php
+++ b/app/Template/tag/edit.php
@@ -9,5 +9,8 @@
<?= $this->form->label(t('Name'), 'name') ?>
<?= $this->form->text('name', $values, $errors, array('autofocus', 'required', 'maxlength="191"')) ?>
+ <?= $this->form->label(t('Color'), 'color_id') ?>
+ <?= $this->form->select('color_id', array('' => t('No color')) + $colors, $values, $errors, array(), 'color-picker') ?>
+
<?= $this->modal->submitButtons() ?>
</form>
diff --git a/app/Template/task/details.php b/app/Template/task/details.php
index 2712d49b..f3c6d896 100644
--- a/app/Template/task/details.php
+++ b/app/Template/task/details.php
@@ -156,7 +156,7 @@
<div class="task-tags">
<ul>
<?php foreach ($tags as $tag): ?>
- <li><?= $this->text->e($tag) ?></li>
+ <li class="task-tag <?= $tag['color_id'] ? "color-{$tag['color_id']}" : '' ?>"><?= $this->text->e($tag['name']) ?></li>
<?php endforeach ?>
</ul>
</div>
diff --git a/app/Template/task_list/task_details.php b/app/Template/task_list/task_details.php
index 9afd9f55..03e1d3eb 100644
--- a/app/Template/task_list/task_details.php
+++ b/app/Template/task_list/task_details.php
@@ -25,7 +25,7 @@
<?php endif ?>
<?php foreach ($task['tags'] as $tag): ?>
- <span class="table-list-category task-list-tag">
+ <span class="table-list-category task-list-tag <?= $tag['color_id'] ? "color-{$tag['color_id']}" : '' ?>">
<?= $this->text->e($tag['name']) ?>
</span>
<?php endforeach ?>