Move dashboard pagination into separate classes
This commit is contained in:
@@ -2,9 +2,6 @@
|
||||
|
||||
namespace Kanboard\Controller;
|
||||
|
||||
use Kanboard\Model\ProjectModel;
|
||||
use Kanboard\Model\SubtaskModel;
|
||||
|
||||
/**
|
||||
* Dashboard Controller
|
||||
*
|
||||
@@ -13,63 +10,6 @@ use Kanboard\Model\SubtaskModel;
|
||||
*/
|
||||
class DashboardController extends BaseController
|
||||
{
|
||||
/**
|
||||
* Get project pagination
|
||||
*
|
||||
* @access private
|
||||
* @param integer $user_id
|
||||
* @param string $action
|
||||
* @param integer $max
|
||||
* @return \Kanboard\Core\Paginator
|
||||
*/
|
||||
private function getProjectPaginator($user_id, $action, $max)
|
||||
{
|
||||
return $this->paginator
|
||||
->setUrl('DashboardController', $action, array('pagination' => 'projects', 'user_id' => $user_id))
|
||||
->setMax($max)
|
||||
->setOrder(ProjectModel::TABLE.'.name')
|
||||
->setQuery($this->projectModel->getQueryColumnStats($this->projectPermissionModel->getActiveProjectIds($user_id)))
|
||||
->calculateOnlyIf($this->request->getStringParam('pagination') === 'projects');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get task pagination
|
||||
*
|
||||
* @access private
|
||||
* @param integer $user_id
|
||||
* @param string $action
|
||||
* @param integer $max
|
||||
* @return \Kanboard\Core\Paginator
|
||||
*/
|
||||
private function getTaskPaginator($user_id, $action, $max)
|
||||
{
|
||||
return $this->paginator
|
||||
->setUrl('DashboardController', $action, array('pagination' => 'tasks', 'user_id' => $user_id))
|
||||
->setMax($max)
|
||||
->setOrder('tasks.id')
|
||||
->setQuery($this->taskFinderModel->getUserQuery($user_id))
|
||||
->calculateOnlyIf($this->request->getStringParam('pagination') === 'tasks');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get subtask pagination
|
||||
*
|
||||
* @access private
|
||||
* @param integer $user_id
|
||||
* @param string $action
|
||||
* @param integer $max
|
||||
* @return \Kanboard\Core\Paginator
|
||||
*/
|
||||
private function getSubtaskPaginator($user_id, $action, $max)
|
||||
{
|
||||
return $this->paginator
|
||||
->setUrl('DashboardController', $action, array('pagination' => 'subtasks', 'user_id' => $user_id))
|
||||
->setMax($max)
|
||||
->setOrder('tasks.id')
|
||||
->setQuery($this->subtaskModel->getUserQuery($user_id, array(SubTaskModel::STATUS_TODO, SubtaskModel::STATUS_INPROGRESS)))
|
||||
->calculateOnlyIf($this->request->getStringParam('pagination') === 'subtasks');
|
||||
}
|
||||
|
||||
/**
|
||||
* Dashboard overview
|
||||
*
|
||||
@@ -81,9 +21,9 @@ class DashboardController extends BaseController
|
||||
|
||||
$this->response->html($this->helper->layout->dashboard('dashboard/show', array(
|
||||
'title' => t('Dashboard'),
|
||||
'project_paginator' => $this->getProjectPaginator($user['id'], 'show', 10),
|
||||
'task_paginator' => $this->getTaskPaginator($user['id'], 'show', 10),
|
||||
'subtask_paginator' => $this->getSubtaskPaginator($user['id'], 'show', 10),
|
||||
'project_paginator' => $this->projectPagination->getDashboardPaginator($user['id'], 'show', 10),
|
||||
'task_paginator' => $this->taskPagination->getDashboardPaginator($user['id'], 'show', 10),
|
||||
'subtask_paginator' => $this->subtaskPagination->getDashboardPaginator($user['id'], 'show', 10),
|
||||
'user' => $user,
|
||||
)));
|
||||
}
|
||||
@@ -99,7 +39,7 @@ class DashboardController extends BaseController
|
||||
|
||||
$this->response->html($this->helper->layout->dashboard('dashboard/tasks', array(
|
||||
'title' => t('My tasks'),
|
||||
'paginator' => $this->getTaskPaginator($user['id'], 'tasks', 50),
|
||||
'paginator' => $this->taskPagination->getDashboardPaginator($user['id'], 'tasks', 50),
|
||||
'user' => $user,
|
||||
)));
|
||||
}
|
||||
@@ -115,7 +55,7 @@ class DashboardController extends BaseController
|
||||
|
||||
$this->response->html($this->helper->layout->dashboard('dashboard/subtasks', array(
|
||||
'title' => t('My subtasks'),
|
||||
'paginator' => $this->getSubtaskPaginator($user['id'], 'subtasks', 50),
|
||||
'paginator' => $this->subtaskPagination->getDashboardPaginator($user['id'], 'subtasks', 50),
|
||||
'user' => $user,
|
||||
)));
|
||||
}
|
||||
@@ -131,7 +71,7 @@ class DashboardController extends BaseController
|
||||
|
||||
$this->response->html($this->helper->layout->dashboard('dashboard/projects', array(
|
||||
'title' => t('My projects'),
|
||||
'paginator' => $this->getProjectPaginator($user['id'], 'projects', 25),
|
||||
'paginator' => $this->projectPagination->getDashboardPaginator($user['id'], 'projects', 25),
|
||||
'user' => $user,
|
||||
)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user