Add new automated action to change task color based on the task link
This commit is contained in:
parent
fd60964c23
commit
cd9bc86fbe
|
|
@ -13,6 +13,7 @@ New features:
|
||||||
* Add config parameter to define session duration
|
* Add config parameter to define session duration
|
||||||
* Add config parameter to disable/enable RememberMe authentication
|
* Add config parameter to disable/enable RememberMe authentication
|
||||||
* Add start/end date for projects
|
* Add start/end date for projects
|
||||||
|
* Add new automated action to change task color based on the task link
|
||||||
* Add Portuguese (European) translation
|
* Add Portuguese (European) translation
|
||||||
* Add Norwegian translation
|
* Add Norwegian translation
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,84 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Action;
|
||||||
|
|
||||||
|
use Model\TaskLink;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assign a color to a specific task link
|
||||||
|
*
|
||||||
|
* @package action
|
||||||
|
* @author Frederic Guillot
|
||||||
|
*/
|
||||||
|
class TaskAssignColorLink extends Base
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the list of compatible events
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getCompatibleEvents()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
TaskLink::EVENT_CREATE_UPDATE,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the required parameter for the action (defined by the user)
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getActionRequiredParameters()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'color_id' => t('Color'),
|
||||||
|
'link_id' => t('Link type'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the required parameter for the event
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
|
public function getEventRequiredParameters()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'task_id',
|
||||||
|
'link_id',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the action (change 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['link_id'] == $this->getParam('link_id');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -31,6 +31,7 @@ class Action extends Base
|
||||||
'projects_list' => $this->project->getList(false),
|
'projects_list' => $this->project->getList(false),
|
||||||
'colors_list' => $this->color->getList(),
|
'colors_list' => $this->color->getList(),
|
||||||
'categories_list' => $this->category->getList($project['id']),
|
'categories_list' => $this->category->getList($project['id']),
|
||||||
|
'links_list' => $this->link->getList(0, false),
|
||||||
'title' => t('Automatic actions')
|
'title' => t('Automatic actions')
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
@ -89,6 +90,7 @@ class Action extends Base
|
||||||
'projects_list' => $projects_list,
|
'projects_list' => $projects_list,
|
||||||
'colors_list' => $this->color->getList(),
|
'colors_list' => $this->color->getList(),
|
||||||
'categories_list' => $this->category->getList($project['id']),
|
'categories_list' => $this->category->getList($project['id']),
|
||||||
|
'links_list' => $this->link->getList(0, false),
|
||||||
'project' => $project,
|
'project' => $project,
|
||||||
'title' => t('Automatic actions')
|
'title' => t('Automatic actions')
|
||||||
)));
|
)));
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Event;
|
||||||
|
|
||||||
|
class TaskLinkEvent extends GenericEvent
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
@ -1049,4 +1049,7 @@ return array(
|
||||||
// 'Projects Gantt chart' => '',
|
// 'Projects Gantt chart' => '',
|
||||||
// 'Start date: %s' => '',
|
// 'Start date: %s' => '',
|
||||||
// 'End date: %s' => '',
|
// 'End date: %s' => '',
|
||||||
|
// 'Link type' => '',
|
||||||
|
// 'Change task color when using a specific task link' => '',
|
||||||
|
// 'Task link creation or modification' => '',
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1049,4 +1049,7 @@ return array(
|
||||||
// 'Projects Gantt chart' => '',
|
// 'Projects Gantt chart' => '',
|
||||||
// 'Start date: %s' => '',
|
// 'Start date: %s' => '',
|
||||||
// 'End date: %s' => '',
|
// 'End date: %s' => '',
|
||||||
|
// 'Link type' => '',
|
||||||
|
// 'Change task color when using a specific task link' => '',
|
||||||
|
// 'Task link creation or modification' => '',
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1049,4 +1049,7 @@ return array(
|
||||||
// 'Projects Gantt chart' => '',
|
// 'Projects Gantt chart' => '',
|
||||||
// 'Start date: %s' => '',
|
// 'Start date: %s' => '',
|
||||||
// 'End date: %s' => '',
|
// 'End date: %s' => '',
|
||||||
|
// 'Link type' => '',
|
||||||
|
// 'Change task color when using a specific task link' => '',
|
||||||
|
// 'Task link creation or modification' => '',
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1049,4 +1049,7 @@ return array(
|
||||||
// 'Projects Gantt chart' => '',
|
// 'Projects Gantt chart' => '',
|
||||||
// 'Start date: %s' => '',
|
// 'Start date: %s' => '',
|
||||||
// 'End date: %s' => '',
|
// 'End date: %s' => '',
|
||||||
|
// 'Link type' => '',
|
||||||
|
// 'Change task color when using a specific task link' => '',
|
||||||
|
// 'Task link creation or modification' => '',
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1049,4 +1049,7 @@ return array(
|
||||||
// 'Projects Gantt chart' => '',
|
// 'Projects Gantt chart' => '',
|
||||||
// 'Start date: %s' => '',
|
// 'Start date: %s' => '',
|
||||||
// 'End date: %s' => '',
|
// 'End date: %s' => '',
|
||||||
|
// 'Link type' => '',
|
||||||
|
// 'Change task color when using a specific task link' => '',
|
||||||
|
// 'Task link creation or modification' => '',
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1051,4 +1051,7 @@ return array(
|
||||||
'Projects Gantt chart' => 'Diagramme de Gantt des projets',
|
'Projects Gantt chart' => 'Diagramme de Gantt des projets',
|
||||||
'Start date: %s' => 'Date de début : %s',
|
'Start date: %s' => 'Date de début : %s',
|
||||||
'End date: %s' => 'Date de fin : %s',
|
'End date: %s' => 'Date de fin : %s',
|
||||||
|
'Link type' => 'Type de lien',
|
||||||
|
'Change task color when using a specific task link' => 'Changer la couleur de la tâche lorsqu\'un lien spécifique est utilisé',
|
||||||
|
'Task link creation or modification' => 'Création ou modification d\'un lien sur une tâche',
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1049,4 +1049,7 @@ return array(
|
||||||
// 'Projects Gantt chart' => '',
|
// 'Projects Gantt chart' => '',
|
||||||
// 'Start date: %s' => '',
|
// 'Start date: %s' => '',
|
||||||
// 'End date: %s' => '',
|
// 'End date: %s' => '',
|
||||||
|
// 'Link type' => '',
|
||||||
|
// 'Change task color when using a specific task link' => '',
|
||||||
|
// 'Task link creation or modification' => '',
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1049,4 +1049,7 @@ return array(
|
||||||
// 'Projects Gantt chart' => '',
|
// 'Projects Gantt chart' => '',
|
||||||
// 'Start date: %s' => '',
|
// 'Start date: %s' => '',
|
||||||
// 'End date: %s' => '',
|
// 'End date: %s' => '',
|
||||||
|
// 'Link type' => '',
|
||||||
|
// 'Change task color when using a specific task link' => '',
|
||||||
|
// 'Task link creation or modification' => '',
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1049,4 +1049,7 @@ return array(
|
||||||
// 'Projects Gantt chart' => '',
|
// 'Projects Gantt chart' => '',
|
||||||
// 'Start date: %s' => '',
|
// 'Start date: %s' => '',
|
||||||
// 'End date: %s' => '',
|
// 'End date: %s' => '',
|
||||||
|
// 'Link type' => '',
|
||||||
|
// 'Change task color when using a specific task link' => '',
|
||||||
|
// 'Task link creation or modification' => '',
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1049,4 +1049,7 @@ return array(
|
||||||
// 'Projects Gantt chart' => '',
|
// 'Projects Gantt chart' => '',
|
||||||
// 'Start date: %s' => '',
|
// 'Start date: %s' => '',
|
||||||
// 'End date: %s' => '',
|
// 'End date: %s' => '',
|
||||||
|
// 'Link type' => '',
|
||||||
|
// 'Change task color when using a specific task link' => '',
|
||||||
|
// 'Task link creation or modification' => '',
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1049,4 +1049,7 @@ return array(
|
||||||
// 'Projects Gantt chart' => '',
|
// 'Projects Gantt chart' => '',
|
||||||
// 'Start date: %s' => '',
|
// 'Start date: %s' => '',
|
||||||
// 'End date: %s' => '',
|
// 'End date: %s' => '',
|
||||||
|
// 'Link type' => '',
|
||||||
|
// 'Change task color when using a specific task link' => '',
|
||||||
|
// 'Task link creation or modification' => '',
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1049,4 +1049,7 @@ return array(
|
||||||
// 'Projects Gantt chart' => '',
|
// 'Projects Gantt chart' => '',
|
||||||
// 'Start date: %s' => '',
|
// 'Start date: %s' => '',
|
||||||
// 'End date: %s' => '',
|
// 'End date: %s' => '',
|
||||||
|
// 'Link type' => '',
|
||||||
|
// 'Change task color when using a specific task link' => '',
|
||||||
|
// 'Task link creation or modification' => '',
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1049,4 +1049,7 @@ return array(
|
||||||
// 'Projects Gantt chart' => '',
|
// 'Projects Gantt chart' => '',
|
||||||
// 'Start date: %s' => '',
|
// 'Start date: %s' => '',
|
||||||
// 'End date: %s' => '',
|
// 'End date: %s' => '',
|
||||||
|
// 'Link type' => '',
|
||||||
|
// 'Change task color when using a specific task link' => '',
|
||||||
|
// 'Task link creation or modification' => '',
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1049,4 +1049,7 @@ return array(
|
||||||
// 'Projects Gantt chart' => '',
|
// 'Projects Gantt chart' => '',
|
||||||
// 'Start date: %s' => '',
|
// 'Start date: %s' => '',
|
||||||
// 'End date: %s' => '',
|
// 'End date: %s' => '',
|
||||||
|
// 'Link type' => '',
|
||||||
|
// 'Change task color when using a specific task link' => '',
|
||||||
|
// 'Task link creation or modification' => '',
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1049,4 +1049,7 @@ return array(
|
||||||
// 'Projects Gantt chart' => '',
|
// 'Projects Gantt chart' => '',
|
||||||
// 'Start date: %s' => '',
|
// 'Start date: %s' => '',
|
||||||
// 'End date: %s' => '',
|
// 'End date: %s' => '',
|
||||||
|
// 'Link type' => '',
|
||||||
|
// 'Change task color when using a specific task link' => '',
|
||||||
|
// 'Task link creation or modification' => '',
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1049,4 +1049,7 @@ return array(
|
||||||
// 'Projects Gantt chart' => '',
|
// 'Projects Gantt chart' => '',
|
||||||
// 'Start date: %s' => '',
|
// 'Start date: %s' => '',
|
||||||
// 'End date: %s' => '',
|
// 'End date: %s' => '',
|
||||||
|
// 'Link type' => '',
|
||||||
|
// 'Change task color when using a specific task link' => '',
|
||||||
|
// 'Task link creation or modification' => '',
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1049,4 +1049,7 @@ return array(
|
||||||
// 'Projects Gantt chart' => '',
|
// 'Projects Gantt chart' => '',
|
||||||
// 'Start date: %s' => '',
|
// 'Start date: %s' => '',
|
||||||
// 'End date: %s' => '',
|
// 'End date: %s' => '',
|
||||||
|
// 'Link type' => '',
|
||||||
|
// 'Change task color when using a specific task link' => '',
|
||||||
|
// 'Task link creation or modification' => '',
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1049,4 +1049,7 @@ return array(
|
||||||
// 'Projects Gantt chart' => '',
|
// 'Projects Gantt chart' => '',
|
||||||
// 'Start date: %s' => '',
|
// 'Start date: %s' => '',
|
||||||
// 'End date: %s' => '',
|
// 'End date: %s' => '',
|
||||||
|
// 'Link type' => '',
|
||||||
|
// 'Change task color when using a specific task link' => '',
|
||||||
|
// 'Task link creation or modification' => '',
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1049,4 +1049,7 @@ return array(
|
||||||
// 'Projects Gantt chart' => '',
|
// 'Projects Gantt chart' => '',
|
||||||
// 'Start date: %s' => '',
|
// 'Start date: %s' => '',
|
||||||
// 'End date: %s' => '',
|
// 'End date: %s' => '',
|
||||||
|
// 'Link type' => '',
|
||||||
|
// 'Change task color when using a specific task link' => '',
|
||||||
|
// 'Task link creation or modification' => '',
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1049,4 +1049,7 @@ return array(
|
||||||
// 'Projects Gantt chart' => '',
|
// 'Projects Gantt chart' => '',
|
||||||
// 'Start date: %s' => '',
|
// 'Start date: %s' => '',
|
||||||
// 'End date: %s' => '',
|
// 'End date: %s' => '',
|
||||||
|
// 'Link type' => '',
|
||||||
|
// 'Change task color when using a specific task link' => '',
|
||||||
|
// 'Task link creation or modification' => '',
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,7 @@ class Action extends Base
|
||||||
'TaskUpdateStartDate' => t('Automatically update the start date'),
|
'TaskUpdateStartDate' => t('Automatically update the start date'),
|
||||||
'TaskMoveColumnCategoryChange' => t('Move the task to another column when the category is changed'),
|
'TaskMoveColumnCategoryChange' => t('Move the task to another column when the category is changed'),
|
||||||
'TaskEmail' => t('Send a task by email to someone'),
|
'TaskEmail' => t('Send a task by email to someone'),
|
||||||
|
'TaskAssignColorLink' => t('Change task color when using a specific task link'),
|
||||||
);
|
);
|
||||||
|
|
||||||
asort($values);
|
asort($values);
|
||||||
|
|
@ -75,6 +76,7 @@ class Action extends Base
|
||||||
public function getAvailableEvents()
|
public function getAvailableEvents()
|
||||||
{
|
{
|
||||||
$values = array(
|
$values = array(
|
||||||
|
TaskLink::EVENT_CREATE_UPDATE => t('Task link creation or modification'),
|
||||||
Task::EVENT_MOVE_COLUMN => t('Move a task to another column'),
|
Task::EVENT_MOVE_COLUMN => t('Move a task to another column'),
|
||||||
Task::EVENT_UPDATE => t('Task modification'),
|
Task::EVENT_UPDATE => t('Task modification'),
|
||||||
Task::EVENT_CREATE => t('Task creation'),
|
Task::EVENT_CREATE => t('Task creation'),
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ namespace Model;
|
||||||
|
|
||||||
use SimpleValidator\Validator;
|
use SimpleValidator\Validator;
|
||||||
use SimpleValidator\Validators;
|
use SimpleValidator\Validators;
|
||||||
|
use Event\TaskLinkEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TaskLink model
|
* TaskLink model
|
||||||
|
|
@ -21,6 +22,13 @@ class TaskLink extends Base
|
||||||
*/
|
*/
|
||||||
const TABLE = 'task_has_links';
|
const TABLE = 'task_has_links';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Events
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
const EVENT_CREATE_UPDATE = 'tasklink.create_update';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a task link
|
* Get a task link
|
||||||
*
|
*
|
||||||
|
|
@ -113,6 +121,20 @@ class TaskLink extends Base
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Publish events
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @param array $events
|
||||||
|
*/
|
||||||
|
private function fireEvents(array $events)
|
||||||
|
{
|
||||||
|
foreach ($events as $event) {
|
||||||
|
$event['project_id'] = $this->taskFinder->getProjectId($event['task_id']);
|
||||||
|
$this->container['dispatcher']->dispatch(self::EVENT_CREATE_UPDATE, new TaskLinkEvent($event));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new link
|
* Create a new link
|
||||||
*
|
*
|
||||||
|
|
@ -124,29 +146,37 @@ class TaskLink extends Base
|
||||||
*/
|
*/
|
||||||
public function create($task_id, $opposite_task_id, $link_id)
|
public function create($task_id, $opposite_task_id, $link_id)
|
||||||
{
|
{
|
||||||
|
$events = array();
|
||||||
$this->db->startTransaction();
|
$this->db->startTransaction();
|
||||||
|
|
||||||
// Get opposite link
|
// Get opposite link
|
||||||
$opposite_link_id = $this->link->getOppositeLinkId($link_id);
|
$opposite_link_id = $this->link->getOppositeLinkId($link_id);
|
||||||
|
|
||||||
// Create the original task link
|
$values = array(
|
||||||
$this->db->table(self::TABLE)->insert(array(
|
|
||||||
'task_id' => $task_id,
|
'task_id' => $task_id,
|
||||||
'opposite_task_id' => $opposite_task_id,
|
'opposite_task_id' => $opposite_task_id,
|
||||||
'link_id' => $link_id,
|
'link_id' => $link_id,
|
||||||
));
|
);
|
||||||
|
|
||||||
|
// Create the original task link
|
||||||
|
$this->db->table(self::TABLE)->insert($values);
|
||||||
$task_link_id = $this->db->getLastId();
|
$task_link_id = $this->db->getLastId();
|
||||||
|
$events[] = $values;
|
||||||
|
|
||||||
// Create the opposite task link
|
// Create the opposite task link
|
||||||
$this->db->table(self::TABLE)->insert(array(
|
$values = array(
|
||||||
'task_id' => $opposite_task_id,
|
'task_id' => $opposite_task_id,
|
||||||
'opposite_task_id' => $task_id,
|
'opposite_task_id' => $task_id,
|
||||||
'link_id' => $opposite_link_id,
|
'link_id' => $opposite_link_id,
|
||||||
));
|
);
|
||||||
|
|
||||||
|
$this->db->table(self::TABLE)->insert($values);
|
||||||
|
$events[] = $values;
|
||||||
|
|
||||||
$this->db->closeTransaction();
|
$this->db->closeTransaction();
|
||||||
|
|
||||||
|
$this->fireEvents($events);
|
||||||
|
|
||||||
return (int) $task_link_id;
|
return (int) $task_link_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -162,6 +192,7 @@ class TaskLink extends Base
|
||||||
*/
|
*/
|
||||||
public function update($task_link_id, $task_id, $opposite_task_id, $link_id)
|
public function update($task_link_id, $task_id, $opposite_task_id, $link_id)
|
||||||
{
|
{
|
||||||
|
$events = array();
|
||||||
$this->db->startTransaction();
|
$this->db->startTransaction();
|
||||||
|
|
||||||
// Get original task link
|
// Get original task link
|
||||||
|
|
@ -174,22 +205,33 @@ class TaskLink extends Base
|
||||||
$opposite_link_id = $this->link->getOppositeLinkId($link_id);
|
$opposite_link_id = $this->link->getOppositeLinkId($link_id);
|
||||||
|
|
||||||
// Update the original task link
|
// Update the original task link
|
||||||
$rs1 = $this->db->table(self::TABLE)->eq('id', $task_link_id)->update(array(
|
$values = array(
|
||||||
'task_id' => $task_id,
|
'task_id' => $task_id,
|
||||||
'opposite_task_id' => $opposite_task_id,
|
'opposite_task_id' => $opposite_task_id,
|
||||||
'link_id' => $link_id,
|
'link_id' => $link_id,
|
||||||
));
|
);
|
||||||
|
|
||||||
|
$rs1 = $this->db->table(self::TABLE)->eq('id', $task_link_id)->update($values);
|
||||||
|
$events[] = $values;
|
||||||
|
|
||||||
// Update the opposite link
|
// Update the opposite link
|
||||||
$rs2 = $this->db->table(self::TABLE)->eq('id', $opposite_task_link['id'])->update(array(
|
$values = array(
|
||||||
'task_id' => $opposite_task_id,
|
'task_id' => $opposite_task_id,
|
||||||
'opposite_task_id' => $task_id,
|
'opposite_task_id' => $task_id,
|
||||||
'link_id' => $opposite_link_id,
|
'link_id' => $opposite_link_id,
|
||||||
));
|
);
|
||||||
|
|
||||||
|
$rs2 = $this->db->table(self::TABLE)->eq('id', $opposite_task_link['id'])->update($values);
|
||||||
|
$events[] = $values;
|
||||||
|
|
||||||
$this->db->closeTransaction();
|
$this->db->closeTransaction();
|
||||||
|
|
||||||
return $rs1 && $rs2;
|
if ($rs1 && $rs2) {
|
||||||
|
$this->fireEvents($events);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,8 @@
|
||||||
<?= $this->text->in($param['value'], $colors_list) ?>
|
<?= $this->text->in($param['value'], $colors_list) ?>
|
||||||
<?php elseif ($this->text->contains($param['name'], 'category_id')): ?>
|
<?php elseif ($this->text->contains($param['name'], 'category_id')): ?>
|
||||||
<?= $this->text->in($param['value'], $categories_list) ?>
|
<?= $this->text->in($param['value'], $categories_list) ?>
|
||||||
|
<?php elseif ($this->text->contains($param['name'], 'link_id')): ?>
|
||||||
|
<?= $this->text->in($param['value'], $links_list) ?>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<?= $this->e($param['value']) ?>
|
<?= $this->e($param['value']) ?>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,9 @@
|
||||||
<?php elseif ($this->text->contains($param_name, 'category_id')): ?>
|
<?php elseif ($this->text->contains($param_name, 'category_id')): ?>
|
||||||
<?= $this->form->label($param_desc, $param_name) ?>
|
<?= $this->form->label($param_desc, $param_name) ?>
|
||||||
<?= $this->form->select('params['.$param_name.']', $categories_list, $values) ?><br/>
|
<?= $this->form->select('params['.$param_name.']', $categories_list, $values) ?><br/>
|
||||||
|
<?php elseif ($this->text->contains($param_name, 'link_id')): ?>
|
||||||
|
<?= $this->form->label($param_desc, $param_name) ?>
|
||||||
|
<?= $this->form->select('params['.$param_name.']', $links_list, $values) ?><br/>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<?= $this->form->label($param_desc, $param_name) ?>
|
<?= $this->form->label($param_desc, $param_name) ?>
|
||||||
<?= $this->form->text('params['.$param_name.']', $values) ?>
|
<?= $this->form->text('params['.$param_name.']', $values) ?>
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ List of available events
|
||||||
- Closing a task
|
- Closing a task
|
||||||
- Task creation or modification
|
- Task creation or modification
|
||||||
- Task assignee change
|
- Task assignee change
|
||||||
|
- Task link created or updated
|
||||||
- Github commit received
|
- Github commit received
|
||||||
- Github issue opened
|
- Github issue opened
|
||||||
- Github issue closed
|
- Github issue closed
|
||||||
|
|
@ -77,6 +78,7 @@ List of available actions
|
||||||
- Automatically update the start date
|
- Automatically update the start date
|
||||||
- Move the task to another column when the category is changed
|
- Move the task to another column when the category is changed
|
||||||
- Send a task by email to someone
|
- Send a task by email to someone
|
||||||
|
- Change task color when using a specific task link
|
||||||
|
|
||||||
Examples
|
Examples
|
||||||
--------
|
--------
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once __DIR__.'/Base.php';
|
||||||
|
|
||||||
|
use Event\TaskLinkEvent;
|
||||||
|
use Model\Task;
|
||||||
|
use Model\TaskCreation;
|
||||||
|
use Model\TaskFinder;
|
||||||
|
use Model\TaskLink;
|
||||||
|
use Model\Project;
|
||||||
|
|
||||||
|
class ActionTaskAssignColorLinkTest extends Base
|
||||||
|
{
|
||||||
|
public function testExecute()
|
||||||
|
{
|
||||||
|
$action = new Action\TaskAssignColorLink($this->container, 1, TaskLink::EVENT_CREATE_UPDATE);
|
||||||
|
$action->setParam('link_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);
|
||||||
|
$tl = new TaskLink($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)));
|
||||||
|
|
||||||
|
// The color should be yellow
|
||||||
|
$task = $tf->getById(1);
|
||||||
|
$this->assertNotEmpty($task);
|
||||||
|
$this->assertEquals('yellow', $task['color_id']);
|
||||||
|
|
||||||
|
$event = array(
|
||||||
|
'project_id' => 1,
|
||||||
|
'task_id' => 1,
|
||||||
|
'link_id' => 2,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Our event should be executed
|
||||||
|
$this->assertTrue($action->execute(new TaskLinkEvent($event)));
|
||||||
|
|
||||||
|
// The color should be green
|
||||||
|
$task = $tf->getById(1);
|
||||||
|
$this->assertNotEmpty($task);
|
||||||
|
$this->assertEquals('green', $task['color_id']);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue