Subtasks events refactoring and show delete in activity stream
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user