Add a page to display completed tasks and add the completion date column for tasks

This commit is contained in:
Frédéric Guillot 2014-02-22 13:37:06 -05:00
parent fd28d50597
commit a1923d3d7f
13 changed files with 215 additions and 11 deletions

View File

@ -402,6 +402,30 @@ nav .active a {
}
/* boards */
.page-header.board {
margin-bottom: 0;
}
.project-menu li {
display: inline;
padding-left: 10px;
padding-right: 10px;
border-right: 1px dotted #ccc;
}
.project-menu li:last-child {
border: none;
padding-right: 0;
}
.project-menu ul {
padding-bottom: 5px;
}
.project-menu {
text-align: right;
}
#board th a {
text-decoration: none;
font-size: 150%;
@ -451,12 +475,15 @@ td div.over {
box-shadow: 0 0 3px #333;
}
tr td.task a,
div.task a {
color: #000;
text-decoration: none;
font-weight: bold;
}
tr td.task a:focus,
tr td.task a:hover,
div.task a:focus,
div.task a:hover {
text-decoration: underline;
@ -467,36 +494,43 @@ article.task li {
list-style-type: square;
}
tr td.task-blue,
.task-blue {
background-color: rgb(219, 235, 255);
border-color: rgb(168, 207, 255);
}
tr td.task-purple,
.task-purple {
background-color: rgb(223, 176, 255);
border-color: rgb(205, 133, 254);
}
tr td.task-grey,
.task-grey {
background-color: rgb(238, 238, 238);
border-color: rgb(204, 204, 204);
}
tr td.task-red,
.task-red {
background-color: rgb(255, 187, 187);
border-color: rgb(255, 151, 151);
}
tr td.task-green,
.task-green {
background-color: rgb(189, 244, 203);
border-color: rgb(74, 227, 113);
}
tr td.task-yellow,
.task-yellow {
background-color: rgb(245, 247, 196);
border-color: rgb(223, 227, 45);
}
tr td.task-orange,
.task-orange {
background-color: rgb(255, 215, 179);
border-color: rgb(255, 172, 98);

View File

@ -4,6 +4,29 @@ namespace Controller;
class Project extends Base
{
// List of completed tasks for a given project
public function tasks()
{
$project_id = $this->request->getIntegerParam('project_id');
$project = $this->project->get($project_id);
if (! $project) {
$this->session->flashError(t('Project not found.'));
$this->response->redirect('?controller=project');
}
$tasks = $this->task->getAllByProjectId($project_id, array(0));
$nb_tasks = count($tasks);
$this->response->html($this->template->layout('project_tasks', array(
'menu' => 'projects',
'project' => $project,
'tasks' => $tasks,
'nb_tasks' => $nb_tasks,
'title' => $project['name'].' ('.$nb_tasks.')'
)));
}
// List of projects
public function index()
{

View File

@ -188,7 +188,7 @@ class Task extends Base
{
$task = $this->task->getById($this->request->getIntegerParam('task_id'));
if ($task && $this->task->close($task['id'])) {
if ($task && $this->task->open($task['id'])) {
$this->session->flash(t('Task opened successfully.'));
} else {
$this->session->flashError(t('Unable to open this task.'));

View File

@ -166,5 +166,17 @@ return array(
'Backlog' => 'En attente',
'Work in progress' => 'En cours',
'Done' => 'Terminé',
'Application version:' => 'Version de l\'application :'
'Application version:' => 'Version de l\'application :',
'Completed on %B %e, %G at %k:%M %p' => 'Terminé le %e %B %G à %k:%M',
'%B %e, %G at %k:%M %p' => '%e %B %G à %k:%M',
'Date created' => 'Date de création',
'Date completed' => 'Date de clôture',
'Id' => 'Identifiant',
'Show this task' => 'Afficher cette tâche',
'No task' => 'Aucune tâche',
'completed tasks' => 'tâches terminées',
'List of projects' => 'Liste des projets',
'Completed tasks for "%s"' => 'Tâches terminées pour "%s"',
'%d closed tasks' => '%d tâches terminées',
'no task for this project' => 'aucune tâche pour ce projet',
);

View File

@ -166,5 +166,20 @@ return array(
'Backlog' => 'Log',
'Work in progress' => 'W trakcie',
'Done' => 'Zakończone',
'Application version:' => 'Wersja aplikacji :'
'Application version:' => 'Wersja aplikacji :',
/* Missing translations:
'Completed on %B %e, %G at %k:%M %p' => '',
'%B %e, %G at %k:%M %p' => '',
'Date created' => '',
'Date completed' => '',
'Id' => '',
'Show this task' => '',
'No task' => '',
'completed tasks' => '',
'List of projects' => '',
'Completed tasks for "%s"' => '',
'%d closed tasks' => '',
'no task for this project' => '',*/
);

View File

@ -17,7 +17,7 @@ require __DIR__.'/schema.php';
abstract class Base
{
const APP_VERSION = 'master';
const DB_VERSION = 1;
const DB_VERSION = 2;
const DB_FILENAME = 'data/db.sqlite';
private static $dbInstance = null;

View File

@ -49,6 +49,7 @@ class Project extends Base
$project['columns'] = $columns;
$project['nb_tasks'] = $taskModel->countByProjectId($project['id']);
$project['nb_inactive_tasks'] = $project['nb_tasks'] - $project['nb_active_tasks'];
}
$this->db->closeTransaction();

View File

@ -2,6 +2,14 @@
namespace Schema;
function version_2($pdo)
{
$pdo->exec('ALTER TABLE tasks ADD column date_completed INTEGER');
// For all existing completed tasks, set the date of creation as a date of completion
$pdo->exec('UPDATE tasks SET date_completed=date_creation WHERE is_active=0');
}
function version_1($pdo)
{
$pdo->exec("

View File

@ -33,6 +33,7 @@ class Task extends Base
self::TABLE.'.title',
self::TABLE.'.description',
self::TABLE.'.date_creation',
self::TABLE.'.date_completed',
self::TABLE.'.color_id',
self::TABLE.'.project_id',
self::TABLE.'.column_id',
@ -55,9 +56,30 @@ class Task extends Base
}
}
public function getAllByProjectId($project_id)
public function getAllByProjectId($project_id, array $status = array(1, 0))
{
return $this->db->table(self::TABLE)->eq('project_id', $project_id)->findAll();
return $this->db->table(self::TABLE)
->columns(
self::TABLE.'.id',
self::TABLE.'.title',
self::TABLE.'.description',
self::TABLE.'.date_creation',
self::TABLE.'.date_completed',
self::TABLE.'.color_id',
self::TABLE.'.project_id',
self::TABLE.'.column_id',
self::TABLE.'.owner_id',
self::TABLE.'.position',
self::TABLE.'.is_active',
\Model\Board::TABLE.'.title AS column_title',
\Model\User::TABLE.'.username'
)
->join(\Model\Board::TABLE, 'id', 'column_id')
->join(\Model\User::TABLE, 'id', 'owner_id')
->eq(self::TABLE.'.project_id', $project_id)
->in('is_active', $status)
->desc('date_completed')
->findAll();
}
public function countByProjectId($project_id, $status = array(1, 0))
@ -117,12 +139,22 @@ class Task extends Base
public function close($task_id)
{
return $this->db->table(self::TABLE)->eq('id', $task_id)->update(array('is_active' => 0));
return $this->db->table(self::TABLE)
->eq('id', $task_id)
->update(array(
'is_active' => 0,
'date_completed' => time()
));
}
public function open($task_id)
{
return $this->db->table(self::TABLE)->eq('id', $task_id)->update(array('is_active' => 1));
return $this->db->table(self::TABLE)
->eq('id', $task_id)
->update(array(
'is_active' => 1,
'date_completed' => ''
));
}
public function remove($task_id)

View File

@ -1,7 +1,9 @@
<section id="main">
<div class="page-header">
<h2><?= t('Project "%s"', $current_project_name) ?></h2>
<div class="page-header board">
<h2>
<?= t('Project "%s"', $current_project_name) ?>
</h2>
<ul>
<?php foreach ($projects as $project_id => $project_name): ?>
<?php if ($project_id != $current_project_id): ?>
@ -13,6 +15,12 @@
</ul>
</div>
<div class="project-menu">
<ul>
<li><a href="?controller=project&amp;action=tasks&amp;project_id=<?= $current_project_id ?>"><?= t('completed tasks') ?></a></li>
</ul>
</div>
<table id="board" data-project-id="<?= $current_project_id ?>">
<tr>
<?php $column_with = round(100 / count($columns), 2); ?>

View File

@ -31,7 +31,21 @@
<?= $project['is_active'] ? t('Active') : t('Inactive') ?>
</td>
<td>
<?= t('%d tasks on the board', $project['nb_active_tasks']) ?>, <?= t('%d tasks in total', $project['nb_tasks']) ?>
<?php if ($project['nb_tasks'] > 0): ?>
<?php if ($project['nb_active_tasks'] > 0): ?>
<a href="?controller=board&amp;action=show&amp;project_id=<?= $project['id'] ?>"><?= t('%d tasks on the board', $project['nb_active_tasks']) ?></a>,
<?php endif ?>
<?php if ($project['nb_inactive_tasks'] > 0): ?>
<a href="?controller=project&amp;action=tasks&amp;project_id=<?= $project['id'] ?>"><?= t('%d closed tasks', $project['nb_inactive_tasks']) ?></a>,
<?php endif ?>
<?= t('%d tasks in total', $project['nb_tasks']) ?>
<?php else: ?>
<?= t('no task for this project') ?>
<?php endif ?>
</td>
<td>
<ul>

View File

@ -0,0 +1,52 @@
<section id="main">
<div class="page-header">
<h2><?= t('Completed tasks for "%s"', $project['name']) ?><span id="page-counter"> (<?= $nb_tasks ?>)</span></h2>
<ul>
<li><a href="?controller=board&amp;action=show&amp;project_id=<?= $project['id'] ?>"><?= t('Back to the board') ?></a></li>
<li><a href="?controller=project&amp;action=index"><?= t('List of projects') ?></a></li>
<?php if ($_SESSION['user']['is_admin'] == 1): ?>
<li><a href="?controller=project&amp;action=create"><?= t('New project') ?></a></li>
<?php endif ?>
</ul>
</div>
<section>
<?php if (empty($tasks)): ?>
<p class="alert"><?= t('No task') ?></p>
<?php else: ?>
<table>
<tr>
<th><?= t('Id') ?></th>
<th><?= t('Column') ?></th>
<th><?= t('Title') ?></th>
<th><?= t('Assignee') ?></th>
<th><?= t('Date created') ?></th>
<th><?= t('Date completed') ?></th>
</tr>
<?php foreach ($tasks as $task): ?>
<tr>
<td class="task task-<?= $task['color_id'] ?>">
<a href="?controller=task&amp;action=show&amp;task_id=<?= $task['id'] ?>" title="<?= t('Show this task') ?>"><?= Helper\escape($task['id']) ?></a>
</td>
<td>
<?= Helper\escape($task['column_title']) ?>
</td>
<td>
<a href="?controller=task&amp;action=show&amp;task_id=<?= $task['id'] ?>" title="<?= t('Show this task') ?>"><?= Helper\escape($task['title']) ?></a>
</td>
<td>
<?= Helper\escape($task['username']) ?>
</td>
<td>
<?= dt('%B %e, %G at %k:%M %p', $task['date_creation']) ?>
</td>
<td>
<?php if ($task['date_completed']): ?>
<?= dt('%B %e, %G at %k:%M %p', $task['date_completed']) ?>
<?php endif ?>
</td>
</tr>
<?php endforeach ?>
</table>
<?php endif ?>
</section>
</section>

View File

@ -12,6 +12,11 @@
<li>
<?= dt('Created on %B %e, %G at %k:%M %p', $task['date_creation']) ?>
</li>
<?php if ($task['date_completed']): ?>
<li>
<?= dt('Completed on %B %e, %G at %k:%M %p', $task['date_completed']) ?>
</li>
<?php endif ?>
<li>
<strong>
<?php if ($task['username']): ?>