diff options
author | Frederic Guillot <fred@kanboard.net> | 2017-03-12 21:36:52 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2017-03-12 21:36:52 -0400 |
commit | 9b34631135f29480dda3ed2df463fbb5aab7c9e4 (patch) | |
tree | 46da2f342a440cc699b7aa9c61bd18d0d2ea01f5 /app/Pagination | |
parent | f6b42eb8024b7db959f6d75118b3de0f96301262 (diff) |
Simplify dashboard to use new tasks list view
Diffstat (limited to 'app/Pagination')
-rw-r--r-- | app/Pagination/DashboardPagination.php | 50 | ||||
-rw-r--r-- | app/Pagination/ProjectPagination.php | 35 | ||||
-rw-r--r-- | app/Pagination/SubtaskPagination.php | 39 | ||||
-rw-r--r-- | app/Pagination/TaskPagination.php | 38 | ||||
-rw-r--r-- | app/Pagination/UserPagination.php | 2 |
5 files changed, 51 insertions, 113 deletions
diff --git a/app/Pagination/DashboardPagination.php b/app/Pagination/DashboardPagination.php new file mode 100644 index 00000000..b8fc4434 --- /dev/null +++ b/app/Pagination/DashboardPagination.php @@ -0,0 +1,50 @@ +<?php + +namespace Kanboard\Pagination; + +use Kanboard\Core\Base; +use Kanboard\Model\ProjectModel; +use Kanboard\Model\TaskModel; + +/** + * Class DashboardPagination + * + * @package Kanboard\Pagination + * @author Frederic Guillot + */ +class DashboardPagination extends Base +{ + /** + * Get user listing pagination + * + * @access public + * @param integer $userId + * @return array + */ + public function getOverview($userId) + { + $paginators = array(); + $projects = $this->projectUserRoleModel->getActiveProjectsByUser($userId); + + foreach ($projects as $projectId => $projectName) { + $paginator = $this->paginator + ->setUrl('DashboardController', 'show', array('user_id' => $userId)) + ->setMax(50) + ->setOrder(TaskModel::TABLE.'.priority') + ->setDirection('DESC') + ->setFormatter($this->taskListSubtaskAssigneeFormatter->withUserId($userId)) + ->setQuery($this->taskFinderModel->getUserQuery($userId)->eq(ProjectModel::TABLE.'.id', $projectId)) + ->calculate(); + + if ($paginator->getTotal() > 0) { + $paginators[] = array( + 'project_id' => $projectId, + 'project_name' => $projectName, + 'paginator' => $paginator, + ); + } + } + + return $paginators; + } +} diff --git a/app/Pagination/ProjectPagination.php b/app/Pagination/ProjectPagination.php deleted file mode 100644 index 8f1fa87c..00000000 --- a/app/Pagination/ProjectPagination.php +++ /dev/null @@ -1,35 +0,0 @@ -<?php - -namespace Kanboard\Pagination; - -use Kanboard\Core\Base; -use Kanboard\Core\Paginator; -use Kanboard\Model\ProjectModel; - -/** - * Class ProjectPagination - * - * @package Kanboard\Pagination - * @author Frederic Guillot - */ -class ProjectPagination extends Base -{ - /** - * Get dashboard pagination - * - * @access public - * @param integer $user_id - * @param string $method - * @param integer $max - * @return Paginator - */ - public function getDashboardPaginator($user_id, $method, $max) - { - return $this->paginator - ->setUrl('DashboardController', $method, 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'); - } -} diff --git a/app/Pagination/SubtaskPagination.php b/app/Pagination/SubtaskPagination.php deleted file mode 100644 index c55d0fb4..00000000 --- a/app/Pagination/SubtaskPagination.php +++ /dev/null @@ -1,39 +0,0 @@ -<?php - -namespace Kanboard\Pagination; - -use Kanboard\Core\Base; -use Kanboard\Core\Paginator; -use Kanboard\Model\SubtaskModel; -use Kanboard\Model\TaskModel; - -/** - * Class SubtaskPagination - * - * @package Kanboard\Pagination - * @author Frederic Guillot - */ -class SubtaskPagination extends Base -{ - /** - * Get dashboard pagination - * - * @access public - * @param integer $user_id - * @param string $method - * @param integer $max - * @return Paginator - */ - public function getDashboardPaginator($user_id, $method, $max) - { - $query = $this->subtaskModel->getUserQuery($user_id, array(SubtaskModel::STATUS_TODO, SubtaskModel::STATUS_INPROGRESS)); - $this->hook->reference('pagination:dashboard:subtask:query', $query); - - return $this->paginator - ->setUrl('DashboardController', $method, array('pagination' => 'subtasks', 'user_id' => $user_id)) - ->setMax($max) - ->setOrder(TaskModel::TABLE.'.id') - ->setQuery($query) - ->calculateOnlyIf($this->request->getStringParam('pagination') === 'subtasks'); - } -} diff --git a/app/Pagination/TaskPagination.php b/app/Pagination/TaskPagination.php deleted file mode 100644 index 5fe986e7..00000000 --- a/app/Pagination/TaskPagination.php +++ /dev/null @@ -1,38 +0,0 @@ -<?php - -namespace Kanboard\Pagination; - -use Kanboard\Core\Base; -use Kanboard\Core\Paginator; -use Kanboard\Model\TaskModel; - -/** - * Class TaskPagination - * - * @package Kanboard\Pagination - * @author Frederic Guillot - */ -class TaskPagination extends Base -{ - /** - * Get dashboard pagination - * - * @access public - * @param integer $user_id - * @param string $method - * @param integer $max - * @return Paginator - */ - public function getDashboardPaginator($user_id, $method, $max) - { - $query = $this->taskFinderModel->getUserQuery($user_id); - $this->hook->reference('pagination:dashboard:task:query', $query); - - return $this->paginator - ->setUrl('DashboardController', $method, array('pagination' => 'tasks', 'user_id' => $user_id)) - ->setMax($max) - ->setOrder(TaskModel::TABLE.'.id') - ->setQuery($query) - ->calculateOnlyIf($this->request->getStringParam('pagination') === 'tasks'); - } -} diff --git a/app/Pagination/UserPagination.php b/app/Pagination/UserPagination.php index 430b7d2f..87688573 100644 --- a/app/Pagination/UserPagination.php +++ b/app/Pagination/UserPagination.php @@ -15,7 +15,7 @@ use Kanboard\Model\UserModel; class UserPagination extends Base { /** - * Get user listing paginator + * Get user listing pagination * * @access public * @return Paginator |