From d3d55224329681722b52a84b31f141bf78aaa134 Mon Sep 17 00:00:00 2001 From: renothing <261274+renothing@users.noreply.github.com> Date: Tue, 9 Jul 2019 10:48:24 +0800 Subject: Automatically update the start date when a task move away from a column --- app/Action/TaskUpdateStartDateOnMoveColumn.php | 96 ++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 app/Action/TaskUpdateStartDateOnMoveColumn.php (limited to 'app/Action/TaskUpdateStartDateOnMoveColumn.php') diff --git a/app/Action/TaskUpdateStartDateOnMoveColumn.php b/app/Action/TaskUpdateStartDateOnMoveColumn.php new file mode 100644 index 00000000..8a00bbab --- /dev/null +++ b/app/Action/TaskUpdateStartDateOnMoveColumn.php @@ -0,0 +1,96 @@ + t('Column'), + ); + } + + /** + * Get the required parameter for the event + * + * @access public + * @return string[] + */ + public function getEventRequiredParameters() + { + return array( + 'task_id', + 'task' => array( + 'project_id', + 'column_id', + ), + ); + } + + /** + * Execute the action (set the task date_started) + * + * @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'], + 'date_started' => time(), + ); + + return $this->taskModificationModel->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 empty($data['task']['date_started']) && $data['task']['column_id'] != $this->getParam('column_id'); + } +} -- cgit v1.2.3