Refactoring to implement new layout with filters: board/calendar/list views (work in progress)
This commit is contained in:
@@ -37,7 +37,8 @@ class Acl extends Base
|
||||
'comment' => '*',
|
||||
'file' => '*',
|
||||
'project' => array('show'),
|
||||
'projectinfo' => array('tasks', 'search', 'activity'),
|
||||
'listing' => '*',
|
||||
'activity' => '*',
|
||||
'subtask' => '*',
|
||||
'task' => '*',
|
||||
'tasklink' => '*',
|
||||
|
||||
@@ -237,10 +237,11 @@ class Board extends Base
|
||||
* Get all tasks sorted by columns and swimlanes
|
||||
*
|
||||
* @access public
|
||||
* @param integer $project_id Project id
|
||||
* @param integer $project_id
|
||||
* @param callable $callback
|
||||
* @return array
|
||||
*/
|
||||
public function getBoard($project_id)
|
||||
public function getBoard($project_id, $callback = null)
|
||||
{
|
||||
$swimlanes = $this->swimlane->getSwimlanes($project_id);
|
||||
$columns = $this->getColumns($project_id);
|
||||
@@ -253,7 +254,11 @@ class Board extends Base
|
||||
$swimlanes[$i]['nb_tasks'] = 0;
|
||||
|
||||
for ($j = 0; $j < $nb_columns; $j++) {
|
||||
$swimlanes[$i]['columns'][$j]['tasks'] = $this->taskFinder->getTasksByColumnAndSwimlane($project_id, $columns[$j]['id'], $swimlanes[$i]['id']);
|
||||
|
||||
$column_id = $columns[$j]['id'];
|
||||
$swimlane_id = $swimlanes[$i]['id'];
|
||||
|
||||
$swimlanes[$i]['columns'][$j]['tasks'] = $callback === null ? $this->taskFinder->getTasksByColumnAndSwimlane($project_id, $column_id, $swimlane_id) : $callback($project_id, $column_id, $swimlane_id);
|
||||
$swimlanes[$i]['columns'][$j]['nb_tasks'] = count($swimlanes[$i]['columns'][$j]['tasks']);
|
||||
$swimlanes[$i]['columns'][$j]['score'] = $this->getColumnSum($swimlanes[$i]['columns'][$j]['tasks'], 'score');
|
||||
$swimlanes[$i]['nb_tasks'] += $swimlanes[$i]['columns'][$j]['nb_tasks'];
|
||||
|
||||
@@ -512,6 +512,23 @@ class TaskFilter extends Base
|
||||
return $this->query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get swimlanes and tasks to display the board
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getBoard($project_id)
|
||||
{
|
||||
$tasks = $this->filterByProject($project_id)->query->asc(Task::TABLE.'.position')->findAll();
|
||||
|
||||
return $this->board->getBoard($project_id, function ($project_id, $column_id, $swimlane_id) use ($tasks) {
|
||||
return array_filter($tasks, function(array $task) use ($column_id, $swimlane_id) {
|
||||
return $task['column_id'] == $column_id && $task['swimlane_id'] == $swimlane_id;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the results to the ajax autocompletion
|
||||
*
|
||||
|
||||
@@ -12,20 +12,6 @@ use PDO;
|
||||
*/
|
||||
class TaskFinder extends Base
|
||||
{
|
||||
/**
|
||||
* Get query for closed tasks
|
||||
*
|
||||
* @access public
|
||||
* @param integer $project_id Project id
|
||||
* @return \PicoDb\Table
|
||||
*/
|
||||
public function getClosedTaskQuery($project_id)
|
||||
{
|
||||
return $this->getExtendedQuery()
|
||||
->eq(Task::TABLE.'.project_id', $project_id)
|
||||
->eq(Task::TABLE.'.is_active', Task::STATUS_CLOSED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get query for assigned user tasks
|
||||
*
|
||||
@@ -142,8 +128,8 @@ class TaskFinder extends Base
|
||||
{
|
||||
return $this->db
|
||||
->table(Task::TABLE)
|
||||
->eq('project_id', $project_id)
|
||||
->eq('is_active', $status_id)
|
||||
->eq(Task::TABLE.'.project_id', $project_id)
|
||||
->eq(Task::TABLE.'.is_active', $status_id)
|
||||
->findAll();
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,11 @@ class TaskPosition extends Base
|
||||
{
|
||||
$original_task = $this->taskFinder->getById($task_id);
|
||||
|
||||
// Ignore closed tasks
|
||||
if ($original_task['is_active'] == Task::STATUS_CLOSED) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$result = $this->calculateAndSave($project_id, $task_id, $column_id, $position, $swimlane_id);
|
||||
|
||||
if ($result) {
|
||||
|
||||
@@ -94,4 +94,28 @@ class UserSession extends Base
|
||||
{
|
||||
return ! empty($this->session['user']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get project filters from the session
|
||||
*
|
||||
* @access public
|
||||
* @param integer $project_id
|
||||
* @return string
|
||||
*/
|
||||
public function getFilters($project_id)
|
||||
{
|
||||
return ! empty($_SESSION['filters'][$project_id]) ? $_SESSION['filters'][$project_id] : 'status:open';
|
||||
}
|
||||
|
||||
/**
|
||||
* Save project filters in the session
|
||||
*
|
||||
* @access public
|
||||
* @param integer $project_id
|
||||
* @param string $filters
|
||||
*/
|
||||
public function setFilters($project_id, $filters)
|
||||
{
|
||||
$_SESSION['filters'][$project_id] = $filters;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user