diff options
-rw-r--r-- | assets/css/app.css | 34 | ||||
-rw-r--r-- | controllers/project.php | 23 | ||||
-rw-r--r-- | controllers/task.php | 2 | ||||
-rw-r--r-- | locales/fr_FR/translations.php | 14 | ||||
-rw-r--r-- | locales/pl_PL/translations.php | 17 | ||||
-rw-r--r-- | models/base.php | 2 | ||||
-rw-r--r-- | models/project.php | 1 | ||||
-rw-r--r-- | models/schema.php | 8 | ||||
-rw-r--r-- | models/task.php | 40 | ||||
-rw-r--r-- | templates/board_index.php | 12 | ||||
-rw-r--r-- | templates/project_index.php | 16 | ||||
-rw-r--r-- | templates/project_tasks.php | 52 | ||||
-rw-r--r-- | templates/task_show.php | 5 |
13 files changed, 215 insertions, 11 deletions
diff --git a/assets/css/app.css b/assets/css/app.css index 2e3e6987..fb0bba98 100644 --- a/assets/css/app.css +++ b/assets/css/app.css @@ -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); diff --git a/controllers/project.php b/controllers/project.php index a384be67..c44dd38d 100644 --- a/controllers/project.php +++ b/controllers/project.php @@ -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() { diff --git a/controllers/task.php b/controllers/task.php index b30758b6..79f2c7d0 100644 --- a/controllers/task.php +++ b/controllers/task.php @@ -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.')); diff --git a/locales/fr_FR/translations.php b/locales/fr_FR/translations.php index 4249632a..245825ad 100644 --- a/locales/fr_FR/translations.php +++ b/locales/fr_FR/translations.php @@ -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', ); diff --git a/locales/pl_PL/translations.php b/locales/pl_PL/translations.php index ae3df97e..32e9e3c8 100644 --- a/locales/pl_PL/translations.php +++ b/locales/pl_PL/translations.php @@ -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' => '',*/ ); diff --git a/models/base.php b/models/base.php index 1029074d..981c7839 100644 --- a/models/base.php +++ b/models/base.php @@ -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; diff --git a/models/project.php b/models/project.php index b0c2b2ca..10d7c572 100644 --- a/models/project.php +++ b/models/project.php @@ -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(); diff --git a/models/schema.php b/models/schema.php index 3217663a..9ccb500f 100644 --- a/models/schema.php +++ b/models/schema.php @@ -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(" diff --git a/models/task.php b/models/task.php index db27c650..9d23baf0 100644 --- a/models/task.php +++ b/models/task.php @@ -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) diff --git a/templates/board_index.php b/templates/board_index.php index 777d601b..abd511b7 100644 --- a/templates/board_index.php +++ b/templates/board_index.php @@ -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&action=tasks&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); ?> diff --git a/templates/project_index.php b/templates/project_index.php index 0fc2468c..d144e41f 100644 --- a/templates/project_index.php +++ b/templates/project_index.php @@ -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&action=show&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&action=tasks&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> diff --git a/templates/project_tasks.php b/templates/project_tasks.php new file mode 100644 index 00000000..ed244c34 --- /dev/null +++ b/templates/project_tasks.php @@ -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&action=show&project_id=<?= $project['id'] ?>"><?= t('Back to the board') ?></a></li> + <li><a href="?controller=project&action=index"><?= t('List of projects') ?></a></li> + <?php if ($_SESSION['user']['is_admin'] == 1): ?> + <li><a href="?controller=project&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&action=show&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&action=show&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>
\ No newline at end of file diff --git a/templates/task_show.php b/templates/task_show.php index 99738f9c..f09f249e 100644 --- a/templates/task_show.php +++ b/templates/task_show.php @@ -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']): ?> |