summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-06-13 22:55:01 -0400
committerFrederic Guillot <fred@kanboard.net>2015-06-13 22:55:01 -0400
commita785810f2d11ad14ab3497a51ca10a6780b758ad (patch)
treef00ef73737b122c426445dea28169bacbf4cef97
parenta9f976153983f8e611df14aa8ffed85bea052e0f (diff)
Show changes in task update notifications
-rw-r--r--app/Model/Notification.php2
-rw-r--r--app/Subscriber/NotificationSubscriber.php1
-rw-r--r--app/Template/notification/task_update.php96
3 files changed, 61 insertions, 38 deletions
diff --git a/app/Model/Notification.php b/app/Model/Notification.php
index 34500483..1ef6a88f 100644
--- a/app/Model/Notification.php
+++ b/app/Model/Notification.php
@@ -268,7 +268,7 @@ class Notification extends Base
{
return $this->template->render(
'notification/'.str_replace('.', '_', $event_name),
- $event_data + array('application_url' => $this->config->get('application_url'))
+ $event_data + array('application_url' => $this->config->get('application_url'), 'colors_list' => $this->color->getList())
);
}
diff --git a/app/Subscriber/NotificationSubscriber.php b/app/Subscriber/NotificationSubscriber.php
index 41fd6aef..d605c9f3 100644
--- a/app/Subscriber/NotificationSubscriber.php
+++ b/app/Subscriber/NotificationSubscriber.php
@@ -41,6 +41,7 @@ class NotificationSubscriber extends \Core\Base implements EventSubscriberInterf
switch (get_class($event)) {
case 'Event\TaskEvent':
$values['task'] = $this->taskFinder->getDetails($event['task_id']);
+ $values['changes'] = isset($event['changes']) ? $event['changes'] : array();
break;
case 'Event\SubtaskEvent':
$values['subtask'] = $this->subtask->getById($event['id'], true);
diff --git a/app/Template/notification/task_update.php b/app/Template/notification/task_update.php
index ffea49cd..0352788b 100644
--- a/app/Template/notification/task_update.php
+++ b/app/Template/notification/task_update.php
@@ -1,43 +1,65 @@
<h2><?= $this->e($task['title']) ?> (#<?= $task['id'] ?>)</h2>
-<ul>
- <li>
- <?= dt('Created on %B %e, %Y at %k:%M %p', $task['date_creation']) ?>
- </li>
- <?php if ($task['date_due']): ?>
- <li>
- <strong><?= dt('Must be done before %B %e, %Y', $task['date_due']) ?></strong>
- </li>
- <?php endif ?>
- <?php if ($task['creator_username']): ?>
- <li>
- <?= t('Created by %s', $task['creator_name'] ?: $task['creator_username']) ?>
- </li>
- <?php endif ?>
- <li>
- <strong>
- <?php if ($task['assignee_username']): ?>
- <?= t('Assigned to %s', $task['assignee_name'] ?: $task['assignee_username']) ?>
- <?php else: ?>
- <?= t('There is nobody assigned') ?>
- <?php endif ?>
- </strong>
- </li>
- <li>
- <?= t('Column on the board:') ?>
- <strong><?= $this->e($task['column_title']) ?></strong>
- </li>
- <li><?= t('Task position:').' '.$this->e($task['position']) ?></li>
- <?php if ($task['category_name']): ?>
- <li>
- <?= t('Category:') ?> <strong><?= $this->e($task['category_name']) ?></strong>
- </li>
- <?php endif ?>
-</ul>
+<?= t('The task have been updated.') ?>
+
+<?php if (! empty($changes)): ?>
+ <h2><?= t('List of changes') ?></h2>
+ <ul>
+ <?php
-<?php if (! empty($task['description'])): ?>
- <h2><?= t('Description') ?></h2>
- <?= $this->text->markdown($task['description']) ?: t('There is no description.') ?>
+ foreach ($changes as $field => $value) {
+
+ switch ($field) {
+ case 'title':
+ echo '<li>'.t('New title: %s', $task['title']).'</li>';
+ break;
+ case 'owner_id':
+ if (empty($task['owner_id'])) {
+ echo '<li>'.t('The task is not assigned anymore').'</li>';
+ }
+ else {
+ echo '<li>'.t('New assignee: %s', $task['assignee_name'] ?: $task['assignee_username']).'</li>';
+ }
+ break;
+ case 'category_id':
+ if (empty($task['category_id'])) {
+ echo '<li>'.t('There is no category now').'</li>';
+ }
+ else {
+ echo '<li>'.t('New category: %s', $task['category_name']).'</li>';
+ }
+ break;
+ case 'color_id':
+ echo '<li>'.t('New color: %s', $this->text->in($task['color_id'], $colors_list)).'</li>';
+ break;
+ case 'score':
+ echo '<li>'.t('New complexity: %d', $task['score']).'</li>';
+ break;
+ case 'date_due':
+ if (empty($task['date_due'])) {
+ echo '<li>'.t('The due date have been removed').'</li>';
+ }
+ else {
+ echo '<li>'.dt('New due date: %B %e, %Y', $task['date_due']).'</li>';
+ }
+ break;
+ case 'description':
+ if (empty($task['description'])) {
+ echo '<li>'.t('There is no description anymore').'</li>';
+ }
+ break;
+ default:
+ echo '<li>'.t('The field "%s" have been updated', $field).'</li>';
+ }
+ }
+
+ ?>
+ </ul>
+
+ <?php if (! empty($changes['description'])): ?>
+ <h3><?= t('New description') ?></h3>
+ <?= $this->text->markdown($task['description']) ?>
+ <?php endif ?>
<?php endif ?>
<?= $this->render('notification/footer', array('task' => $task, 'application_url' => $application_url)) ?> \ No newline at end of file