Move dashboard pagination into separate classes
This commit is contained in:
@@ -2,9 +2,6 @@
|
|||||||
|
|
||||||
namespace Kanboard\Controller;
|
namespace Kanboard\Controller;
|
||||||
|
|
||||||
use Kanboard\Model\ProjectModel;
|
|
||||||
use Kanboard\Model\SubtaskModel;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dashboard Controller
|
* Dashboard Controller
|
||||||
*
|
*
|
||||||
@@ -13,63 +10,6 @@ use Kanboard\Model\SubtaskModel;
|
|||||||
*/
|
*/
|
||||||
class DashboardController extends BaseController
|
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
|
* Dashboard overview
|
||||||
*
|
*
|
||||||
@@ -81,9 +21,9 @@ class DashboardController extends BaseController
|
|||||||
|
|
||||||
$this->response->html($this->helper->layout->dashboard('dashboard/show', array(
|
$this->response->html($this->helper->layout->dashboard('dashboard/show', array(
|
||||||
'title' => t('Dashboard'),
|
'title' => t('Dashboard'),
|
||||||
'project_paginator' => $this->getProjectPaginator($user['id'], 'show', 10),
|
'project_paginator' => $this->projectPagination->getDashboardPaginator($user['id'], 'show', 10),
|
||||||
'task_paginator' => $this->getTaskPaginator($user['id'], 'show', 10),
|
'task_paginator' => $this->taskPagination->getDashboardPaginator($user['id'], 'show', 10),
|
||||||
'subtask_paginator' => $this->getSubtaskPaginator($user['id'], 'show', 10),
|
'subtask_paginator' => $this->subtaskPagination->getDashboardPaginator($user['id'], 'show', 10),
|
||||||
'user' => $user,
|
'user' => $user,
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
@@ -99,7 +39,7 @@ class DashboardController extends BaseController
|
|||||||
|
|
||||||
$this->response->html($this->helper->layout->dashboard('dashboard/tasks', array(
|
$this->response->html($this->helper->layout->dashboard('dashboard/tasks', array(
|
||||||
'title' => t('My tasks'),
|
'title' => t('My tasks'),
|
||||||
'paginator' => $this->getTaskPaginator($user['id'], 'tasks', 50),
|
'paginator' => $this->taskPagination->getDashboardPaginator($user['id'], 'tasks', 50),
|
||||||
'user' => $user,
|
'user' => $user,
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
@@ -115,7 +55,7 @@ class DashboardController extends BaseController
|
|||||||
|
|
||||||
$this->response->html($this->helper->layout->dashboard('dashboard/subtasks', array(
|
$this->response->html($this->helper->layout->dashboard('dashboard/subtasks', array(
|
||||||
'title' => t('My subtasks'),
|
'title' => t('My subtasks'),
|
||||||
'paginator' => $this->getSubtaskPaginator($user['id'], 'subtasks', 50),
|
'paginator' => $this->subtaskPagination->getDashboardPaginator($user['id'], 'subtasks', 50),
|
||||||
'user' => $user,
|
'user' => $user,
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
@@ -131,7 +71,7 @@ class DashboardController extends BaseController
|
|||||||
|
|
||||||
$this->response->html($this->helper->layout->dashboard('dashboard/projects', array(
|
$this->response->html($this->helper->layout->dashboard('dashboard/projects', array(
|
||||||
'title' => t('My projects'),
|
'title' => t('My projects'),
|
||||||
'paginator' => $this->getProjectPaginator($user['id'], 'projects', 25),
|
'paginator' => $this->projectPagination->getDashboardPaginator($user['id'], 'projects', 25),
|
||||||
'user' => $user,
|
'user' => $user,
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,12 +17,7 @@ class UserListController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function show()
|
public function show()
|
||||||
{
|
{
|
||||||
$paginator = $this->paginator
|
$paginator = $this->userPagination->getListingPaginator();
|
||||||
->setUrl('UserListController', 'show')
|
|
||||||
->setMax(30)
|
|
||||||
->setOrder('username')
|
|
||||||
->setQuery($this->userModel->getQuery())
|
|
||||||
->calculate();
|
|
||||||
|
|
||||||
$this->response->html($this->helper->layout->app('user_list/show', array(
|
$this->response->html($this->helper->layout->app('user_list/show', array(
|
||||||
'title' => t('Users').' ('.$paginator->getTotal().')',
|
'title' => t('Users').' ('.$paginator->getTotal().')',
|
||||||
|
|||||||
@@ -122,6 +122,10 @@ use Pimple\Container;
|
|||||||
* @property \Kanboard\Model\UserNotificationFilterModel $userNotificationFilterModel
|
* @property \Kanboard\Model\UserNotificationFilterModel $userNotificationFilterModel
|
||||||
* @property \Kanboard\Model\UserUnreadNotificationModel $userUnreadNotificationModel
|
* @property \Kanboard\Model\UserUnreadNotificationModel $userUnreadNotificationModel
|
||||||
* @property \Kanboard\Model\UserMetadataModel $userMetadataModel
|
* @property \Kanboard\Model\UserMetadataModel $userMetadataModel
|
||||||
|
* @property \Kanboard\Pagination\TaskPagination $taskPagination
|
||||||
|
* @property \Kanboard\Pagination\SubtaskPagination $subtaskPagination
|
||||||
|
* @property \Kanboard\Pagination\ProjectPagination $projectPagination
|
||||||
|
* @property \Kanboard\Pagination\UserPagination $userPagination
|
||||||
* @property \Kanboard\Validator\ActionValidator $actionValidator
|
* @property \Kanboard\Validator\ActionValidator $actionValidator
|
||||||
* @property \Kanboard\Validator\AuthValidator $authValidator
|
* @property \Kanboard\Validator\AuthValidator $authValidator
|
||||||
* @property \Kanboard\Validator\ColumnValidator $columnValidator
|
* @property \Kanboard\Validator\ColumnValidator $columnValidator
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ class ProjectDuplicationModel extends Base
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make sure that the creator of the duplicated project is alsp owner
|
* Make sure that the creator of the duplicated project is also owner
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param integer $dst_project_id
|
* @param integer $dst_project_id
|
||||||
|
|||||||
@@ -318,7 +318,7 @@ class ProjectModel extends Base
|
|||||||
public function getQueryColumnStats(array $project_ids)
|
public function getQueryColumnStats(array $project_ids)
|
||||||
{
|
{
|
||||||
if (empty($project_ids)) {
|
if (empty($project_ids)) {
|
||||||
return $this->db->table(ProjectModel::TABLE)->limit(0);
|
return $this->db->table(ProjectModel::TABLE)->eq(ProjectModel::TABLE.'.id', 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->db
|
return $this->db
|
||||||
|
|||||||
@@ -63,19 +63,19 @@ class TaskFinderModel extends Base
|
|||||||
return $this->db
|
return $this->db
|
||||||
->table(TaskModel::TABLE)
|
->table(TaskModel::TABLE)
|
||||||
->columns(
|
->columns(
|
||||||
'tasks.id',
|
TaskModel::TABLE.'.id',
|
||||||
'tasks.title',
|
TaskModel::TABLE.'.title',
|
||||||
'tasks.date_due',
|
TaskModel::TABLE.'.date_due',
|
||||||
'tasks.date_creation',
|
TaskModel::TABLE.'.date_creation',
|
||||||
'tasks.project_id',
|
TaskModel::TABLE.'.project_id',
|
||||||
'tasks.color_id',
|
TaskModel::TABLE.'.color_id',
|
||||||
'tasks.priority',
|
TaskModel::TABLE.'.priority',
|
||||||
'tasks.time_spent',
|
TaskModel::TABLE.'.time_spent',
|
||||||
'tasks.time_estimated',
|
TaskModel::TABLE.'.time_estimated',
|
||||||
'tasks.is_active',
|
TaskModel::TABLE.'.is_active',
|
||||||
'tasks.creator_id',
|
TaskModel::TABLE.'.creator_id',
|
||||||
'projects.name AS project_name',
|
ProjectModel::TABLE.'.name AS project_name',
|
||||||
'columns.title AS column_title'
|
ColumnModel::TABLE.'.title AS column_title'
|
||||||
)
|
)
|
||||||
->join(ProjectModel::TABLE, 'id', 'project_id')
|
->join(ProjectModel::TABLE, 'id', 'project_id')
|
||||||
->join(ColumnModel::TABLE, 'id', 'column_id')
|
->join(ColumnModel::TABLE, 'id', 'column_id')
|
||||||
@@ -103,36 +103,36 @@ class TaskFinderModel extends Base
|
|||||||
'(SELECT COUNT(*) FROM '.TaskLinkModel::TABLE.' WHERE '.TaskLinkModel::TABLE.'.task_id = tasks.id) AS nb_links',
|
'(SELECT COUNT(*) FROM '.TaskLinkModel::TABLE.' WHERE '.TaskLinkModel::TABLE.'.task_id = tasks.id) AS nb_links',
|
||||||
'(SELECT COUNT(*) FROM '.TaskExternalLinkModel::TABLE.' WHERE '.TaskExternalLinkModel::TABLE.'.task_id = tasks.id) AS nb_external_links',
|
'(SELECT COUNT(*) FROM '.TaskExternalLinkModel::TABLE.' WHERE '.TaskExternalLinkModel::TABLE.'.task_id = tasks.id) AS nb_external_links',
|
||||||
'(SELECT DISTINCT 1 FROM '.TaskLinkModel::TABLE.' WHERE '.TaskLinkModel::TABLE.'.task_id = tasks.id AND '.TaskLinkModel::TABLE.'.link_id = 9) AS is_milestone',
|
'(SELECT DISTINCT 1 FROM '.TaskLinkModel::TABLE.' WHERE '.TaskLinkModel::TABLE.'.task_id = tasks.id AND '.TaskLinkModel::TABLE.'.link_id = 9) AS is_milestone',
|
||||||
'tasks.id',
|
TaskModel::TABLE.'.id',
|
||||||
'tasks.reference',
|
TaskModel::TABLE.'.reference',
|
||||||
'tasks.title',
|
TaskModel::TABLE.'.title',
|
||||||
'tasks.description',
|
TaskModel::TABLE.'.description',
|
||||||
'tasks.date_creation',
|
TaskModel::TABLE.'.date_creation',
|
||||||
'tasks.date_modification',
|
TaskModel::TABLE.'.date_modification',
|
||||||
'tasks.date_completed',
|
TaskModel::TABLE.'.date_completed',
|
||||||
'tasks.date_started',
|
TaskModel::TABLE.'.date_started',
|
||||||
'tasks.date_due',
|
TaskModel::TABLE.'.date_due',
|
||||||
'tasks.color_id',
|
TaskModel::TABLE.'.color_id',
|
||||||
'tasks.project_id',
|
TaskModel::TABLE.'.project_id',
|
||||||
'tasks.column_id',
|
TaskModel::TABLE.'.column_id',
|
||||||
'tasks.swimlane_id',
|
TaskModel::TABLE.'.swimlane_id',
|
||||||
'tasks.owner_id',
|
TaskModel::TABLE.'.owner_id',
|
||||||
'tasks.creator_id',
|
TaskModel::TABLE.'.creator_id',
|
||||||
'tasks.position',
|
TaskModel::TABLE.'.position',
|
||||||
'tasks.is_active',
|
TaskModel::TABLE.'.is_active',
|
||||||
'tasks.score',
|
TaskModel::TABLE.'.score',
|
||||||
'tasks.category_id',
|
TaskModel::TABLE.'.category_id',
|
||||||
'tasks.priority',
|
TaskModel::TABLE.'.priority',
|
||||||
'tasks.date_moved',
|
TaskModel::TABLE.'.date_moved',
|
||||||
'tasks.recurrence_status',
|
TaskModel::TABLE.'.recurrence_status',
|
||||||
'tasks.recurrence_trigger',
|
TaskModel::TABLE.'.recurrence_trigger',
|
||||||
'tasks.recurrence_factor',
|
TaskModel::TABLE.'.recurrence_factor',
|
||||||
'tasks.recurrence_timeframe',
|
TaskModel::TABLE.'.recurrence_timeframe',
|
||||||
'tasks.recurrence_basedate',
|
TaskModel::TABLE.'.recurrence_basedate',
|
||||||
'tasks.recurrence_parent',
|
TaskModel::TABLE.'.recurrence_parent',
|
||||||
'tasks.recurrence_child',
|
TaskModel::TABLE.'.recurrence_child',
|
||||||
'tasks.time_estimated',
|
TaskModel::TABLE.'.time_estimated',
|
||||||
'tasks.time_spent',
|
TaskModel::TABLE.'.time_spent',
|
||||||
UserModel::TABLE.'.username AS assignee_username',
|
UserModel::TABLE.'.username AS assignee_username',
|
||||||
UserModel::TABLE.'.name AS assignee_name',
|
UserModel::TABLE.'.name AS assignee_name',
|
||||||
UserModel::TABLE.'.email AS assignee_email',
|
UserModel::TABLE.'.email AS assignee_email',
|
||||||
|
|||||||
35
app/Pagination/ProjectPagination.php
Normal file
35
app/Pagination/ProjectPagination.php
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<?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');
|
||||||
|
}
|
||||||
|
}
|
||||||
36
app/Pagination/SubtaskPagination.php
Normal file
36
app/Pagination/SubtaskPagination.php
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<?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)
|
||||||
|
{
|
||||||
|
return $this->paginator
|
||||||
|
->setUrl('DashboardController', $method, array('pagination' => 'subtasks', 'user_id' => $user_id))
|
||||||
|
->setMax($max)
|
||||||
|
->setOrder(TaskModel::TABLE.'.id')
|
||||||
|
->setQuery($this->subtaskModel->getUserQuery($user_id, array(SubtaskModel::STATUS_TODO, SubtaskModel::STATUS_INPROGRESS)))
|
||||||
|
->calculateOnlyIf($this->request->getStringParam('pagination') === 'subtasks');
|
||||||
|
}
|
||||||
|
}
|
||||||
35
app/Pagination/TaskPagination.php
Normal file
35
app/Pagination/TaskPagination.php
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<?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)
|
||||||
|
{
|
||||||
|
return $this->paginator
|
||||||
|
->setUrl('DashboardController', $method, array('pagination' => 'tasks', 'user_id' => $user_id))
|
||||||
|
->setMax($max)
|
||||||
|
->setOrder(TaskModel::TABLE.'.id')
|
||||||
|
->setQuery($this->taskFinderModel->getUserQuery($user_id))
|
||||||
|
->calculateOnlyIf($this->request->getStringParam('pagination') === 'tasks');
|
||||||
|
}
|
||||||
|
}
|
||||||
32
app/Pagination/UserPagination.php
Normal file
32
app/Pagination/UserPagination.php
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Kanboard\Pagination;
|
||||||
|
|
||||||
|
use Kanboard\Core\Base;
|
||||||
|
use Kanboard\Core\Paginator;
|
||||||
|
use Kanboard\Model\UserModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class UserPagination
|
||||||
|
*
|
||||||
|
* @package Kanboard\Pagination
|
||||||
|
* @author Frederic Guillot
|
||||||
|
*/
|
||||||
|
class UserPagination extends Base
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get user listing paginator
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return Paginator
|
||||||
|
*/
|
||||||
|
public function getListingPaginator()
|
||||||
|
{
|
||||||
|
return $this->paginator
|
||||||
|
->setUrl('UserListController', 'show')
|
||||||
|
->setMax(30)
|
||||||
|
->setOrder(UserModel::TABLE.'.username')
|
||||||
|
->setQuery($this->userModel->getQuery())
|
||||||
|
->calculate();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -122,6 +122,12 @@ class ClassProvider implements ServiceProviderInterface
|
|||||||
'TaskExport',
|
'TaskExport',
|
||||||
'TransitionExport',
|
'TransitionExport',
|
||||||
),
|
),
|
||||||
|
'Pagination' => array(
|
||||||
|
'TaskPagination',
|
||||||
|
'SubtaskPagination',
|
||||||
|
'ProjectPagination',
|
||||||
|
'UserPagination',
|
||||||
|
),
|
||||||
'Core' => array(
|
'Core' => array(
|
||||||
'DateParser',
|
'DateParser',
|
||||||
'Lexer',
|
'Lexer',
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<table class="table-fixed table-small">
|
<table class="table-fixed table-small">
|
||||||
<tr>
|
<tr>
|
||||||
<th class="column-5"><?= $paginator->order('Id', 'id') ?></th>
|
<th class="column-5"><?= $paginator->order('Id', \Kanboard\Model\ProjectModel::TABLE.'.id') ?></th>
|
||||||
<th class="column-3"><?= $paginator->order('<i class="fa fa-lock fa-fw" title="'.t('Private project').'"></i>', 'is_private') ?></th>
|
<th class="column-3"><?= $paginator->order('<i class="fa fa-lock fa-fw" title="'.t('Private project').'"></i>', \Kanboard\Model\ProjectModel::TABLE.'.is_private') ?></th>
|
||||||
<th class="column-25"><?= $paginator->order(t('Project'), \Kanboard\Model\ProjectModel::TABLE.'.name') ?></th>
|
<th class="column-25"><?= $paginator->order(t('Project'), \Kanboard\Model\ProjectModel::TABLE.'.name') ?></th>
|
||||||
<th class="column-10"><?= t('Tasks') ?></th>
|
<th class="column-10"><?= t('Tasks') ?></th>
|
||||||
<th><?= t('Columns') ?></th>
|
<th><?= t('Columns') ?></th>
|
||||||
|
|||||||
@@ -6,10 +6,10 @@
|
|||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<table class="table-fixed table-small">
|
<table class="table-fixed table-small">
|
||||||
<tr>
|
<tr>
|
||||||
<th class="column-5"><?= $paginator->order('Id', 'tasks.id') ?></th>
|
<th class="column-5"><?= $paginator->order('Id', \Kanboard\Model\TaskModel::TABLE.'.id') ?></th>
|
||||||
<th class="column-20"><?= $paginator->order(t('Project'), 'project_name') ?></th>
|
<th class="column-20"><?= $paginator->order(t('Project'), 'project_name') ?></th>
|
||||||
<th><?= $paginator->order(t('Task'), 'task_name') ?></th>
|
<th><?= $paginator->order(t('Task'), 'task_name') ?></th>
|
||||||
<th><?= $paginator->order(t('Subtask'), 'title') ?></th>
|
<th><?= $paginator->order(t('Subtask'), \Kanboard\Model\SubtaskModel::TABLE.'.title') ?></th>
|
||||||
<th class="column-20"><?= t('Time tracking') ?></th>
|
<th class="column-20"><?= t('Time tracking') ?></th>
|
||||||
</tr>
|
</tr>
|
||||||
<?php foreach ($paginator->getCollection() as $subtask): ?>
|
<?php foreach ($paginator->getCollection() as $subtask): ?>
|
||||||
|
|||||||
@@ -6,12 +6,12 @@
|
|||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<table class="table-fixed table-small">
|
<table class="table-fixed table-small">
|
||||||
<tr>
|
<tr>
|
||||||
<th class="column-5"><?= $paginator->order('Id', 'tasks.id') ?></th>
|
<th class="column-5"><?= $paginator->order('Id', \Kanboard\Model\TaskModel::TABLE.'.id') ?></th>
|
||||||
<th class="column-20"><?= $paginator->order(t('Project'), 'project_name') ?></th>
|
<th class="column-20"><?= $paginator->order(t('Project'), 'project_name') ?></th>
|
||||||
<th><?= $paginator->order(t('Task'), 'title') ?></th>
|
<th><?= $paginator->order(t('Task'), \Kanboard\Model\TaskModel::TABLE.'.title') ?></th>
|
||||||
<th class="column-5"><?= $paginator->order(t('Priority'), 'tasks.priority') ?></th>
|
<th class="column-5"><?= $paginator->order(t('Priority'), \Kanboard\Model\TaskModel::TABLE.'.priority') ?></th>
|
||||||
<th class="column-20"><?= t('Time tracking') ?></th>
|
<th class="column-20"><?= t('Time tracking') ?></th>
|
||||||
<th class="column-10"><?= $paginator->order(t('Due date'), 'date_due') ?></th>
|
<th class="column-10"><?= $paginator->order(t('Due date'), \Kanboard\Model\TaskModel::TABLE.'.date_due') ?></th>
|
||||||
<th class="column-10"><?= $paginator->order(t('Column'), 'column_title') ?></th>
|
<th class="column-10"><?= $paginator->order(t('Column'), 'column_title') ?></th>
|
||||||
</tr>
|
</tr>
|
||||||
<?php foreach ($paginator->getCollection() as $task): ?>
|
<?php foreach ($paginator->getCollection() as $task): ?>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ use Kanboard\Model\ProjectModel;
|
|||||||
|
|
||||||
class TaskFinderModelTest extends Base
|
class TaskFinderModelTest extends Base
|
||||||
{
|
{
|
||||||
public function testGetTasksForDashboard()
|
public function testGetTasksForDashboardWithHiddenColumn()
|
||||||
{
|
{
|
||||||
$taskCreationModel = new TaskCreationModel($this->container);
|
$taskCreationModel = new TaskCreationModel($this->container);
|
||||||
$taskFinderModel = new TaskFinderModel($this->container);
|
$taskFinderModel = new TaskFinderModel($this->container);
|
||||||
|
|||||||
35
tests/units/Pagination/ProjectPaginationTest.php
Normal file
35
tests/units/Pagination/ProjectPaginationTest.php
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Kanboard\Core\Security\Role;
|
||||||
|
use Kanboard\Model\ProjectModel;
|
||||||
|
use Kanboard\Model\ProjectUserRoleModel;
|
||||||
|
use Kanboard\Model\UserModel;
|
||||||
|
use Kanboard\Pagination\ProjectPagination;
|
||||||
|
|
||||||
|
require_once __DIR__.'/../Base.php';
|
||||||
|
|
||||||
|
class ProjectPaginationTest extends Base
|
||||||
|
{
|
||||||
|
public function testDashboardPagination()
|
||||||
|
{
|
||||||
|
$projectModel = new ProjectModel($this->container);
|
||||||
|
$projectUserRoleModel = new ProjectUserRoleModel($this->container);
|
||||||
|
$userModel = new UserModel($this->container);
|
||||||
|
$projectPagination = new ProjectPagination($this->container);
|
||||||
|
|
||||||
|
$this->assertEquals(1, $projectModel->create(array('name' => 'Project #1')));
|
||||||
|
$this->assertEquals(2, $projectModel->create(array('name' => 'Project #2', 'is_private' => 1)));
|
||||||
|
$this->assertEquals(3, $projectModel->create(array('name' => 'Project #3')));
|
||||||
|
$this->assertEquals(4, $projectModel->create(array('name' => 'Project #4', 'is_private' => 1)));
|
||||||
|
|
||||||
|
$this->assertEquals(2, $userModel->create(array('username' => 'test')));
|
||||||
|
$this->assertTrue($projectUserRoleModel->addUser(1, 2, Role::PROJECT_MANAGER));
|
||||||
|
$this->assertTrue($projectUserRoleModel->addUser(2, 2, Role::PROJECT_MANAGER));
|
||||||
|
|
||||||
|
$this->assertCount(2, $projectPagination->getDashboardPaginator(2, 'projects', 5)->getCollection());
|
||||||
|
$this->assertCount(0, $projectPagination->getDashboardPaginator(3, 'projects', 5)->getCollection());
|
||||||
|
$this->assertCount(2, $projectPagination->getDashboardPaginator(2, 'projects', 5)->setOrder(ProjectModel::TABLE.'.id')->getCollection());
|
||||||
|
$this->assertCount(2, $projectPagination->getDashboardPaginator(2, 'projects', 5)->setOrder(ProjectModel::TABLE.'.is_private')->getCollection());
|
||||||
|
$this->assertCount(2, $projectPagination->getDashboardPaginator(2, 'projects', 5)->setOrder(ProjectModel::TABLE.'.name')->getCollection());
|
||||||
|
}
|
||||||
|
}
|
||||||
36
tests/units/Pagination/SubtaskPaginationTest.php
Normal file
36
tests/units/Pagination/SubtaskPaginationTest.php
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Kanboard\Model\ProjectModel;
|
||||||
|
use Kanboard\Model\SubtaskModel;
|
||||||
|
use Kanboard\Model\TaskCreationModel;
|
||||||
|
use Kanboard\Model\TaskModel;
|
||||||
|
use Kanboard\Pagination\SubtaskPagination;
|
||||||
|
|
||||||
|
require_once __DIR__.'/../Base.php';
|
||||||
|
|
||||||
|
class SubtaskPaginationTest extends Base
|
||||||
|
{
|
||||||
|
public function testDashboardPagination()
|
||||||
|
{
|
||||||
|
$taskCreationModel = new TaskCreationModel($this->container);
|
||||||
|
$projectModel = new ProjectModel($this->container);
|
||||||
|
$subtaskModel = new SubtaskModel($this->container);
|
||||||
|
$subtaskPagination = new SubtaskPagination($this->container);
|
||||||
|
|
||||||
|
$this->assertEquals(1, $projectModel->create(array('name' => 'Project #1')));
|
||||||
|
$this->assertEquals(1, $taskCreationModel->create(array('title' => 'Task #1', 'project_id' => 1)));
|
||||||
|
$this->assertEquals(2, $taskCreationModel->create(array('title' => 'Task #2', 'project_id' => 1, 'column_id' => 2, 'owner_id' => 1)));
|
||||||
|
$this->assertEquals(1, $subtaskModel->create(array('task_id' => 1, 'title' => 'subtask #1', 'user_id' => 1)));
|
||||||
|
$this->assertEquals(2, $subtaskModel->create(array('task_id' => 2, 'title' => 'subtask #1', 'user_id' => 1)));
|
||||||
|
$this->assertEquals(3, $subtaskModel->create(array('task_id' => 1, 'title' => 'subtask #1', 'user_id' => 1)));
|
||||||
|
$this->assertEquals(4, $subtaskModel->create(array('task_id' => 2, 'title' => 'subtask #1')));
|
||||||
|
$this->assertEquals(5, $subtaskModel->create(array('task_id' => 1, 'title' => 'subtask #1')));
|
||||||
|
|
||||||
|
$this->assertCount(3, $subtaskPagination->getDashboardPaginator(1, 'subtasks', 5)->getCollection());
|
||||||
|
$this->assertCount(0, $subtaskPagination->getDashboardPaginator(2, 'subtasks', 5)->getCollection());
|
||||||
|
$this->assertCount(3, $subtaskPagination->getDashboardPaginator(1, 'subtasks', 5)->setOrder(TaskModel::TABLE.'.id')->getCollection());
|
||||||
|
$this->assertCount(3, $subtaskPagination->getDashboardPaginator(1, 'subtasks', 5)->setOrder('project_name')->getCollection());
|
||||||
|
$this->assertCount(3, $subtaskPagination->getDashboardPaginator(1, 'subtasks', 5)->setOrder('task_name')->getCollection());
|
||||||
|
$this->assertCount(3, $subtaskPagination->getDashboardPaginator(1, 'subtasks', 5)->setOrder(SubtaskModel::TABLE.'.title')->getCollection());
|
||||||
|
}
|
||||||
|
}
|
||||||
30
tests/units/Pagination/TaskPaginationTest.php
Normal file
30
tests/units/Pagination/TaskPaginationTest.php
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Kanboard\Model\ProjectModel;
|
||||||
|
use Kanboard\Model\TaskCreationModel;
|
||||||
|
use Kanboard\Model\TaskModel;
|
||||||
|
use Kanboard\Pagination\TaskPagination;
|
||||||
|
|
||||||
|
require_once __DIR__.'/../Base.php';
|
||||||
|
|
||||||
|
class TaskPaginationTest extends Base
|
||||||
|
{
|
||||||
|
public function testDashboardPagination()
|
||||||
|
{
|
||||||
|
$taskCreationModel = new TaskCreationModel($this->container);
|
||||||
|
$projectModel = new ProjectModel($this->container);
|
||||||
|
$taskPagination = new TaskPagination($this->container);
|
||||||
|
|
||||||
|
$this->assertEquals(1, $projectModel->create(array('name' => 'Project #1')));
|
||||||
|
$this->assertEquals(1, $taskCreationModel->create(array('title' => 'Task #1', 'project_id' => 1)));
|
||||||
|
$this->assertEquals(2, $taskCreationModel->create(array('title' => 'Task #2', 'project_id' => 1, 'column_id' => 2, 'owner_id' => 1)));
|
||||||
|
|
||||||
|
$this->assertCount(1, $taskPagination->getDashboardPaginator(1, 'tasks', 5)->getCollection());
|
||||||
|
$this->assertCount(0, $taskPagination->getDashboardPaginator(2, 'tasks', 5)->getCollection());
|
||||||
|
$this->assertCount(1, $taskPagination->getDashboardPaginator(1, 'tasks', 5)->setOrder(TaskModel::TABLE.'.id')->getCollection());
|
||||||
|
$this->assertCount(1, $taskPagination->getDashboardPaginator(1, 'tasks', 5)->setOrder('project_name')->getCollection());
|
||||||
|
$this->assertCount(1, $taskPagination->getDashboardPaginator(1, 'tasks', 5)->setOrder(TaskModel::TABLE.'.title')->getCollection());
|
||||||
|
$this->assertCount(1, $taskPagination->getDashboardPaginator(1, 'tasks', 5)->setOrder(TaskModel::TABLE.'.priority')->getCollection());
|
||||||
|
$this->assertCount(1, $taskPagination->getDashboardPaginator(1, 'tasks', 5)->setOrder(TaskModel::TABLE.'.date_due')->getCollection());
|
||||||
|
}
|
||||||
|
}
|
||||||
27
tests/units/Pagination/UserPaginationTest.php
Normal file
27
tests/units/Pagination/UserPaginationTest.php
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Kanboard\Model\UserModel;
|
||||||
|
use Kanboard\Pagination\UserPagination;
|
||||||
|
|
||||||
|
require_once __DIR__.'/../Base.php';
|
||||||
|
|
||||||
|
class UserPaginationTest extends Base
|
||||||
|
{
|
||||||
|
public function testListingPagination()
|
||||||
|
{
|
||||||
|
$userModel = new UserModel($this->container);
|
||||||
|
$userPagination = new UserPagination($this->container);
|
||||||
|
|
||||||
|
$this->assertEquals(2, $userModel->create(array('username' => 'test1')));
|
||||||
|
$this->assertEquals(3, $userModel->create(array('username' => 'test2')));
|
||||||
|
|
||||||
|
$this->assertCount(3, $userPagination->getListingPaginator()->setOrder('id')->getCollection());
|
||||||
|
$this->assertCount(3, $userPagination->getListingPaginator()->setOrder('username')->getCollection());
|
||||||
|
$this->assertCount(3, $userPagination->getListingPaginator()->setOrder('name')->getCollection());
|
||||||
|
$this->assertCount(3, $userPagination->getListingPaginator()->setOrder('email')->getCollection());
|
||||||
|
$this->assertCount(3, $userPagination->getListingPaginator()->setOrder('role')->getCollection());
|
||||||
|
$this->assertCount(3, $userPagination->getListingPaginator()->setOrder('twofactor_activated')->setDirection('DESC')->getCollection());
|
||||||
|
$this->assertCount(3, $userPagination->getListingPaginator()->setOrder('is_ldap_user')->getCollection());
|
||||||
|
$this->assertCount(3, $userPagination->getListingPaginator()->setOrder('is_active')->getCollection());
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user