mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-19 13:22:42 +01:00
Paginate the user list view.
This commit is contained in:
parent
313da1d5eb
commit
29ce4ed83f
3 changed files with 27 additions and 15 deletions
|
@ -19,8 +19,25 @@
|
|||
class PhabricatorPeopleListController extends PhabricatorPeopleController {
|
||||
|
||||
public function processRequest() {
|
||||
$request = $this->getRequest();
|
||||
|
||||
$user = new PhabricatorUser();
|
||||
|
||||
$count = queryfx_one(
|
||||
$user->establishConnection('r'),
|
||||
'SELECT COUNT(*) N FROM %T',
|
||||
$user->getTableName());
|
||||
$count = idx($count, 'N', 0);
|
||||
|
||||
$pager = new AphrontPagerView();
|
||||
$pager->setOffset($request->getInt('page', 0));
|
||||
$pager->setCount($count);
|
||||
$pager->setURI($request->getRequestURI(), 'page');
|
||||
|
||||
$users = id(new PhabricatorUser())->loadAllWhere(
|
||||
'1 = 1 ORDER BY id DESC LIMIT 100');
|
||||
'1 = 1 ORDER BY id DESC LIMIT %d, %d',
|
||||
$pager->getOffset(),
|
||||
$pager->getPageSize());
|
||||
|
||||
$rows = array();
|
||||
foreach ($users as $user) {
|
||||
|
@ -35,15 +52,6 @@ class PhabricatorPeopleListController extends PhabricatorPeopleController {
|
|||
'href' => '/p/'.$user->getUsername().'/',
|
||||
),
|
||||
'View Profile'),
|
||||
/*
|
||||
phutil_render_tag(
|
||||
'a',
|
||||
array(
|
||||
'class' => 'button grey small',
|
||||
'href' => '/people/edit/'.$user->getUsername().'/',
|
||||
),
|
||||
'Edit'),
|
||||
*/
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -54,7 +62,6 @@ class PhabricatorPeopleListController extends PhabricatorPeopleController {
|
|||
'Username',
|
||||
'Real Name',
|
||||
'',
|
||||
// '',
|
||||
));
|
||||
$table->setColumnClasses(
|
||||
array(
|
||||
|
@ -62,13 +69,12 @@ class PhabricatorPeopleListController extends PhabricatorPeopleController {
|
|||
null,
|
||||
'wide',
|
||||
'action',
|
||||
// 'action',
|
||||
));
|
||||
|
||||
$panel = new AphrontPanelView();
|
||||
$panel->appendChild($table);
|
||||
$panel->setHeader('People');
|
||||
// $panel->setCreateButton('Create New User', '/people/edit/');
|
||||
$panel->appendChild($table);
|
||||
$panel->appendChild($pager);
|
||||
|
||||
return $this->buildStandardPageResponse($panel, array(
|
||||
'title' => 'People',
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
phutil_require_module('phabricator', 'applications/people/controller/base');
|
||||
phutil_require_module('phabricator', 'applications/people/storage/user');
|
||||
phutil_require_module('phabricator', 'storage/queryfx');
|
||||
phutil_require_module('phabricator', 'view/control/pager');
|
||||
phutil_require_module('phabricator', 'view/control/table');
|
||||
phutil_require_module('phabricator', 'view/layout/panel');
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
final class AphrontPagerView extends AphrontView {
|
||||
|
||||
private $offset;
|
||||
private $pageSize;
|
||||
private $pageSize = 100;
|
||||
|
||||
private $count;
|
||||
private $hasMorePages;
|
||||
|
@ -81,6 +81,10 @@ final class AphrontPagerView extends AphrontView {
|
|||
}
|
||||
|
||||
public function render() {
|
||||
if (!$this->uri) {
|
||||
throw new Exception(
|
||||
"You must call setURI() before you can call render().");
|
||||
}
|
||||
|
||||
require_celerity_resource('aphront-pager-view-css');
|
||||
|
||||
|
|
Loading…
Reference in a new issue