1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-27 01:02:42 +01:00

Updates to phrequent's landing page

Summary:
https://secure.phabricator.com/D5554#comment-4

Implemented the changes outlined above.

Test Plan: Go to the page, click the new nav links, try the user filter

Reviewers: epriestley, hach-que

CC: hach-que, aran, Korvin

Differential Revision: https://secure.phabricator.com/D5789
This commit is contained in:
Gareth Evans 2013-04-29 11:59:16 -07:00 committed by epriestley
parent f53cde8f92
commit eaa4362979
3 changed files with 127 additions and 36 deletions

View file

@ -36,6 +36,7 @@ final class PhabricatorApplicationPhrequent extends PhabricatorApplication {
return array( return array(
'/phrequent/' => array( '/phrequent/' => array(
'' => 'PhrequentListController', '' => 'PhrequentListController',
'view/(?P<view>\w+)/' => 'PhrequentListController',
'track/(?P<verb>[a-z]+)/(?P<phid>[^/]+)/' 'track/(?P<verb>[a-z]+)/(?P<phid>[^/]+)/'
=> 'PhrequentTrackController' => 'PhrequentTrackController'
), ),

View file

@ -4,9 +4,14 @@ abstract class PhrequentController extends PhabricatorController {
protected function buildNav($view) { protected function buildNav($view) {
$nav = new AphrontSideNavFilterView(); $nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI('/phrequent/')); $nav->setBaseURI(new PhutilURI('/phrequent/view/'));
$nav->addFilter('usertime', 'Time Tracked'); $nav->addLabel(pht('User Times'));
$nav->addFilter('current', pht('Currently Tracking'));
$nav->addFilter('recent', pht('Recent Activity'));
$nav->addLabel('All Times');
$nav->addFilter('allcurrent', pht('Currently Tracking'));
$nav->addFilter('allrecent', pht('Recent Activity'));
$nav->selectFilter($view); $nav->selectFilter($view);

View file

@ -2,48 +2,69 @@
final class PhrequentListController extends PhrequentController { final class PhrequentListController extends PhrequentController {
private $view;
public function willProcessRequest(array $data) {
$this->view = idx($data, 'view', "current");
}
private function getArrToStrList($key) {
$arr = $this->getRequest()->getArr($key);
$arr = implode(',', $arr);
return nonempty($arr, null);
}
public function processRequest() { public function processRequest() {
$request = $this->getRequest(); $request = $this->getRequest();
$user = $request->getUser(); $user = $request->getUser();
$nav = $this->buildNav('usertime'); if ($request->isFormPost()) {
// Redirect to GET so URIs can be copy/pasted.
$form = id(new AphrontFormView()) $order = $request->getStr('o');
->setUser($user) $order = nonempty($order, null);
->setNoShading(true);
$form->appendChild( $ended = $request->getStr('e');
id(new AphrontFormToggleButtonsControl()) $ended = nonempty($ended, null);
->setName('o')
->setLabel(pht('Sort Order'))
->setBaseURI($request->getRequestURI(), 'o')
->setValue($request->getStr('o', 's'))
->setButtons(
array(
's' => pht('Started'),
'e' => pht('Ended'),
'd' => pht('Duration'),
)));
$form->appendChild( $uri = $request->getRequestURI()
id(new AphrontFormToggleButtonsControl()) ->alter('users', $this->getArrToStrList('set_users'))
->setName('e') ->alter('o', $order)
->setLabel(pht('Ended')) ->alter('e', $ended);
->setBaseURI($request->getRequestURI(), 'e')
->setValue($request->getStr('e', 'a'))
->setButtons(
array(
'y' => pht('Yes'),
'n' => pht('No'),
'a' => pht('All'),
)));
$filter = new AphrontListFilterView(); return id(new AphrontRedirectResponse())->setURI($uri);
$filter->appendChild($form); }
$query = new PhrequentUserTimeQuery(); $nav = $this->buildNav($this->view);
switch ($request->getStr('o', 's')) { $has_user_filter = array(
"current" => true,
"recent" => true,
);
$user_phids = $request->getStrList('users', array());
if (isset($has_user_filter[$this->view])) {
$user_phids = array($user->getPHID());
}
switch ($this->view) {
case "current":
case "allcurrent":
$order_key_default = "s";
$ended_key_default = "n";
break;
case "recent":
case "allrecent":
$order_key_default = "s";
$ended_key_default = "y";
break;
default:
$order_key_default = "s";
$ended_key_default = "a";
break;
}
switch ($request->getStr('o', $order_key_default)) {
case 's': case 's':
$order = PhrequentUserTimeQuery::ORDER_STARTED; $order = PhrequentUserTimeQuery::ORDER_STARTED;
break; break;
@ -56,9 +77,8 @@ final class PhrequentListController extends PhrequentController {
default: default:
throw new Exception("Unknown order!"); throw new Exception("Unknown order!");
} }
$query->setOrder($order);
switch ($request->getStr('e', 'a')) { switch ($request->getStr('e', $ended_key_default)) {
case 'a': case 'a':
$ended = PhrequentUserTimeQuery::ENDED_ALL; $ended = PhrequentUserTimeQuery::ENDED_ALL;
break; break;
@ -71,7 +91,15 @@ final class PhrequentListController extends PhrequentController {
default: default:
throw new Exception("Unknown ended!"); throw new Exception("Unknown ended!");
} }
$filter = new AphrontListFilterView();
$filter->appendChild(
$this->buildForm($user_phids, $order_key_default, $ended_key_default));
$query = new PhrequentUserTimeQuery();
$query->setOrder($order);
$query->setEnded($ended); $query->setEnded($ended);
$query->setUsers($user_phids);
$pager = new AphrontPagerView(); $pager = new AphrontPagerView();
$pager->setPageSize(500); $pager->setPageSize(500);
@ -97,6 +125,7 @@ final class PhrequentListController extends PhrequentController {
id(new PhabricatorCrumbView()) id(new PhabricatorCrumbView())
->setName($title) ->setName($title)
->setHref($this->getApplicationURI('/'))); ->setHref($this->getApplicationURI('/')));
$nav->setCrumbs($crumbs); $nav->setCrumbs($crumbs);
return $this->buildApplicationPage( return $this->buildApplicationPage(
@ -108,6 +137,62 @@ final class PhrequentListController extends PhrequentController {
} }
protected function buildForm(array $user_phids, $order_key_default,
$ended_key_default) {
$request = $this->getRequest();
$user = $request->getUser();
$form = id(new AphrontFormView())
->setUser($user)
->setNoShading(true)
->setAction($this->getApplicationURI("/view/custom/"));
$user_handles = id(new PhabricatorObjectHandleData($user_phids))
->setViewer($user)
->loadHandles();
$tokens = array();
foreach ($user_phids as $phid) {
$tokens[$phid] = $user_handles[$phid]->getFullName();
}
$form->appendChild(
id(new AphrontFormTokenizerControl())
->setDatasource('/typeahead/common/searchowner/')
->setName('set_users')
->setLabel(pht('Users'))
->setValue($tokens));
$form->appendChild(
id(new AphrontFormToggleButtonsControl())
->setName('o')
->setLabel(pht('Sort Order'))
->setBaseURI($request->getRequestURI(), 'o')
->setValue($request->getStr('o', $order_key_default))
->setButtons(
array(
's' => pht('Started'),
'e' => pht('Ended'),
'd' => pht('Duration'),
)));
$form->appendChild(
id(new AphrontFormToggleButtonsControl())
->setName('e')
->setLabel(pht('Ended'))
->setBaseURI($request->getRequestURI(), 'e')
->setValue($request->getStr('e', $ended_key_default))
->setButtons(
array(
'y' => pht('Yes'),
'n' => pht('No'),
'a' => pht('All'),
)));
$form->appendChild(
id(new AphrontFormSubmitControl())->setValue(pht('Filter Objects')));
return $form;
}
protected function buildTableView(array $usertimes) { protected function buildTableView(array $usertimes) {
assert_instances_of($usertimes, 'PhrequentUserTime'); assert_instances_of($usertimes, 'PhrequentUserTime');