From a264a53e3b07d0669c1283d5c54c9b3919239449 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Fri, 3 Apr 2015 18:56:05 -0400 Subject: Rename action TaskAssignColor to TaskAssignColorColumn --- app/Action/TaskAssignColor.php | 83 ------------------------- app/Action/TaskAssignColorColumn.php | 83 +++++++++++++++++++++++++ app/Locale/da_DK/translations.php | 1 + app/Locale/de_DE/translations.php | 1 + app/Locale/es_ES/translations.php | 1 + app/Locale/fi_FI/translations.php | 1 + app/Locale/fr_FR/translations.php | 1 + app/Locale/hu_HU/translations.php | 1 + app/Locale/it_IT/translations.php | 1 + app/Locale/ja_JP/translations.php | 1 + app/Locale/nl_NL/translations.php | 1 + app/Locale/pl_PL/translations.php | 1 + app/Locale/pt_BR/translations.php | 1 + app/Locale/ru_RU/translations.php | 1 + app/Locale/sr_Latn_RS/translations.php | 1 + app/Locale/sv_SE/translations.php | 1 + app/Locale/th_TH/translations.php | 1 + app/Locale/tr_TR/translations.php | 1 + app/Locale/zh_CN/translations.php | 1 + app/Model/Action.php | 2 +- docs/api-json-rpc.markdown | 2 +- tests/units/ActionTaskAssignColorColumnTest.php | 41 ++++++++++++ tests/units/ActionTaskAssignColorTest.php | 41 ------------ 23 files changed, 143 insertions(+), 126 deletions(-) delete mode 100644 app/Action/TaskAssignColor.php create mode 100644 app/Action/TaskAssignColorColumn.php create mode 100644 tests/units/ActionTaskAssignColorColumnTest.php delete mode 100644 tests/units/ActionTaskAssignColorTest.php diff --git a/app/Action/TaskAssignColor.php b/app/Action/TaskAssignColor.php deleted file mode 100644 index b1da17e9..00000000 --- a/app/Action/TaskAssignColor.php +++ /dev/null @@ -1,83 +0,0 @@ - t('Column'), - 'color_id' => t('Color'), - ); - } - - /** - * 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'], - 'color_id' => $this->getParam('color_id'), - ); - - 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/Action/TaskAssignColorColumn.php b/app/Action/TaskAssignColorColumn.php new file mode 100644 index 00000000..2d10b776 --- /dev/null +++ b/app/Action/TaskAssignColorColumn.php @@ -0,0 +1,83 @@ + t('Column'), + 'color_id' => t('Color'), + ); + } + + /** + * 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'], + 'color_id' => $this->getParam('color_id'), + ); + + 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 51397129..b8417071 100644 --- a/app/Locale/da_DK/translations.php +++ b/app/Locale/da_DK/translations.php @@ -845,4 +845,5 @@ return array( // 'Check my code' => '', // 'Secret key: ' => '', // 'Test your device' => '', + // 'Assign a color when the task is moved to a specific column' => '', ); diff --git a/app/Locale/de_DE/translations.php b/app/Locale/de_DE/translations.php index 82319766..12d5bda8 100644 --- a/app/Locale/de_DE/translations.php +++ b/app/Locale/de_DE/translations.php @@ -845,4 +845,5 @@ return array( // 'Check my code' => '', // 'Secret key: ' => '', // 'Test your device' => '', + // 'Assign a color when the task is moved to a specific column' => '', ); diff --git a/app/Locale/es_ES/translations.php b/app/Locale/es_ES/translations.php index 4fa07781..0ce50bce 100644 --- a/app/Locale/es_ES/translations.php +++ b/app/Locale/es_ES/translations.php @@ -845,4 +845,5 @@ return array( // 'Check my code' => '', // 'Secret key: ' => '', // 'Test your device' => '', + // 'Assign a color when the task is moved to a specific column' => '', ); diff --git a/app/Locale/fi_FI/translations.php b/app/Locale/fi_FI/translations.php index 239d5a51..9673c380 100644 --- a/app/Locale/fi_FI/translations.php +++ b/app/Locale/fi_FI/translations.php @@ -845,4 +845,5 @@ return array( // 'Check my code' => '', // 'Secret key: ' => '', // 'Test your device' => '', + // 'Assign a color when the task is moved to a specific column' => '', ); diff --git a/app/Locale/fr_FR/translations.php b/app/Locale/fr_FR/translations.php index 7cca5aa6..013e7739 100644 --- a/app/Locale/fr_FR/translations.php +++ b/app/Locale/fr_FR/translations.php @@ -847,4 +847,5 @@ return array( 'Check my code' => 'Vérifier mon code', 'Secret key: ' => 'Clé secrète : ', 'Test your device' => 'Testez votre appareil', + 'Assign a color when the task is moved to a specific column' => 'Assigner une couleur lorsque la tâche est déplacée dans une colonne spécifique', ); diff --git a/app/Locale/hu_HU/translations.php b/app/Locale/hu_HU/translations.php index af5c8cb7..50c09eef 100644 --- a/app/Locale/hu_HU/translations.php +++ b/app/Locale/hu_HU/translations.php @@ -845,4 +845,5 @@ return array( // 'Check my code' => '', // 'Secret key: ' => '', // 'Test your device' => '', + // 'Assign a color when the task is moved to a specific column' => '', ); diff --git a/app/Locale/it_IT/translations.php b/app/Locale/it_IT/translations.php index b4cdf9f0..8b9e2742 100644 --- a/app/Locale/it_IT/translations.php +++ b/app/Locale/it_IT/translations.php @@ -845,4 +845,5 @@ return array( // 'Check my code' => '', // 'Secret key: ' => '', // 'Test your device' => '', + // 'Assign a color when the task is moved to a specific column' => '', ); diff --git a/app/Locale/ja_JP/translations.php b/app/Locale/ja_JP/translations.php index ff563073..f1f8bff8 100644 --- a/app/Locale/ja_JP/translations.php +++ b/app/Locale/ja_JP/translations.php @@ -845,4 +845,5 @@ return array( // 'Check my code' => '', // 'Secret key: ' => '', // 'Test your device' => '', + // 'Assign a color when the task is moved to a specific column' => '', ); diff --git a/app/Locale/nl_NL/translations.php b/app/Locale/nl_NL/translations.php index eba573d2..55d1fd99 100644 --- a/app/Locale/nl_NL/translations.php +++ b/app/Locale/nl_NL/translations.php @@ -845,4 +845,5 @@ return array( // 'Check my code' => '', // 'Secret key: ' => '', // 'Test your device' => '', + // 'Assign a color when the task is moved to a specific column' => '', ); diff --git a/app/Locale/pl_PL/translations.php b/app/Locale/pl_PL/translations.php index bad64238..bf2364c0 100644 --- a/app/Locale/pl_PL/translations.php +++ b/app/Locale/pl_PL/translations.php @@ -845,4 +845,5 @@ return array( // 'Check my code' => '', // 'Secret key: ' => '', // 'Test your device' => '', + // 'Assign a color when the task is moved to a specific column' => '', ); diff --git a/app/Locale/pt_BR/translations.php b/app/Locale/pt_BR/translations.php index 787aa2d0..025aaa52 100644 --- a/app/Locale/pt_BR/translations.php +++ b/app/Locale/pt_BR/translations.php @@ -845,4 +845,5 @@ return array( // 'Check my code' => '', // 'Secret key: ' => '', // 'Test your device' => '', + // 'Assign a color when the task is moved to a specific column' => '', ); diff --git a/app/Locale/ru_RU/translations.php b/app/Locale/ru_RU/translations.php index bcf216cc..754af11a 100644 --- a/app/Locale/ru_RU/translations.php +++ b/app/Locale/ru_RU/translations.php @@ -845,4 +845,5 @@ return array( // 'Check my code' => '', // 'Secret key: ' => '', // 'Test your device' => '', + // 'Assign a color when the task is moved to a specific column' => '', ); diff --git a/app/Locale/sr_Latn_RS/translations.php b/app/Locale/sr_Latn_RS/translations.php index 0229a030..77460766 100644 --- a/app/Locale/sr_Latn_RS/translations.php +++ b/app/Locale/sr_Latn_RS/translations.php @@ -845,4 +845,5 @@ return array( // 'Check my code' => '', // 'Secret key: ' => '', // 'Test your device' => '', + // 'Assign a color when the task is moved to a specific column' => '', ); diff --git a/app/Locale/sv_SE/translations.php b/app/Locale/sv_SE/translations.php index 3e52818b..8ae8702f 100644 --- a/app/Locale/sv_SE/translations.php +++ b/app/Locale/sv_SE/translations.php @@ -845,4 +845,5 @@ return array( // 'Check my code' => '', // 'Secret key: ' => '', // 'Test your device' => '', + // 'Assign a color when the task is moved to a specific column' => '', ); diff --git a/app/Locale/th_TH/translations.php b/app/Locale/th_TH/translations.php index 400c0c26..c2be430b 100644 --- a/app/Locale/th_TH/translations.php +++ b/app/Locale/th_TH/translations.php @@ -845,4 +845,5 @@ return array( // 'Check my code' => '', // 'Secret key: ' => '', // 'Test your device' => '', + // 'Assign a color when the task is moved to a specific column' => '', ); diff --git a/app/Locale/tr_TR/translations.php b/app/Locale/tr_TR/translations.php index 0f8a2802..617e8269 100644 --- a/app/Locale/tr_TR/translations.php +++ b/app/Locale/tr_TR/translations.php @@ -845,4 +845,5 @@ return array( // 'Check my code' => '', // 'Secret key: ' => '', // 'Test your device' => '', + // 'Assign a color when the task is moved to a specific column' => '', ); diff --git a/app/Locale/zh_CN/translations.php b/app/Locale/zh_CN/translations.php index 5f3eacf0..e48dbe14 100644 --- a/app/Locale/zh_CN/translations.php +++ b/app/Locale/zh_CN/translations.php @@ -845,4 +845,5 @@ return array( // 'Check my code' => '', // 'Secret key: ' => '', // 'Test your device' => '', + // 'Assign a color when the task is moved to a specific column' => '', ); diff --git a/app/Model/Action.php b/app/Model/Action.php index 91bd9608..4489bca7 100644 --- a/app/Model/Action.php +++ b/app/Model/Action.php @@ -41,13 +41,13 @@ class Action extends Base $values = array( 'TaskClose' => t('Close a task'), 'TaskOpen' => t('Open a task'), - 'TaskAssignColor' => t('Assign a color to a task'), 'TaskAssignSpecificUser' => t('Assign the task to a specific user'), 'TaskAssignCurrentUser' => t('Assign the task to the person who does the action'), 'TaskDuplicateAnotherProject' => t('Duplicate the task to another project'), 'TaskMoveAnotherProject' => t('Move the task to another project'), 'TaskMoveColumnAssigned' => t('Move the task to another column when assigned to a user'), 'TaskMoveColumnUnAssigned' => t('Move the task to another column when assignee is cleared'), + 'TaskAssignColorColumn' => t('Assign a color when the task is moved to a specific column'), 'TaskAssignColorUser' => t('Assign a color to a specific user'), 'TaskAssignColorCategory' => t('Assign automatically a color based on a category'), 'TaskAssignCategoryColor' => t('Assign automatically a category based on a color'), diff --git a/docs/api-json-rpc.markdown b/docs/api-json-rpc.markdown index 3c02e818..e7f5a6b6 100644 --- a/docs/api-json-rpc.markdown +++ b/docs/api-json-rpc.markdown @@ -1390,7 +1390,7 @@ Response example: "id": 1433237746, "result": { "TaskLogMoveAnotherColumn" : "Add a comment logging moving the task between columns", - "TaskAssignColor" : "Assign a color to a task", + "TaskAssignColorColumn" : "Assign a color when the task is moved to a specific column", "TaskAssignColorUser" : "Assign a color to a specific user", "TaskAssignCategoryColor" : "Assign automatically a category based on a color", "TaskAssignColorCategory" : "Assign automatically a color based on a category", diff --git a/tests/units/ActionTaskAssignColorColumnTest.php b/tests/units/ActionTaskAssignColorColumnTest.php new file mode 100644 index 00000000..363bb05c --- /dev/null +++ b/tests/units/ActionTaskAssignColorColumnTest.php @@ -0,0 +1,41 @@ +container, 1, Task::EVENT_MOVE_COLUMN); + $action->setParam('column_id', 2); + $action->setParam('color_id', 'green'); + + // 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, 'color_id' => 'yellow'))); + + $event = array( + 'project_id' => 1, + 'task_id' => 1, + 'column_id' => 2, + 'color_id' => 'green', + ); + + // Our event should be executed + $this->assertTrue($action->execute(new GenericEvent($event))); + + // Our task should have color green + $task = $tf->getById(1); + $this->assertEquals('green', $task['color_id']); + } +} diff --git a/tests/units/ActionTaskAssignColorTest.php b/tests/units/ActionTaskAssignColorTest.php deleted file mode 100644 index 4d2ea70a..00000000 --- a/tests/units/ActionTaskAssignColorTest.php +++ /dev/null @@ -1,41 +0,0 @@ -container, 1, Task::EVENT_MOVE_COLUMN); - $action->setParam('column_id', 2); - $action->setParam('color_id', 'green'); - - // 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, 'color_id' => 'yellow'))); - - $event = array( - 'project_id' => 1, - 'task_id' => 1, - 'column_id' => 2, - 'color_id' => 'green', - ); - - // Our event should be executed - $this->assertTrue($action->execute(new GenericEvent($event))); - - // Our task should have color green - $task = $tf->getById(1); - $this->assertEquals('green', $task['color_id']); - } -} -- cgit v1.2.3