Add new automatic action to move a task to another column when closed
This commit is contained in:
@@ -7,7 +7,7 @@ use Kanboard\Event\GenericEvent;
|
||||
/**
|
||||
* Base class for automatic actions
|
||||
*
|
||||
* @package action
|
||||
* @package Kanboard\Action
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
abstract class Base extends \Kanboard\Core\Base
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Kanboard\Action;
|
||||
/**
|
||||
* Create automatically a comment from a webhook
|
||||
*
|
||||
* @package action
|
||||
* @package Kanboard\Action
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class CommentCreation extends Base
|
||||
|
||||
@@ -7,7 +7,7 @@ use Kanboard\Model\TaskModel;
|
||||
/**
|
||||
* Add a comment of the triggering event to the task description.
|
||||
*
|
||||
* @package action
|
||||
* @package Kanboard\Action
|
||||
* @author Oren Ben-Kiki
|
||||
*/
|
||||
class CommentCreationMoveTaskColumn extends Base
|
||||
|
||||
@@ -7,7 +7,7 @@ use Kanboard\Model\TaskModel;
|
||||
/**
|
||||
* Set a category automatically according to the color
|
||||
*
|
||||
* @package action
|
||||
* @package Kanboard\Action
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class TaskAssignCategoryColor extends Base
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Kanboard\Action;
|
||||
/**
|
||||
* Set a category automatically according to a label
|
||||
*
|
||||
* @package action
|
||||
* @package Kanboard\Action
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class TaskAssignCategoryLabel extends Base
|
||||
|
||||
@@ -7,7 +7,7 @@ use Kanboard\Model\TaskLinkModel;
|
||||
/**
|
||||
* Set a category automatically according to a task link
|
||||
*
|
||||
* @package action
|
||||
* @package Kanboard\Action
|
||||
* @author Olivier Maridat
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
|
||||
@@ -7,7 +7,7 @@ use Kanboard\Model\TaskModel;
|
||||
/**
|
||||
* Assign a color to a specific category
|
||||
*
|
||||
* @package action
|
||||
* @package Kanboard\Action
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class TaskAssignColorCategory extends Base
|
||||
|
||||
@@ -7,7 +7,7 @@ use Kanboard\Model\TaskModel;
|
||||
/**
|
||||
* Assign a color to a task
|
||||
*
|
||||
* @package action
|
||||
* @package Kanboard\Action
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class TaskAssignColorColumn extends Base
|
||||
|
||||
@@ -7,7 +7,7 @@ use Kanboard\Model\TaskLinkModel;
|
||||
/**
|
||||
* Assign a color to a specific task link
|
||||
*
|
||||
* @package action
|
||||
* @package Kanboard\Action
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class TaskAssignColorLink extends Base
|
||||
|
||||
@@ -7,7 +7,7 @@ use Kanboard\Model\TaskModel;
|
||||
/**
|
||||
* Assign a color to a priority
|
||||
*
|
||||
* @package action
|
||||
* @package Kanboard\Action
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class TaskAssignColorPriority extends Base
|
||||
|
||||
@@ -7,7 +7,7 @@ use Kanboard\Model\TaskModel;
|
||||
/**
|
||||
* Assign a color to a specific user
|
||||
*
|
||||
* @package action
|
||||
* @package Kanboard\Action
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class TaskAssignColorUser extends Base
|
||||
|
||||
@@ -7,7 +7,7 @@ use Kanboard\Model\TaskModel;
|
||||
/**
|
||||
* Assign a task to the logged user
|
||||
*
|
||||
* @package action
|
||||
* @package Kanboard\Action
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class TaskAssignCurrentUser extends Base
|
||||
|
||||
@@ -7,7 +7,7 @@ use Kanboard\Model\TaskModel;
|
||||
/**
|
||||
* Assign a task to the logged user on column change
|
||||
*
|
||||
* @package action
|
||||
* @package Kanboard\Action
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class TaskAssignCurrentUserColumn extends Base
|
||||
|
||||
@@ -7,7 +7,7 @@ use Kanboard\Model\TaskModel;
|
||||
/**
|
||||
* Set the due date of task
|
||||
*
|
||||
* @package action
|
||||
* @package Kanboard\Action
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class TaskAssignDueDateOnCreation extends Base
|
||||
|
||||
@@ -7,7 +7,7 @@ use Kanboard\Model\TaskModel;
|
||||
/**
|
||||
* Assign a task to a specific user
|
||||
*
|
||||
* @package action
|
||||
* @package Kanboard\Action
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class TaskAssignSpecificUser extends Base
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Kanboard\Action;
|
||||
/**
|
||||
* Assign a task to someone
|
||||
*
|
||||
* @package action
|
||||
* @package Kanboard\Actionv
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class TaskAssignUser extends Base
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Kanboard\Action;
|
||||
/**
|
||||
* Close automatically a task
|
||||
*
|
||||
* @package action
|
||||
* @package Kanboard\Action
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class TaskClose extends Base
|
||||
|
||||
@@ -7,7 +7,7 @@ use Kanboard\Model\TaskModel;
|
||||
/**
|
||||
* Close automatically a task in a specific column
|
||||
*
|
||||
* @package action
|
||||
* @package Kanboard\Action
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class TaskCloseColumn extends Base
|
||||
|
||||
@@ -7,7 +7,7 @@ use Kanboard\Model\TaskModel;
|
||||
/**
|
||||
* Close automatically a task after when inactive
|
||||
*
|
||||
* @package action
|
||||
* @package Kanboard\Action
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class TaskCloseNoActivity extends Base
|
||||
|
||||
@@ -7,7 +7,7 @@ use Kanboard\Model\TaskModel;
|
||||
/**
|
||||
* Close automatically a task after inactive and in an defined column
|
||||
*
|
||||
* @package action
|
||||
* @package Kanboard\Action
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class TaskCloseNoActivityColumn extends Base
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Kanboard\Action;
|
||||
/**
|
||||
* Create automatically a task from a webhook
|
||||
*
|
||||
* @package action
|
||||
* @package Kanboard\Action
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class TaskCreation extends Base
|
||||
|
||||
@@ -7,7 +7,7 @@ use Kanboard\Model\TaskModel;
|
||||
/**
|
||||
* Duplicate a task to another project
|
||||
*
|
||||
* @package action
|
||||
* @package Kanboard\Action
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class TaskDuplicateAnotherProject extends Base
|
||||
|
||||
@@ -7,7 +7,7 @@ use Kanboard\Model\TaskModel;
|
||||
/**
|
||||
* Email a task to someone
|
||||
*
|
||||
* @package action
|
||||
* @package Kanboard\Action
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class TaskEmail extends Base
|
||||
|
||||
@@ -7,7 +7,7 @@ use Kanboard\Model\TaskModel;
|
||||
/**
|
||||
* Email a task with no activity
|
||||
*
|
||||
* @package action
|
||||
* @package Kanboard\Action
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class TaskEmailNoActivity extends Base
|
||||
|
||||
@@ -7,7 +7,7 @@ use Kanboard\Model\TaskModel;
|
||||
/**
|
||||
* Move a task to another project
|
||||
*
|
||||
* @package action
|
||||
* @package Kanboard\Action
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class TaskMoveAnotherProject extends Base
|
||||
|
||||
@@ -7,7 +7,7 @@ use Kanboard\Model\TaskModel;
|
||||
/**
|
||||
* Move a task to another column when an assignee is set
|
||||
*
|
||||
* @package action
|
||||
* @package Kanboard\Action
|
||||
* @author Francois Ferrand
|
||||
*/
|
||||
class TaskMoveColumnAssigned extends Base
|
||||
|
||||
@@ -7,7 +7,7 @@ use Kanboard\Model\TaskModel;
|
||||
/**
|
||||
* Move a task to another column when the category is changed
|
||||
*
|
||||
* @package action
|
||||
* @package Kanboard\Action
|
||||
* @author Francois Ferrand
|
||||
*/
|
||||
class TaskMoveColumnCategoryChange extends Base
|
||||
|
||||
102
app/Action/TaskMoveColumnClosed.php
Normal file
102
app/Action/TaskMoveColumnClosed.php
Normal file
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace Kanboard\Action;
|
||||
|
||||
use Kanboard\Model\TaskModel;
|
||||
|
||||
/**
|
||||
* Move a task to another column when the task is closed
|
||||
*
|
||||
* @package Kanboard\Action
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class TaskMoveColumnClosed extends Base
|
||||
{
|
||||
/**
|
||||
* Get automatic action description
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
return t('Move the task to another column when closed');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of compatible events
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getCompatibleEvents()
|
||||
{
|
||||
return array(
|
||||
TaskModel::EVENT_CLOSE,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the required parameter for the action (defined by the user)
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getActionRequiredParameters()
|
||||
{
|
||||
return array(
|
||||
'dest_column_id' => t('Destination column'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the required parameter for the event
|
||||
*
|
||||
* @access public
|
||||
* @return string[]
|
||||
*/
|
||||
public function getEventRequiredParameters()
|
||||
{
|
||||
return array(
|
||||
'task_id',
|
||||
'task' => array(
|
||||
'project_id',
|
||||
'column_id',
|
||||
'swimlane_id',
|
||||
'is_active',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the action (move the task to another column)
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
return $this->taskPositionModel->movePosition(
|
||||
$data['task']['project_id'],
|
||||
$data['task']['id'],
|
||||
$this->getParam('dest_column_id'),
|
||||
1,
|
||||
$data['task']['swimlane_id'],
|
||||
false,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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['task']['column_id'] != $this->getParam('dest_column_id') && $data['task']['is_active'] == 0;
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ use Kanboard\Model\TaskModel;
|
||||
/**
|
||||
* Move a task to another column when an assignee is cleared
|
||||
*
|
||||
* @package action
|
||||
* @package Kanboard\Action
|
||||
* @author Francois Ferrand
|
||||
*/
|
||||
class TaskMoveColumnUnAssigned extends Base
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Kanboard\Action;
|
||||
/**
|
||||
* Open automatically a task
|
||||
*
|
||||
* @package action
|
||||
* @package Kanboard\Action
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class TaskOpen extends Base
|
||||
|
||||
@@ -7,7 +7,7 @@ use Kanboard\Model\TaskModel;
|
||||
/**
|
||||
* Set the start date of task
|
||||
*
|
||||
* @package action
|
||||
* @package Kanboard\Action
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class TaskUpdateStartDate extends Base
|
||||
|
||||
@@ -16,15 +16,16 @@ class TaskPositionModel extends Base
|
||||
* Move a task to another column or to another position
|
||||
*
|
||||
* @access public
|
||||
* @param integer $project_id Project id
|
||||
* @param integer $task_id Task id
|
||||
* @param integer $column_id Column id
|
||||
* @param integer $position Position (must be >= 1)
|
||||
* @param integer $swimlane_id Swimlane id
|
||||
* @param boolean $fire_events Fire events
|
||||
* @return boolean
|
||||
* @param integer $project_id Project id
|
||||
* @param integer $task_id Task id
|
||||
* @param integer $column_id Column id
|
||||
* @param integer $position Position (must be >= 1)
|
||||
* @param integer $swimlane_id Swimlane id
|
||||
* @param boolean $fire_events Fire events
|
||||
* @param bool $onlyOpen Do not move closed tasks
|
||||
* @return bool
|
||||
*/
|
||||
public function movePosition($project_id, $task_id, $column_id, $position, $swimlane_id = 0, $fire_events = true)
|
||||
public function movePosition($project_id, $task_id, $column_id, $position, $swimlane_id = 0, $fire_events = true, $onlyOpen = true)
|
||||
{
|
||||
if ($position < 1) {
|
||||
return false;
|
||||
@@ -32,7 +33,7 @@ class TaskPositionModel extends Base
|
||||
|
||||
$task = $this->taskFinderModel->getById($task_id);
|
||||
|
||||
if ($task['is_active'] == TaskModel::STATUS_CLOSED) {
|
||||
if ($onlyOpen && $task['is_active'] == TaskModel::STATUS_CLOSED) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace Kanboard\ServiceProvider;
|
||||
|
||||
use Kanboard\Action\TaskAssignColorPriority;
|
||||
use Kanboard\Action\TaskAssignDueDateOnCreation;
|
||||
use Kanboard\Action\TaskMoveColumnClosed;
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
use Kanboard\Core\Action\ActionManager;
|
||||
@@ -78,6 +79,7 @@ class ActionProvider implements ServiceProviderInterface
|
||||
$container['actionManager']->register(new TaskMoveAnotherProject($container));
|
||||
$container['actionManager']->register(new TaskMoveColumnAssigned($container));
|
||||
$container['actionManager']->register(new TaskMoveColumnCategoryChange($container));
|
||||
$container['actionManager']->register(new TaskMoveColumnClosed($container));
|
||||
$container['actionManager']->register(new TaskMoveColumnUnAssigned($container));
|
||||
$container['actionManager']->register(new TaskOpen($container));
|
||||
$container['actionManager']->register(new TaskUpdateStartDate($container));
|
||||
|
||||
Reference in New Issue
Block a user