Add an automatic action to assign a color to a specific user
This commit is contained in:
parent
1cda8059b5
commit
66c7cf0caa
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
namespace Action;
|
||||
|
||||
require_once __DIR__.'/base.php';
|
||||
|
||||
class TaskAssignColorUser extends Base
|
||||
{
|
||||
public function __construct($project_id, \Model\Task $task)
|
||||
{
|
||||
parent::__construct($project_id);
|
||||
$this->task = $task;
|
||||
}
|
||||
|
||||
public function getActionRequiredParameters()
|
||||
{
|
||||
return array(
|
||||
'column_id' => t('Column'),
|
||||
'color_id' => t('Color'),
|
||||
'user_id' => t('Assignee'),
|
||||
);
|
||||
}
|
||||
|
||||
public function getEventRequiredParameters()
|
||||
{
|
||||
return array(
|
||||
'task_id',
|
||||
'owner_id',
|
||||
'column_id',
|
||||
);
|
||||
}
|
||||
|
||||
public function doAction(array $data)
|
||||
{
|
||||
if ($data['column_id'] == $this->getParam('column_id') && $data['owner_id'] == $this->getParam('user_id')) {
|
||||
|
||||
$this->task->update(array(
|
||||
'id' => $data['task_id'],
|
||||
'color_id' => $this->getParam('color_id'),
|
||||
));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -37,6 +37,7 @@ class Action extends Base
|
|||
'columns_list' => $this->board->getColumnsList($project['id']),
|
||||
'users_list' => $this->project->getUsersList($project['id'], false),
|
||||
'projects_list' => $this->project->getList(false),
|
||||
'colors_list' => $this->task->getColors(),
|
||||
'menu' => 'projects',
|
||||
'title' => t('Automatic actions')
|
||||
)));
|
||||
|
|
@ -66,6 +67,7 @@ class Action extends Base
|
|||
'columns_list' => $this->board->getColumnsList($project['id']),
|
||||
'users_list' => $this->project->getUsersList($project['id'], false),
|
||||
'projects_list' => $this->project->getList(false),
|
||||
'colors_list' => $this->task->getColors(),
|
||||
'project' => $project,
|
||||
'menu' => 'projects',
|
||||
'title' => t('Automatic actions')
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ return array(
|
|||
'Edit a task' => 'Modifier une tâche',
|
||||
'Column' => 'Colonne',
|
||||
'Color' => 'Couleur',
|
||||
'Assignee' => 'Personne assigné',
|
||||
'Assignee' => 'Personne assignée',
|
||||
'Create another task' => 'Créer une autre tâche',
|
||||
'New task' => 'Nouvelle tâche',
|
||||
'Open a task' => 'Ouvrir une tâche',
|
||||
|
|
@ -247,4 +247,5 @@ return array(
|
|||
'Task creation' => 'Création d\'une tâche',
|
||||
'Open a closed task' => 'Ouverture d\'une tâche fermée',
|
||||
'Closing a task' => 'Fermeture d\'une tâche',
|
||||
'Assign a color to a specific user' => 'Assigner une couleur à un utilisateur',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -250,4 +250,5 @@ return array(
|
|||
// 'Task creation' => '',
|
||||
// 'Open a closed task' => '',
|
||||
// 'Closing a task' => '',
|
||||
// 'Assign a color to a specific user' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ class Action extends Base
|
|||
'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'),
|
||||
'TaskAssignColorUser' => t('Assign a color to a specific user'),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -217,6 +218,10 @@ class Action extends Base
|
|||
require_once __DIR__.'/../actions/task_duplicate_another_project.php';
|
||||
$className = '\Action\TaskDuplicateAnotherProject';
|
||||
return new $className($project_id, new Task($this->db, $this->event));
|
||||
case 'TaskAssignColorUser':
|
||||
require_once __DIR__.'/../actions/task_assign_color_user.php';
|
||||
$className = '\Action\TaskAssignColorUser';
|
||||
return new $className($project_id, new Task($this->db, $this->event));
|
||||
default:
|
||||
throw new \LogicException('Action not found: '.$name);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@
|
|||
<?= Helper\in_list($param['value'], $users_list) ?>
|
||||
<?php elseif (Helper\contains($param['name'], 'project_id')): ?>
|
||||
<?= Helper\in_list($param['value'], $projects_list) ?>
|
||||
<?php elseif (Helper\contains($param['name'], 'color_id')): ?>
|
||||
<?= Helper\in_list($param['value'], $colors_list) ?>
|
||||
<?php endif ?>
|
||||
</strong>
|
||||
</li>
|
||||
|
|
|
|||
|
|
@ -25,8 +25,10 @@
|
|||
<?php elseif (Helper\contains($param_name, 'project_id')): ?>
|
||||
<?= Helper\form_label($param_desc, $param_name) ?>
|
||||
<?= Helper\form_select('params['.$param_name.']', $projects_list, $values) ?><br/>
|
||||
<?php elseif (Helper\contains($param_name, 'color_id')): ?>
|
||||
<?= Helper\form_label($param_desc, $param_name) ?>
|
||||
<?= Helper\form_select('params['.$param_name.']', $colors_list, $values) ?><br/>
|
||||
<?php endif ?>
|
||||
|
||||
<?php endforeach ?>
|
||||
|
||||
<div class="form-actions">
|
||||
|
|
|
|||
Loading…
Reference in New Issue