summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/Action/TaskAssignColorColumn.php1
-rw-r--r--app/Action/TaskUpdateStartDate.php83
-rw-r--r--app/Locale/da_DK/translations.php1
-rw-r--r--app/Locale/de_DE/translations.php1
-rw-r--r--app/Locale/es_ES/translations.php1
-rw-r--r--app/Locale/fi_FI/translations.php1
-rw-r--r--app/Locale/fr_FR/translations.php1
-rw-r--r--app/Locale/hu_HU/translations.php1
-rw-r--r--app/Locale/it_IT/translations.php1
-rw-r--r--app/Locale/ja_JP/translations.php1
-rw-r--r--app/Locale/nl_NL/translations.php1
-rw-r--r--app/Locale/pl_PL/translations.php1
-rw-r--r--app/Locale/pt_BR/translations.php1
-rw-r--r--app/Locale/ru_RU/translations.php1
-rw-r--r--app/Locale/sr_Latn_RS/translations.php1
-rw-r--r--app/Locale/sv_SE/translations.php1
-rw-r--r--app/Locale/th_TH/translations.php1
-rw-r--r--app/Locale/tr_TR/translations.php1
-rw-r--r--app/Locale/zh_CN/translations.php1
-rw-r--r--app/Model/Action.php1
-rw-r--r--docs/automatic-actions.markdown21
-rw-r--r--tests/units/ActionTaskUpdateStartDateTest.php46
22 files changed, 162 insertions, 7 deletions
diff --git a/app/Action/TaskAssignColorColumn.php b/app/Action/TaskAssignColorColumn.php
index 2d10b776..ee1d66ae 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 00000000..4cd50c9a
--- /dev/null
+++ b/app/Action/TaskUpdateStartDate.php
@@ -0,0 +1,83 @@
+<?php
+
+namespace Action;
+
+use Model\Task;
+
+/**
+ * Set the start date of task
+ *
+ * @package action
+ * @author Frederic Guillot
+ */
+class TaskUpdateStartDate extends Base
+{
+ /**
+ * Get the list of compatible events
+ *
+ * @access public
+ * @return array
+ */
+ public function getCompatibleEvents()
+ {
+ return array(
+ Task::EVENT_MOVE_COLUMN,
+ );
+ }
+
+ /**
+ * Get the required parameter for the action (defined by the user)
+ *
+ * @access public
+ * @return array
+ */
+ public function getActionRequiredParameters()
+ {
+ return array(
+ 'column_id' => 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 0815440f..2fba9478 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 c859d433..5f52a850 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 6f30046c..efe6150f 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 efd7eb6d..6bbba02e 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 e50bf1b3..6abca0ea 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 7f0280a8..d3a8628d 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 3f2f5f76..94bf4a5a 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 57ba3abb..18cf9d72 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 f3f2e72b..88c55155 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 cb24b60b..4a237f14 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 652dc80e..d8b7a7c6 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 354c6a5b..b0b2b09f 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 a43fe57b..20defd6d 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 8c7229f4..8c1ad094 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 3066e798..ecd9413c 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 e5011905..e18341e9 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 c6186145..0784cedb 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 4489bca7..3e8aa091 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 e90a5e5d..f99212d6 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 00000000..da36551d
--- /dev/null
+++ b/tests/units/ActionTaskUpdateStartDateTest.php
@@ -0,0 +1,46 @@
+<?php
+
+require_once __DIR__.'/Base.php';
+
+use Event\GenericEvent;
+use Model\Task;
+use Model\TaskCreation;
+use Model\TaskFinder;
+use Model\Project;
+use Integration\GithubWebhook;
+
+class ActionTaskUpdateStartDateTest extends Base
+{
+ public function testExecute()
+ {
+ $action = new Action\TaskUpdateStartDate($this->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);
+ }
+}