mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 20:10:55 +01:00
Add a pager to "Files"
Summary: Adds a pager control to the "Files" tool so you can page through files if there are >100. Test Plan: Set page size to a smaller number, paged through files. Reviewed By: aran Reviewers: aran, tuomaspelkonen, jungejason CC: aran Differential Revision: 211
This commit is contained in:
parent
7ca4835438
commit
59cd14bc61
2 changed files with 18 additions and 1 deletions
|
@ -19,8 +19,23 @@
|
|||
class PhabricatorFileListController extends PhabricatorFileController {
|
||||
|
||||
public function processRequest() {
|
||||
|
||||
$request = $this->getRequest();
|
||||
|
||||
$pager = new AphrontPagerView();
|
||||
$pager->setOffset($request->getInt('page'));
|
||||
|
||||
$files = id(new PhabricatorFile())->loadAllWhere(
|
||||
'1 = 1 ORDER BY id DESC LIMIT 100');
|
||||
'1 = 1 ORDER BY id DESC LIMIT %d, %d',
|
||||
$pager->getOffset(),
|
||||
$pager->getPageSize() + 1);
|
||||
|
||||
if (count($files) > $pager->getPageSize()) {
|
||||
$files = array_slice($files, 0, $pager->getPageSize(), true);
|
||||
$pager->setHasMorePages(true);
|
||||
}
|
||||
|
||||
$pager->setURI($request->getRequestURI(), 'page');
|
||||
|
||||
$rows = array();
|
||||
foreach ($files as $file) {
|
||||
|
@ -81,6 +96,7 @@ class PhabricatorFileListController extends PhabricatorFileController {
|
|||
$panel->appendChild($table);
|
||||
$panel->setHeader('Files');
|
||||
$panel->setCreateButton('Upload File', '/file/upload/');
|
||||
$panel->appendChild($pager);
|
||||
|
||||
return $this->buildStandardPageResponse($panel, array(
|
||||
'title' => 'Files',
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
phutil_require_module('phabricator', 'applications/files/controller/base');
|
||||
phutil_require_module('phabricator', 'applications/files/storage/file');
|
||||
phutil_require_module('phabricator', 'view/control/pager');
|
||||
phutil_require_module('phabricator', 'view/control/table');
|
||||
phutil_require_module('phabricator', 'view/layout/panel');
|
||||
|
||||
|
|
Loading…
Reference in a new issue