Merge pull-request #2587
This commit is contained in:
99
app/Action/TaskAssignColorSwimlane.php
Normal file
99
app/Action/TaskAssignColorSwimlane.php
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
namespace Kanboard\Action;
|
||||
|
||||
use Kanboard\Model\TaskModel;
|
||||
|
||||
/**
|
||||
* Assign a color to a task based on Swimlane
|
||||
*
|
||||
* @package Kanboard\Action
|
||||
* @author Dave Almond
|
||||
*/
|
||||
class TaskAssignColorSwimlane extends Base
|
||||
{
|
||||
/**
|
||||
* Get automatic action description
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
return t('Assign a color when the task is moved to a specific swimlane');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of compatible events
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getCompatibleEvents()
|
||||
{
|
||||
return array(
|
||||
TaskModel::EVENT_CREATE,
|
||||
TaskModel::EVENT_MOVE_SWIMLANE,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the required parameter for the action (defined by the user)
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getActionRequiredParameters()
|
||||
{
|
||||
return array(
|
||||
'swimlane_id' => t('Swimlane'),
|
||||
'color_id' => t('Color'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the required parameter for the event
|
||||
*
|
||||
* @access public
|
||||
* @return string[]
|
||||
*/
|
||||
public function getEventRequiredParameters()
|
||||
{
|
||||
return array(
|
||||
'task_id',
|
||||
'task' => array(
|
||||
'project_id',
|
||||
'swimlane_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->taskModificationModel->update($values, 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']['swimlane_id'] == $this->getParam('swimlane_id');
|
||||
}
|
||||
}
|
||||
99
app/Action/TaskAssignPrioritySwimlane.php
Normal file
99
app/Action/TaskAssignPrioritySwimlane.php
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
namespace Kanboard\Action;
|
||||
|
||||
use Kanboard\Model\TaskModel;
|
||||
|
||||
/**
|
||||
* Set a priority automatically according to the Swimlane
|
||||
*
|
||||
* @package Kanboard\Action
|
||||
* @author Dave Almond
|
||||
*/
|
||||
class TaskAssignPrioritySwimlane extends Base
|
||||
{
|
||||
/**
|
||||
* Get automatic action description
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
return t('Assign a priority when the task is moved to a specific swimlane');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of compatible events
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getCompatibleEvents()
|
||||
{
|
||||
return array(
|
||||
TaskModel::EVENT_CREATE,
|
||||
TaskModel::EVENT_MOVE_SWIMLANE,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the required parameter for the action (defined by the user)
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getActionRequiredParameters()
|
||||
{
|
||||
return array(
|
||||
'swimlane_id' => t('Swimlane'),
|
||||
'priority' => t('Priority'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the required parameter for the event
|
||||
*
|
||||
* @access public
|
||||
* @return string[]
|
||||
*/
|
||||
public function getEventRequiredParameters()
|
||||
{
|
||||
return array(
|
||||
'task_id',
|
||||
'task' => array(
|
||||
'project_id',
|
||||
'swimlane_id',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the action (set the priority)
|
||||
*
|
||||
* @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'],
|
||||
'priority' => $this->getParam('priority'),
|
||||
);
|
||||
|
||||
return $this->taskModificationModel->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['task']['swimlane_id'] == $this->getParam('swimlane_id');
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,7 @@ class ActionController extends BaseController
|
||||
'colors_list' => $this->colorModel->getList(),
|
||||
'categories_list' => $this->categoryModel->getList($project['id']),
|
||||
'links_list' => $this->linkModel->getList(0, false),
|
||||
'swimlane_list' => $this->swimlaneModel->getList($project['id']),
|
||||
'title' => t('Automatic actions')
|
||||
)));
|
||||
}
|
||||
|
||||
@@ -84,6 +84,7 @@ class ActionCreationController extends BaseController
|
||||
'priorities_list' => $this->projectTaskPriorityModel->getPriorities($project),
|
||||
'project' => $project,
|
||||
'available_actions' => $this->actionManager->getAvailableActions(),
|
||||
'swimlane_list' => $this->swimlaneModel->getList($project['id']),
|
||||
'events' => $this->actionManager->getCompatibleEvents($values['action_name']),
|
||||
)));
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ class EventManager
|
||||
TaskModel::EVENT_CREATE_UPDATE => t('Task creation or modification'),
|
||||
TaskModel::EVENT_ASSIGNEE_CHANGE => t('Task assignee change'),
|
||||
TaskModel::EVENT_DAILY_CRONJOB => t('Daily background job for tasks'),
|
||||
TaskModel::EVENT_MOVE_SWIMLANE => t('Move a task to another swimlane'),
|
||||
);
|
||||
|
||||
$events = array_merge($events, $this->events);
|
||||
|
||||
@@ -157,7 +157,10 @@ class ActionParameterModel extends Base
|
||||
case 'user_id':
|
||||
case 'owner_id':
|
||||
return $this->projectPermissionModel->isAssignable($project_id, $value) ? $value : false;
|
||||
default:
|
||||
case 'swimlane_id':
|
||||
$column = $this->swimlaneModel->getById($value);
|
||||
return empty($column) ? false : $this->swimlaneModel->getIdByName($project_id, $column['name']) ?: false;
|
||||
default:
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,8 @@ use Kanboard\Action\TaskOpen;
|
||||
use Kanboard\Action\TaskUpdateStartDate;
|
||||
use Kanboard\Action\TaskCloseNoActivity;
|
||||
use Kanboard\Action\TaskCloseNoActivityColumn;
|
||||
use Kanboard\Action\TaskAssignColorSwimlane;
|
||||
use Kanboard\Action\TaskAssignPrioritySwimlane;
|
||||
|
||||
/**
|
||||
* Action Provider
|
||||
@@ -86,6 +88,8 @@ class ActionProvider implements ServiceProviderInterface
|
||||
$container['actionManager']->register(new TaskOpen($container));
|
||||
$container['actionManager']->register(new TaskUpdateStartDate($container));
|
||||
$container['actionManager']->register(new TaskAssignDueDateOnCreation($container));
|
||||
$container['actionManager']->register(new TaskAssignColorSwimlane($container));
|
||||
$container['actionManager']->register(new TaskAssignPrioritySwimlane($container));
|
||||
|
||||
return $container;
|
||||
}
|
||||
|
||||
@@ -54,6 +54,8 @@
|
||||
<?= $this->text->in($param_value, $categories_list) ?>
|
||||
<?php elseif ($this->text->contains($param_name, 'link_id')): ?>
|
||||
<?= $this->text->in($param_value, $links_list) ?>
|
||||
<?php elseif ($this->text->contains($param_name, 'swimlane_id')): ?>
|
||||
<?= $this->text->in($param_value, $swimlane_list) ?>
|
||||
<?php else: ?>
|
||||
<?= $this->text->e($param_value) ?>
|
||||
<?php endif ?>
|
||||
|
||||
@@ -41,10 +41,13 @@
|
||||
<?php elseif ($this->text->contains($param_name, 'duration')): ?>
|
||||
<?= $this->form->label($param_desc, $param_name) ?>
|
||||
<?= $this->form->number('params['.$param_name.']', $values) ?>
|
||||
<?php else: ?>
|
||||
<?php elseif ($this->text->contains($param_name, 'swimlane_id')): ?>
|
||||
<?= $this->form->label($param_desc, $param_name) ?>
|
||||
<?= $this->form->select('params['.$param_name.']', $swimlane_list, $values) ?>
|
||||
<?php else: ?>
|
||||
<?= $this->form->label($param_desc, $param_name) ?>
|
||||
<?= $this->form->text('params['.$param_name.']', $values) ?>
|
||||
<?php endif ?>
|
||||
<?php endif ?>
|
||||
<?php endforeach ?>
|
||||
|
||||
<div class="form-actions">
|
||||
|
||||
Reference in New Issue
Block a user