summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-06-24 15:43:34 -0400
committerFrederic Guillot <fred@kanboard.net>2016-06-24 15:43:34 -0400
commit18cb7ad0a4a96be63030f5207b74a195c8b6cd6c (patch)
tree719898528a9df56f6d8ea4abaee54b9542e3d434 /app
parentb2e92480c29acb15586bc8ea305c8416927a667c (diff)
Expose tags to the user interface (first prototype)
Diffstat (limited to 'app')
-rw-r--r--app/Controller/TaskModificationController.php1
-rw-r--r--app/Controller/TaskViewController.php2
-rw-r--r--app/Helper/TaskHelper.php28
-rw-r--r--app/Model/TagModel.php18
-rw-r--r--app/Model/TaskCreationModel.php14
-rw-r--r--app/Model/TaskModificationModel.php5
-rw-r--r--app/Template/board/task_footer.php10
-rw-r--r--app/Template/task/details.php259
-rw-r--r--app/Template/task/public.php7
-rw-r--r--app/Template/task/show.php1
-rw-r--r--app/Template/task_creation/show.php4
-rw-r--r--app/Template/task_gantt_creation/show.php5
-rw-r--r--app/Template/task_modification/edit_task.php4
13 files changed, 222 insertions, 136 deletions
diff --git a/app/Controller/TaskModificationController.php b/app/Controller/TaskModificationController.php
index f9c63c12..d55a7193 100644
--- a/app/Controller/TaskModificationController.php
+++ b/app/Controller/TaskModificationController.php
@@ -98,6 +98,7 @@ class TaskModificationController extends BaseController
'values' => $values,
'errors' => $errors,
'task' => $task,
+ 'tags' => $this->taskTagModel->getList($task['id']),
'users_list' => $this->projectUserRoleModel->getAssignableUsersList($task['project_id']),
'colors_list' => $this->colorModel->getList(),
'categories_list' => $this->categoryModel->getList($task['project_id']),
diff --git a/app/Controller/TaskViewController.php b/app/Controller/TaskViewController.php
index bd1e86ae..f40f8bea 100644
--- a/app/Controller/TaskViewController.php
+++ b/app/Controller/TaskViewController.php
@@ -45,6 +45,7 @@ class TaskViewController extends BaseController
'task' => $task,
'columns_list' => $this->columnModel->getList($task['project_id']),
'colors_list' => $this->colorModel->getList(),
+ 'tags' => $this->taskTagModel->getList($task['id']),
'title' => $task['title'],
'no_layout' => true,
'auto_refresh' => true,
@@ -82,6 +83,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']),
)));
}
diff --git a/app/Helper/TaskHelper.php b/app/Helper/TaskHelper.php
index e33438d6..f272059d 100644
--- a/app/Helper/TaskHelper.php
+++ b/app/Helper/TaskHelper.php
@@ -40,6 +40,34 @@ class TaskHelper extends Base
return $this->taskModel->getRecurrenceBasedateList();
}
+ public function selectTitle(array $values, array $errors)
+ {
+ $html = $this->helper->form->label(t('Title'), 'title');
+ $html .= $this->helper->form->text('title', $values, $errors, array('autofocus', 'required', 'maxlength="200"', 'tabindex="1"'), 'form-input-large');
+ return $html;
+ }
+
+ public function selectTags(array $project, array $tags = array())
+ {
+ $options = $this->tagModel->getAssignableList($project['id']);
+
+ $html = $this->helper->form->label(t('Tags'), 'tags[]');
+ $html .= '<select name="tags[]" id="form-tags" class="tag-autocomplete" multiple>';
+
+ foreach ($options as $tag) {
+ $html .= sprintf(
+ '<option value="%s" %s>%s</option>',
+ $this->helper->text->e($tag),
+ in_array($tag, $tags) ? 'selected="selected"' : '',
+ $this->helper->text->e($tag)
+ );
+ }
+
+ $html .= '</select>';
+
+ return $html;
+ }
+
public function selectAssignee(array $users, array $values, array $errors = array(), array $attributes = array())
{
$attributes = array_merge(array('tabindex="3"'), $attributes);
diff --git a/app/Model/TagModel.php b/app/Model/TagModel.php
index 1be05a66..8eb5e5ba 100644
--- a/app/Model/TagModel.php
+++ b/app/Model/TagModel.php
@@ -43,6 +43,24 @@ class TagModel extends Base
}
/**
+ * Get assignable tags for a project
+ *
+ * @access public
+ * @param integer $project_id
+ * @return array
+ */
+ public function getAssignableList($project_id)
+ {
+ return $this->db->hashtable(self::TABLE)
+ ->beginOr()
+ ->eq('project_id', $project_id)
+ ->eq('project_id', 0)
+ ->closeOr()
+ ->asc('name')
+ ->getAll('id', 'name');
+ }
+
+ /**
* Get one tag
*
* @access public
diff --git a/app/Model/TaskCreationModel.php b/app/Model/TaskCreationModel.php
index 3800f831..fa2d32c6 100644
--- a/app/Model/TaskCreationModel.php
+++ b/app/Model/TaskCreationModel.php
@@ -22,11 +22,13 @@ class TaskCreationModel extends Base
*/
public function create(array $values)
{
- if (! $this->projectModel->exists($values['project_id'])) {
- return 0;
- }
-
$position = empty($values['position']) ? 0 : $values['position'];
+ $tags = array();
+
+ if (isset($values['tags'])) {
+ $tags = $values['tags'];
+ unset($values['tags']);
+ }
$this->prepare($values);
$task_id = $this->db->table(TaskModel::TABLE)->persist($values);
@@ -36,6 +38,10 @@ class TaskCreationModel extends Base
$this->taskPositionModel->movePosition($values['project_id'], $task_id, $values['column_id'], $position, $values['swimlane_id'], false);
}
+ if (! empty($tags)) {
+ $this->taskTagModel->save($values['project_id'], $task_id, $tags);
+ }
+
$this->fireEvents($task_id, $values);
}
diff --git a/app/Model/TaskModificationModel.php b/app/Model/TaskModificationModel.php
index 762af2c5..0fc3617e 100644
--- a/app/Model/TaskModificationModel.php
+++ b/app/Model/TaskModificationModel.php
@@ -85,6 +85,11 @@ class TaskModificationModel extends Base
*/
public function prepare(array &$values)
{
+ if (isset($values['tags'])) {
+ $this->taskTagModel->save($values['project_id'], $values['id'], $values['tags']);
+ unset($values['tags']);
+ }
+
$values = $this->dateParser->convert($values, array('date_due'));
$values = $this->dateParser->convert($values, array('date_started'), true);
diff --git a/app/Template/board/task_footer.php b/app/Template/board/task_footer.php
index f6cbff70..37d13605 100644
--- a/app/Template/board/task_footer.php
+++ b/app/Template/board/task_footer.php
@@ -18,6 +18,16 @@
</div>
<?php endif ?>
+<?php if (! empty($task['tags'])): ?>
+ <div class="task-tags">
+ <ul>
+ <?php foreach ($task['tags'] as $tag): ?>
+ <li><?= $this->text->e($tag['name']) ?></li>
+ <?php endforeach ?>
+ </ul>
+ </div>
+<?php endif ?>
+
<div class="task-board-icons">
<?php if ($task['score']): ?>
<span class="task-score" title="<?= t('Complexity') ?>">
diff --git a/app/Template/task/details.php b/app/Template/task/details.php
index fe2bba67..695957f9 100644
--- a/app/Template/task/details.php
+++ b/app/Template/task/details.php
@@ -4,146 +4,157 @@
<?= $this->hook->render('template:task:details:top', array('task' => $task)) ?>
<div class="task-summary-container color-<?= $task['color_id'] ?>">
- <div class="task-summary-column">
- <ul class="no-bullet">
- <li>
- <strong><?= t('Status:') ?></strong>
- <span>
- <?php if ($task['is_active'] == 1): ?>
- <?= t('open') ?>
- <?php else: ?>
- <?= t('closed') ?>
- <?php endif ?>
- </span>
- </li>
- <li>
- <strong><?= t('Priority:') ?></strong> <span><?= $task['priority'] ?></span>
- </li>
- <?php if (! empty($task['reference'])): ?>
+ <div class="task-summary-columns">
+ <div class="task-summary-column">
+ <ul class="no-bullet">
<li>
- <strong><?= t('Reference:') ?></strong> <span><?= $this->text->e($task['reference']) ?></span>
+ <strong><?= t('Status:') ?></strong>
+ <span>
+ <?php if ($task['is_active'] == 1): ?>
+ <?= t('open') ?>
+ <?php else: ?>
+ <?= t('closed') ?>
+ <?php endif ?>
+ </span>
</li>
- <?php endif ?>
- <?php if (! empty($task['score'])): ?>
<li>
- <strong><?= t('Complexity:') ?></strong> <span><?= $this->text->e($task['score']) ?></span>
+ <strong><?= t('Priority:') ?></strong> <span><?= $task['priority'] ?></span>
</li>
- <?php endif ?>
- <?php if ($project['is_public']): ?>
- <li class="smaller">
- <i class="fa fa-external-link fa-fw"></i>
- <?= $this->url->link(t('Public link'), 'TaskViewController', 'readonly', array('task_id' => $task['id'], 'token' => $project['token']), false, '', '', true) ?>
- </li>
- <?php endif ?>
- <?php if ($project['is_public'] && !$editable): ?>
- <li class="smaller">
- <i class="fa fa-th fa-fw"></i>
- <?= $this->url->link(t('Back to the board'), 'BoardViewController', 'readonly', array('token' => $project['token'])) ?>
- </li>
- <?php endif ?>
- <li class="smaller">
+ <?php if (! empty($task['reference'])): ?>
+ <li>
+ <strong><?= t('Reference:') ?></strong> <span><?= $this->text->e($task['reference']) ?></span>
+ </li>
+ <?php endif ?>
+ <?php if (! empty($task['score'])): ?>
+ <li>
+ <strong><?= t('Complexity:') ?></strong> <span><?= $this->text->e($task['score']) ?></span>
+ </li>
+ <?php endif ?>
+ <?php if ($project['is_public']): ?>
+ <li class="smaller">
+ <i class="fa fa-external-link fa-fw"></i>
+ <?= $this->url->link(t('Public link'), 'TaskViewController', 'readonly', array('task_id' => $task['id'], 'token' => $project['token']), false, '', '', true) ?>
+ </li>
+ <?php endif ?>
+ <?php if ($project['is_public'] && !$editable): ?>
+ <li class="smaller">
+ <i class="fa fa-th fa-fw"></i>
+ <?= $this->url->link(t('Back to the board'), 'BoardViewController', 'readonly', array('token' => $project['token'])) ?>
+ </li>
+ <?php endif ?>
+ <li class="smaller">
- <?= $this->hook->render('template:task:details:first-column', array('task' => $task)) ?>
- </ul>
- </div>
- <div class="task-summary-column">
- <ul class="no-bullet">
- <?php if (! empty($task['category_name'])): ?>
+ <?= $this->hook->render('template:task:details:first-column', array('task' => $task)) ?>
+ </ul>
+ </div>
+ <div class="task-summary-column">
+ <ul class="no-bullet">
+ <?php if (! empty($task['category_name'])): ?>
+ <li>
+ <strong><?= t('Category:') ?></strong>
+ <span><?= $this->text->e($task['category_name']) ?></span>
+ </li>
+ <?php endif ?>
+ <?php if (! empty($task['swimlane_name'])): ?>
+ <li>
+ <strong><?= t('Swimlane:') ?></strong>
+ <span><?= $this->text->e($task['swimlane_name']) ?></span>
+ </li>
+ <?php endif ?>
<li>
- <strong><?= t('Category:') ?></strong>
- <span><?= $this->text->e($task['category_name']) ?></span>
+ <strong><?= t('Column:') ?></strong>
+ <span><?= $this->text->e($task['column_title']) ?></span>
</li>
- <?php endif ?>
- <?php if (! empty($task['swimlane_name'])): ?>
<li>
- <strong><?= t('Swimlane:') ?></strong>
- <span><?= $this->text->e($task['swimlane_name']) ?></span>
+ <strong><?= t('Position:') ?></strong>
+ <span><?= $task['position'] ?></span>
</li>
- <?php endif ?>
- <li>
- <strong><?= t('Column:') ?></strong>
- <span><?= $this->text->e($task['column_title']) ?></span>
- </li>
- <li>
- <strong><?= t('Position:') ?></strong>
- <span><?= $task['position'] ?></span>
- </li>
- <?= $this->hook->render('template:task:details:second-column', array('task' => $task)) ?>
- </ul>
- </div>
- <div class="task-summary-column">
- <ul class="no-bullet">
- <li>
- <strong><?= t('Assignee:') ?></strong>
- <span>
- <?php if ($task['assignee_username']): ?>
- <?= $this->text->e($task['assignee_name'] ?: $task['assignee_username']) ?>
- <?php else: ?>
- <?= t('not assigned') ?>
+ <?= $this->hook->render('template:task:details:second-column', array('task' => $task)) ?>
+ </ul>
+ </div>
+ <div class="task-summary-column">
+ <ul class="no-bullet">
+ <li>
+ <strong><?= t('Assignee:') ?></strong>
+ <span>
+ <?php if ($task['assignee_username']): ?>
+ <?= $this->text->e($task['assignee_name'] ?: $task['assignee_username']) ?>
+ <?php else: ?>
+ <?= t('not assigned') ?>
+ <?php endif ?>
+ </span>
+ </li>
+ <?php if ($task['creator_username']): ?>
+ <li>
+ <strong><?= t('Creator:') ?></strong>
+ <span><?= $this->text->e($task['creator_name'] ?: $task['creator_username']) ?></span>
+ </li>
+ <?php endif ?>
+ <?php if ($task['date_due']): ?>
+ <li>
+ <strong><?= t('Due date:') ?></strong>
+ <span><?= $this->dt->date($task['date_due']) ?></span>
+ </li>
+ <?php endif ?>
+ <?php if ($task['time_estimated']): ?>
+ <li>
+ <strong><?= t('Time estimated:') ?></strong>
+ <span><?= t('%s hours', $task['time_estimated']) ?></span>
+ </li>
<?php endif ?>
- </span>
- </li>
- <?php if ($task['creator_username']): ?>
+ <?php if ($task['time_spent']): ?>
<li>
- <strong><?= t('Creator:') ?></strong>
- <span><?= $this->text->e($task['creator_name'] ?: $task['creator_username']) ?></span>
+ <strong><?= t('Time spent:') ?></strong>
+ <span><?= t('%s hours', $task['time_spent']) ?></span>
</li>
- <?php endif ?>
- <?php if ($task['date_due']): ?>
- <li>
- <strong><?= t('Due date:') ?></strong>
- <span><?= $this->dt->date($task['date_due']) ?></span>
- </li>
- <?php endif ?>
- <?php if ($task['time_estimated']): ?>
- <li>
- <strong><?= t('Time estimated:') ?></strong>
- <span><?= t('%s hours', $task['time_estimated']) ?></span>
- </li>
- <?php endif ?>
- <?php if ($task['time_spent']): ?>
- <li>
- <strong><?= t('Time spent:') ?></strong>
- <span><?= t('%s hours', $task['time_spent']) ?></span>
- </li>
- <?php endif ?>
+ <?php endif ?>
- <?= $this->hook->render('template:task:details:third-column', array('task' => $task)) ?>
- </ul>
- </div>
- <div class="task-summary-column">
- <ul class="no-bullet">
- <li>
- <strong><?= t('Created:') ?></strong>
- <span><?= $this->dt->datetime($task['date_creation']) ?></span>
- </li>
- <li>
- <strong><?= t('Modified:') ?></strong>
- <span><?= $this->dt->datetime($task['date_modification']) ?></span>
- </li>
- <?php if ($task['date_completed']): ?>
- <li>
- <strong><?= t('Completed:') ?></strong>
- <span><?= $this->dt->datetime($task['date_completed']) ?></span>
- </li>
- <?php endif ?>
- <?php if ($task['date_started']): ?>
- <li>
- <strong><?= t('Started:') ?></strong>
- <span><?= $this->dt->datetime($task['date_started']) ?></span>
- </li>
- <?php endif ?>
- <?php if ($task['date_moved']): ?>
- <li>
- <strong><?= t('Moved:') ?></strong>
- <span><?= $this->dt->datetime($task['date_moved']) ?></span>
- </li>
- <?php endif ?>
+ <?= $this->hook->render('template:task:details:third-column', array('task' => $task)) ?>
+ </ul>
+ </div>
+ <div class="task-summary-column">
+ <ul class="no-bullet">
+ <li>
+ <strong><?= t('Created:') ?></strong>
+ <span><?= $this->dt->datetime($task['date_creation']) ?></span>
+ </li>
+ <li>
+ <strong><?= t('Modified:') ?></strong>
+ <span><?= $this->dt->datetime($task['date_modification']) ?></span>
+ </li>
+ <?php if ($task['date_completed']): ?>
+ <li>
+ <strong><?= t('Completed:') ?></strong>
+ <span><?= $this->dt->datetime($task['date_completed']) ?></span>
+ </li>
+ <?php endif ?>
+ <?php if ($task['date_started']): ?>
+ <li>
+ <strong><?= t('Started:') ?></strong>
+ <span><?= $this->dt->datetime($task['date_started']) ?></span>
+ </li>
+ <?php endif ?>
+ <?php if ($task['date_moved']): ?>
+ <li>
+ <strong><?= t('Moved:') ?></strong>
+ <span><?= $this->dt->datetime($task['date_moved']) ?></span>
+ </li>
+ <?php endif ?>
- <?= $this->hook->render('template:task:details:fourth-column', array('task' => $task)) ?>
- </ul>
+ <?= $this->hook->render('template:task:details:fourth-column', array('task' => $task)) ?>
+ </ul>
+ </div>
</div>
+ <?php if (! empty($tags)): ?>
+ <div class="task-tags">
+ <ul>
+ <?php foreach ($tags as $tag): ?>
+ <li><?= $this->text->e($tag) ?></li>
+ <?php endforeach ?>
+ </ul>
+ </div>
+ <?php endif ?>
</div>
<?php if ($editable && empty($task['date_started'])): ?>
diff --git a/app/Template/task/public.php b/app/Template/task/public.php
index 94782163..b8405ff7 100644
--- a/app/Template/task/public.php
+++ b/app/Template/task/public.php
@@ -1,5 +1,10 @@
<section id="main" class="public-task">
- <?= $this->render('task/details', array('task' => $task, 'project' => $project, 'editable' => false)) ?>
+ <?= $this->render('task/details', array(
+ 'task' => $task,
+ 'tags' => $tags,
+ 'project' => $project,
+ 'editable' => false,
+ )) ?>
<?= $this->render('task/description', array(
'task' => $task,
diff --git a/app/Template/task/show.php b/app/Template/task/show.php
index 2b54eea8..80786715 100644
--- a/app/Template/task/show.php
+++ b/app/Template/task/show.php
@@ -2,6 +2,7 @@
<?= $this->render('task/details', array(
'task' => $task,
+ 'tags' => $tags,
'project' => $project,
'editable' => $this->user->hasProjectAccess('TaskModificationController', 'edit', $project['id']),
)) ?>
diff --git a/app/Template/task_creation/show.php b/app/Template/task_creation/show.php
index 7bebbfe9..cd752eba 100644
--- a/app/Template/task_creation/show.php
+++ b/app/Template/task_creation/show.php
@@ -7,8 +7,7 @@
<?= $this->form->csrf() ?>
<div class="form-column">
- <?= $this->form->label(t('Title'), 'title') ?>
- <?= $this->form->text('title', $values, $errors, array('autofocus', 'required', 'maxlength="200"', 'tabindex="1"'), 'form-input-large') ?>
+ <?= $this->task->selectTitle($values, $errors) ?>
<?= $this->form->label(t('Description'), 'description') ?>
<?= $this->form->textarea(
@@ -23,6 +22,7 @@
'markdown-editor'
) ?>
+ <?= $this->task->selectTags($project) ?>
<?= $this->render('task/color_picker', array('colors_list' => $colors_list, 'values' => $values)) ?>
<?php if (! isset($duplicate)): ?>
diff --git a/app/Template/task_gantt_creation/show.php b/app/Template/task_gantt_creation/show.php
index 683bc8c8..d1bfa67c 100644
--- a/app/Template/task_gantt_creation/show.php
+++ b/app/Template/task_gantt_creation/show.php
@@ -8,12 +8,11 @@
<?= $this->form->hidden('position', $values) ?>
<div class="form-column">
- <?= $this->form->label(t('Title'), 'title') ?>
- <?= $this->form->text('title', $values, $errors, array('autofocus', 'required', 'maxlength="200"', 'tabindex="1"'), 'form-input-large') ?>
+ <?= $this->task->selectTitle($values, $errors) ?>
<?= $this->form->label(t('Description'), 'description') ?>
<?= $this->form->textarea('description', $values, $errors, array('placeholder="'.t('Leave a description').'"', 'tabindex="2"'), 'markdown-editor') ?>
-
+ <?= $this->task->selectTags($project) ?>
<?= $this->render('task/color_picker', array('colors_list' => $colors_list, 'values' => $values)) ?>
</div>
diff --git a/app/Template/task_modification/edit_task.php b/app/Template/task_modification/edit_task.php
index 0707fd9a..d8f18743 100644
--- a/app/Template/task_modification/edit_task.php
+++ b/app/Template/task_modification/edit_task.php
@@ -7,8 +7,8 @@
<?= $this->form->hidden('project_id', $values) ?>
<div class="form-column">
- <?= $this->form->label(t('Title'), 'title') ?>
- <?= $this->form->text('title', $values, $errors, array('autofocus', 'required', 'maxlength="200"', 'tabindex="1"')) ?>
+ <?= $this->task->selectTitle($values, $errors) ?>
+ <?= $this->task->selectTags($project, $tags) ?>
<?= $this->task->selectAssignee($users_list, $values, $errors) ?>
<?= $this->task->selectCategory($categories_list, $values, $errors) ?>
<?= $this->task->selectPriority($project, $values) ?>