1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 22:10:55 +01:00

Add pager to all Audit Views

Summary: Fixes T1153, removes the "active" restriction from pagination

Test Plan: Bring up audit, test pager exists, and doesn't exist when needed

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: aik099, epriestley, Korvin

Maniphest Tasks: T1153

Differential Revision: https://secure.phabricator.com/D8643
This commit is contained in:
Chad Little 2014-03-29 08:43:17 -07:00
parent 44942f3378
commit cc626b0306

View file

@ -271,16 +271,12 @@ final class PhabricatorAuditListController extends PhabricatorAuditController {
$query = new PhabricatorAuditQuery(); $query = new PhabricatorAuditQuery();
$use_pager = ($this->filter != 'active'); $pager = new AphrontPagerView();
$pager->setURI($request->getRequestURI(), 'offset');
$pager->setOffset($request->getInt('offset'));
if ($use_pager) { $query->setOffset($pager->getOffset());
$pager = new AphrontPagerView(); $query->setLimit($pager->getPageSize() + 1);
$pager->setURI($request->getRequestURI(), 'offset');
$pager->setOffset($request->getInt('offset'));
$query->setOffset($pager->getOffset());
$query->setLimit($pager->getPageSize() + 1);
}
$awaiting = null; $awaiting = null;
@ -375,9 +371,7 @@ final class PhabricatorAuditListController extends PhabricatorAuditController {
$query->needCommitData(true); $query->needCommitData(true);
$audits = $query->execute(); $audits = $query->execute();
if ($use_pager) { $audits = $pager->sliceResults($audits);
$audits = $pager->sliceResults($audits);
}
$view = new PhabricatorAuditListView(); $view = new PhabricatorAuditListView();
$view->setAudits($audits); $view->setAudits($audits);
@ -394,9 +388,7 @@ final class PhabricatorAuditListController extends PhabricatorAuditController {
$panel->appendChild($view); $panel->appendChild($view);
$panel->setNoBackground(); $panel->setNoBackground();
if ($use_pager) { $panel->appendChild($pager);
$panel->appendChild($pager);
}
return $panel; return $panel;
} }
@ -408,16 +400,12 @@ final class PhabricatorAuditListController extends PhabricatorAuditController {
$query->needCommitData(true); $query->needCommitData(true);
$query->needAudits(true); $query->needAudits(true);
$use_pager = ($this->filter != 'active'); $pager = new AphrontPagerView();
$pager->setURI($request->getRequestURI(), 'offset');
$pager->setOffset($request->getInt('offset'));
if ($use_pager) { $query->setOffset($pager->getOffset());
$pager = new AphrontPagerView(); $query->setLimit($pager->getPageSize() + 1);
$pager->setURI($request->getRequestURI(), 'offset');
$pager->setOffset($request->getInt('offset'));
$query->setOffset($pager->getOffset());
$query->setLimit($pager->getPageSize() + 1);
}
switch ($this->filter) { switch ($this->filter) {
case 'active': case 'active':
@ -471,10 +459,7 @@ final class PhabricatorAuditListController extends PhabricatorAuditController {
} }
$commits = $query->execute(); $commits = $query->execute();
$commits = $pager->sliceResults($commits);
if ($use_pager) {
$commits = $pager->sliceResults($commits);
}
$view = new PhabricatorAuditCommitListView(); $view = new PhabricatorAuditCommitListView();
$view->setUser($request->getUser()); $view->setUser($request->getUser());
@ -490,9 +475,7 @@ final class PhabricatorAuditListController extends PhabricatorAuditController {
$panel->appendChild($view); $panel->appendChild($view);
$panel->setNoBackground(); $panel->setNoBackground();
if ($use_pager) { $panel->appendChild($pager);
$panel->appendChild($pager);
}
return $panel; return $panel;
} }