summaryrefslogtreecommitdiff
path: root/app/Model
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-07-17 20:33:27 -0400
committerFrederic Guillot <fred@kanboard.net>2016-07-17 20:33:27 -0400
commitd9d37882228771bca0c7f53f5ffcef90ba7ac1c5 (patch)
treef5df4446273878fc0bc9bf6e6db4bef1535b9de3 /app/Model
parentcbe52e57200a66522d88dfc5d5f46de8eb87ffb2 (diff)
Subtasks events refactoring and show delete in activity stream
Diffstat (limited to 'app/Model')
-rw-r--r--app/Model/NotificationModel.php5
-rw-r--r--app/Model/SubtaskModel.php22
2 files changed, 10 insertions, 17 deletions
diff --git a/app/Model/NotificationModel.php b/app/Model/NotificationModel.php
index df481fc7..ac8d9bae 100644
--- a/app/Model/NotificationModel.php
+++ b/app/Model/NotificationModel.php
@@ -70,6 +70,8 @@ class NotificationModel extends Base
return e('%s updated a subtask for the task #%d', $event_author, $event_data['task']['id']);
case SubtaskModel::EVENT_CREATE:
return e('%s created a subtask for the task #%d', $event_author, $event_data['task']['id']);
+ case SubtaskModel::EVENT_DELETE:
+ return e('%s removed a subtask for the task #%d', $event_author, $event_data['task']['id']);
case CommentModel::EVENT_UPDATE:
return e('%s updated a comment on the task #%d', $event_author, $event_data['task']['id']);
case CommentModel::EVENT_CREATE:
@@ -110,6 +112,8 @@ class NotificationModel extends Base
return e('New subtask on task #%d', $event_data['subtask']['task_id']);
case SubtaskModel::EVENT_UPDATE:
return e('Subtask updated on task #%d', $event_data['subtask']['task_id']);
+ case SubtaskModel::EVENT_DELETE:
+ return e('Subtask removed on task #%d', $event_data['subtask']['task_id']);
case TaskModel::EVENT_CREATE:
return e('New task #%d: %s', $event_data['task']['id'], $event_data['task']['title']);
case TaskModel::EVENT_UPDATE:
@@ -157,6 +161,7 @@ class NotificationModel extends Base
return $event_data['comment']['task_id'];
case SubtaskModel::EVENT_CREATE:
case SubtaskModel::EVENT_UPDATE:
+ case SubtaskModel::EVENT_DELETE:
return $event_data['subtask']['task_id'];
case TaskModel::EVENT_CREATE:
case TaskModel::EVENT_UPDATE:
diff --git a/app/Model/SubtaskModel.php b/app/Model/SubtaskModel.php
index a97bddbf..6dd1f26a 100644
--- a/app/Model/SubtaskModel.php
+++ b/app/Model/SubtaskModel.php
@@ -66,7 +66,7 @@ class SubtaskModel extends Base
->join(TaskModel::TABLE, 'id', 'task_id')
->findOneColumn(TaskModel::TABLE . '.project_id') ?: 0;
}
-
+
/**
* Get available status
*
@@ -235,10 +235,7 @@ class SubtaskModel extends Base
$subtask_id = $this->db->table(self::TABLE)->persist($values);
if ($subtask_id !== false) {
- $this->container['dispatcher']->dispatch(
- self::EVENT_CREATE,
- new SubtaskEvent(array('id' => $subtask_id) + $values)
- );
+ $this->queueManager->push($this->subtaskEventJob->withParams($subtask_id, self::EVENT_CREATE));
}
return $subtask_id;
@@ -255,13 +252,10 @@ class SubtaskModel extends Base
public function update(array $values, $fire_events = true)
{
$this->prepare($values);
- $subtask = $this->getById($values['id']);
$result = $this->db->table(self::TABLE)->eq('id', $values['id'])->save($values);
if ($result && $fire_events) {
- $event = $subtask;
- $event['changes'] = array_diff_assoc($values, $subtask);
- $this->container['dispatcher']->dispatch(self::EVENT_UPDATE, new SubtaskEvent($event));
+ $this->queueManager->push($this->subtaskEventJob->withParams($values['id'], self::EVENT_UPDATE, $values));
}
return $result;
@@ -377,14 +371,8 @@ class SubtaskModel extends Base
*/
public function remove($subtask_id)
{
- $subtask = $this->getById($subtask_id);
- $result = $this->db->table(self::TABLE)->eq('id', $subtask_id)->remove();
-
- if ($result) {
- $this->container['dispatcher']->dispatch(self::EVENT_DELETE, new SubtaskEvent($subtask));
- }
-
- return $result;
+ $this->subtaskEventJob->execute($subtask_id, self::EVENT_DELETE);
+ return $this->db->table(self::TABLE)->eq('id', $subtask_id)->remove();
}
/**