diff --git a/app/Action/TaskAssignColorColumn.php b/app/Action/TaskAssignColorColumn.php index 2d10b776c..ee1d66ae5 100644 --- a/app/Action/TaskAssignColorColumn.php +++ b/app/Action/TaskAssignColorColumn.php @@ -8,6 +8,7 @@ use Model\Task; * Assign a color to a task * * @package action + * @author Frederic Guillot */ class TaskAssignColorColumn extends Base { diff --git a/app/Action/TaskUpdateStartDate.php b/app/Action/TaskUpdateStartDate.php new file mode 100644 index 000000000..4cd50c9ad --- /dev/null +++ b/app/Action/TaskUpdateStartDate.php @@ -0,0 +1,83 @@ + t('Column'), + ); + } + + /** + * Get the required parameter for the event + * + * @access public + * @return string[] + */ + public function getEventRequiredParameters() + { + return array( + 'task_id', + 'column_id', + ); + } + + /** + * Execute the action (set 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'], + 'date_started' => time(), + ); + + return $this->taskModification->update($values); + } + + /** + * 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['column_id'] == $this->getParam('column_id'); + } +} diff --git a/app/Locale/da_DK/translations.php b/app/Locale/da_DK/translations.php index 0815440f9..2fba9478d 100644 --- a/app/Locale/da_DK/translations.php +++ b/app/Locale/da_DK/translations.php @@ -916,4 +916,5 @@ return array( // 'Show tasks based on the start date' => '', // 'Subtasks time tracking' => '', // 'User calendar view' => '', + // 'Automatically update the start date' => '', ); diff --git a/app/Locale/de_DE/translations.php b/app/Locale/de_DE/translations.php index c859d4334..5f52a850e 100644 --- a/app/Locale/de_DE/translations.php +++ b/app/Locale/de_DE/translations.php @@ -916,4 +916,5 @@ return array( // 'Show tasks based on the start date' => '', // 'Subtasks time tracking' => '', // 'User calendar view' => '', + // 'Automatically update the start date' => '', ); diff --git a/app/Locale/es_ES/translations.php b/app/Locale/es_ES/translations.php index 6f30046c3..efe6150f1 100644 --- a/app/Locale/es_ES/translations.php +++ b/app/Locale/es_ES/translations.php @@ -916,4 +916,5 @@ return array( // 'Show tasks based on the start date' => '', // 'Subtasks time tracking' => '', // 'User calendar view' => '', + // 'Automatically update the start date' => '', ); diff --git a/app/Locale/fi_FI/translations.php b/app/Locale/fi_FI/translations.php index efd7eb6d6..6bbba02e1 100644 --- a/app/Locale/fi_FI/translations.php +++ b/app/Locale/fi_FI/translations.php @@ -916,4 +916,5 @@ return array( // 'Show tasks based on the start date' => '', // 'Subtasks time tracking' => '', // 'User calendar view' => '', + // 'Automatically update the start date' => '', ); diff --git a/app/Locale/fr_FR/translations.php b/app/Locale/fr_FR/translations.php index e50bf1b34..6abca0ea5 100644 --- a/app/Locale/fr_FR/translations.php +++ b/app/Locale/fr_FR/translations.php @@ -918,4 +918,5 @@ return array( 'Show tasks based on the start date' => 'Afficher les tâches en fonction de la date de début', 'Subtasks time tracking' => 'Suivi du temps par rapport aux sous-tâches', 'User calendar view' => 'Vue en mode utilisateur du calendrier', + 'Automatically update the start date' => 'Mettre à jour automatiquement la date de début', ); diff --git a/app/Locale/hu_HU/translations.php b/app/Locale/hu_HU/translations.php index 7f0280a81..d3a8628d3 100644 --- a/app/Locale/hu_HU/translations.php +++ b/app/Locale/hu_HU/translations.php @@ -916,4 +916,5 @@ return array( // 'Show tasks based on the start date' => '', // 'Subtasks time tracking' => '', // 'User calendar view' => '', + // 'Automatically update the start date' => '', ); diff --git a/app/Locale/it_IT/translations.php b/app/Locale/it_IT/translations.php index 3f2f5f76c..94bf4a5a8 100644 --- a/app/Locale/it_IT/translations.php +++ b/app/Locale/it_IT/translations.php @@ -916,4 +916,5 @@ return array( // 'Show tasks based on the start date' => '', // 'Subtasks time tracking' => '', // 'User calendar view' => '', + // 'Automatically update the start date' => '', ); diff --git a/app/Locale/ja_JP/translations.php b/app/Locale/ja_JP/translations.php index 57ba3abb1..18cf9d724 100644 --- a/app/Locale/ja_JP/translations.php +++ b/app/Locale/ja_JP/translations.php @@ -916,4 +916,5 @@ return array( // 'Show tasks based on the start date' => '', // 'Subtasks time tracking' => '', // 'User calendar view' => '', + // 'Automatically update the start date' => '', ); diff --git a/app/Locale/nl_NL/translations.php b/app/Locale/nl_NL/translations.php index f3f2e72bf..88c55155e 100644 --- a/app/Locale/nl_NL/translations.php +++ b/app/Locale/nl_NL/translations.php @@ -916,4 +916,5 @@ return array( // 'Show tasks based on the start date' => '', // 'Subtasks time tracking' => '', // 'User calendar view' => '', + // 'Automatically update the start date' => '', ); diff --git a/app/Locale/pl_PL/translations.php b/app/Locale/pl_PL/translations.php index cb24b60b7..4a237f14c 100644 --- a/app/Locale/pl_PL/translations.php +++ b/app/Locale/pl_PL/translations.php @@ -916,4 +916,5 @@ return array( // 'Show tasks based on the start date' => '', // 'Subtasks time tracking' => '', // 'User calendar view' => '', + // 'Automatically update the start date' => '', ); diff --git a/app/Locale/pt_BR/translations.php b/app/Locale/pt_BR/translations.php index 652dc80ea..d8b7a7c64 100644 --- a/app/Locale/pt_BR/translations.php +++ b/app/Locale/pt_BR/translations.php @@ -916,4 +916,5 @@ return array( // 'Show tasks based on the start date' => '', // 'Subtasks time tracking' => '', // 'User calendar view' => '', + // 'Automatically update the start date' => '', ); diff --git a/app/Locale/ru_RU/translations.php b/app/Locale/ru_RU/translations.php index 354c6a5bb..b0b2b09f7 100644 --- a/app/Locale/ru_RU/translations.php +++ b/app/Locale/ru_RU/translations.php @@ -916,4 +916,5 @@ return array( // 'Show tasks based on the start date' => '', // 'Subtasks time tracking' => '', // 'User calendar view' => '', + // 'Automatically update the start date' => '', ); diff --git a/app/Locale/sr_Latn_RS/translations.php b/app/Locale/sr_Latn_RS/translations.php index a43fe57be..20defd6d1 100644 --- a/app/Locale/sr_Latn_RS/translations.php +++ b/app/Locale/sr_Latn_RS/translations.php @@ -916,4 +916,5 @@ return array( // 'Show tasks based on the start date' => '', // 'Subtasks time tracking' => '', // 'User calendar view' => '', + // 'Automatically update the start date' => '', ); diff --git a/app/Locale/sv_SE/translations.php b/app/Locale/sv_SE/translations.php index 8c7229f48..8c1ad094f 100644 --- a/app/Locale/sv_SE/translations.php +++ b/app/Locale/sv_SE/translations.php @@ -916,4 +916,5 @@ return array( // 'Show tasks based on the start date' => '', // 'Subtasks time tracking' => '', // 'User calendar view' => '', + // 'Automatically update the start date' => '', ); diff --git a/app/Locale/th_TH/translations.php b/app/Locale/th_TH/translations.php index 3066e7980..ecd9413c7 100644 --- a/app/Locale/th_TH/translations.php +++ b/app/Locale/th_TH/translations.php @@ -916,4 +916,5 @@ return array( // 'Show tasks based on the start date' => '', // 'Subtasks time tracking' => '', // 'User calendar view' => '', + // 'Automatically update the start date' => '', ); diff --git a/app/Locale/tr_TR/translations.php b/app/Locale/tr_TR/translations.php index e5011905b..e18341e9a 100644 --- a/app/Locale/tr_TR/translations.php +++ b/app/Locale/tr_TR/translations.php @@ -916,4 +916,5 @@ return array( // 'Show tasks based on the start date' => '', // 'Subtasks time tracking' => '', // 'User calendar view' => '', + // 'Automatically update the start date' => '', ); diff --git a/app/Locale/zh_CN/translations.php b/app/Locale/zh_CN/translations.php index c61861456..0784cedb6 100644 --- a/app/Locale/zh_CN/translations.php +++ b/app/Locale/zh_CN/translations.php @@ -916,4 +916,5 @@ return array( // 'Show tasks based on the start date' => '', // 'Subtasks time tracking' => '', // 'User calendar view' => '', + // 'Automatically update the start date' => '', ); diff --git a/app/Model/Action.php b/app/Model/Action.php index 4489bca74..3e8aa0915 100644 --- a/app/Model/Action.php +++ b/app/Model/Action.php @@ -56,6 +56,7 @@ class Action extends Base 'TaskLogMoveAnotherColumn' => t('Add a comment logging moving the task between columns'), 'TaskAssignUser' => t('Change the assignee based on an external username'), 'TaskAssignCategoryLabel' => t('Change the category based on an external label'), + 'TaskUpdateStartDate' => t('Automatically update the start date'), ); asort($values); diff --git a/docs/automatic-actions.markdown b/docs/automatic-actions.markdown index e90a5e5d3..f99212d64 100644 --- a/docs/automatic-actions.markdown +++ b/docs/automatic-actions.markdown @@ -63,6 +63,7 @@ List of available actions - Change the assignee based on an external username - Change the category based on an external label - Create a comment from an external provider +- Automatically update the start date Examples -------- @@ -71,46 +72,52 @@ Here are some examples used in the real life: ### When I move a task to the column "Done", automatically close this task -- Choose the event: **Move a task to another column** - Choose the action: **Close the task** +- Choose the event: **Move a task to another column** - Define the action parameter: **Column = Done** (this is the destination column) ### When I move a task to the column "To be validated", assign this task to a specific user -- Choose the event: **Move a task to another column** - Choose the action: **Assign the task to a specific user** +- Choose the event: **Move a task to another column** - Define the action parameters: **Column = To be validated** and **User = Bob** (Bob is our tester) ### When I move a task to the column "Work in progress", assign this task to the current user -- Choose the event: **Move a task to another column** - Choose the action: **Assign the task to the person who does the action** +- Choose the event: **Move a task to another column** - Define the action parameter: **Column = Work in progress** ### When a task is completed, duplicate this task to another project Let's say we have two projects "Customer orders" and "Production", once the order is validated, swap it to the "Production" project. -- Choose the event: **Closing a task** - Choose the action: **Duplicate the task to another project** +- Choose the event: **Closing a task** - Define the action parameters: **Column = Validated** and **Project = Production** ### When a task is moved to the last column, move the exact same task to another project Let's say we have two projects "Ideas" and "Development", once the idea is validated, swap it to the "Development" project. -- Choose the event: **Move a task to another column** - Choose the action: **Move the task to another project** +- Choose the event: **Move a task to another column** - Define the action parameters: **Column = Validated** and **Project = Development** ### I want to assign automatically a color to the user Bob -- Choose the event: **Task assignee change** - Choose the action: **Assign a color to a specific user** +- Choose the event: **Task assignee change** - Define the action parameters: **Color = Green** and **Assignee = Bob** ### I want to assign automatically a color to the defined category "Feature Request" -- Choose the event: **Task creation or modification** - Choose the action: **Assign automatically a color based on a category** +- Choose the event: **Task creation or modification** - Define the action parameters: **Color = Blue** and **Category = Feature Request** + +### I want to set the start date automatically when the task is moved to the column "Work in progress" + +- Choose the action: **Automatically update the start date** +- Choose the event: **Move a task to another column** +- Define the action parameters: **Column = Work in progress** diff --git a/tests/units/ActionTaskUpdateStartDateTest.php b/tests/units/ActionTaskUpdateStartDateTest.php new file mode 100644 index 000000000..da36551d4 --- /dev/null +++ b/tests/units/ActionTaskUpdateStartDateTest.php @@ -0,0 +1,46 @@ +container, 1, Task::EVENT_MOVE_COLUMN); + $action->setParam('column_id', 2); + + // We create a task in the first column + $tc = new TaskCreation($this->container); + $tf = new TaskFinder($this->container); + $p = new Project($this->container); + $this->assertEquals(1, $p->create(array('name' => 'test'))); + $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1))); + + // The start date must be empty + $task = $tf->getById(1); + $this->assertNotEmpty($task); + $this->assertEmpty($task['date_started']); + + // We create an event to move the task to the 2nd column + $event = array( + 'project_id' => 1, + 'task_id' => 1, + 'column_id' => 2, + ); + + // Our event should be executed + $this->assertTrue($action->execute(new GenericEvent($event))); + + // Our task should be closed + $task = $tf->getById(1); + $this->assertNotEmpty($task); + $this->assertEquals(time(), $task['date_started'], '', 2); + } +}