Avoid automatic actions that change the color to fire subsequent events

This commit is contained in:
Frederic Guillot
2016-01-17 14:56:31 -05:00
parent 1259e911e4
commit e94c4cab7f
10 changed files with 34 additions and 20 deletions

View File

@@ -88,6 +88,9 @@ class TaskCreation extends Base
{
$event = new TaskEvent(array('task_id' => $task_id) + $values);
$this->logger->debug('Event fired: '.Task::EVENT_CREATE_UPDATE);
$this->logger->debug('Event fired: '.Task::EVENT_CREATE);
$this->dispatcher->dispatch(Task::EVENT_CREATE_UPDATE, $event);
$this->dispatcher->dispatch(Task::EVENT_CREATE, $event);

View File

@@ -17,16 +17,17 @@ class TaskModification extends Base
*
* @access public
* @param array $values
* @param boolean $fire_events
* @return boolean
*/
public function update(array $values)
public function update(array $values, $fire_events = true)
{
$original_task = $this->taskFinder->getById($values['id']);
$this->prepare($values);
$result = $this->db->table(Task::TABLE)->eq('id', $original_task['id'])->update($values);
if ($result) {
if ($fire_events && $result) {
$this->fireEvents($original_task, $values);
}
@@ -57,7 +58,8 @@ class TaskModification extends Base
}
foreach ($events as $event) {
$this->container['dispatcher']->dispatch($event, new TaskEvent($event_data));
$this->logger->debug('Event fired: '.$event);
$this->dispatcher->dispatch($event, new TaskEvent($event_data));
}
}

View File

@@ -177,11 +177,14 @@ class TaskPosition extends Base
);
if ($task['swimlane_id'] != $new_swimlane_id) {
$this->container['dispatcher']->dispatch(Task::EVENT_MOVE_SWIMLANE, new TaskEvent($event_data));
$this->logger->debug('Event fired: '.Task::EVENT_MOVE_SWIMLANE);
$this->dispatcher->dispatch(Task::EVENT_MOVE_SWIMLANE, new TaskEvent($event_data));
} elseif ($task['column_id'] != $new_column_id) {
$this->container['dispatcher']->dispatch(Task::EVENT_MOVE_COLUMN, new TaskEvent($event_data));
$this->logger->debug('Event fired: '.Task::EVENT_MOVE_COLUMN);
$this->dispatcher->dispatch(Task::EVENT_MOVE_COLUMN, new TaskEvent($event_data));
} elseif ($task['position'] != $new_position) {
$this->container['dispatcher']->dispatch(Task::EVENT_MOVE_POSITION, new TaskEvent($event_data));
$this->logger->debug('Event fired: '.Task::EVENT_MOVE_POSITION);
$this->dispatcher->dispatch(Task::EVENT_MOVE_POSITION, new TaskEvent($event_data));
}
}
}

View File

@@ -113,10 +113,8 @@ class TaskStatus extends Base
));
if ($result) {
$this->container['dispatcher']->dispatch(
$event,
new TaskEvent(array('task_id' => $task_id) + $this->taskFinder->getById($task_id))
);
$this->logger->debug('Event fired: '.$event);
$this->dispatcher->dispatch($event, new TaskEvent(array('task_id' => $task_id) + $this->taskFinder->getById($task_id)));
}
return $result;