From d5c95e8240639975f61f726e9722900a8d54611f Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Wed, 4 May 2016 22:52:08 -0400 Subject: Added automated action to change task color based on the priority --- app/Action/TaskAssignColorPriority.php | 95 ++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 app/Action/TaskAssignColorPriority.php (limited to 'app/Action/TaskAssignColorPriority.php') diff --git a/app/Action/TaskAssignColorPriority.php b/app/Action/TaskAssignColorPriority.php new file mode 100644 index 00000000..2e24f9ef --- /dev/null +++ b/app/Action/TaskAssignColorPriority.php @@ -0,0 +1,95 @@ + t('Color'), + 'priority' => t('Priority'), + ); + } + + /** + * Get the required parameter for the event + * + * @access public + * @return string[] + */ + public function getEventRequiredParameters() + { + return array( + 'task_id', + 'priority', + ); + } + + /** + * Execute the action (change the task color) + * + * @access public + * @param array $data Event data dictionary + * @return bool True if the action was executed or false when not executed + */ + public function doAction(array $data) + { + $values = array( + 'id' => $data['task_id'], + 'color_id' => $this->getParam('color_id'), + ); + + return $this->taskModification->update($values, false); + } + + /** + * Check if the event data meet the action condition + * + * @access public + * @param array $data Event data dictionary + * @return bool + */ + public function hasRequiredCondition(array $data) + { + return $data['priority'] == $this->getParam('priority'); + } +} -- cgit v1.2.3