diff --git a/src/applications/flag/controller/PhabricatorFlagListController.php b/src/applications/flag/controller/PhabricatorFlagListController.php index 01e0e5c78d..ee18e5b2b2 100644 --- a/src/applications/flag/controller/PhabricatorFlagListController.php +++ b/src/applications/flag/controller/PhabricatorFlagListController.php @@ -5,6 +5,7 @@ final class PhabricatorFlagListController extends PhabricatorFlagController { public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); + $flag_order = $request->getStr('o', 'n'); $nav = new AphrontSideNavFilterView(); $nav->setBaseURI(new PhutilURI('/flag/view/')); @@ -25,13 +26,12 @@ final class PhabricatorFlagListController extends PhabricatorFlagController { ->setName('o') ->setLabel(pht('Sort Order')) ->setBaseURI($request->getRequestURI(), 'o') - ->setValue($request->getStr('o', 'n')) + ->setValue($flag_order) ->setButtons( array( 'n' => pht('Date'), 'c' => pht('Color'), 'o' => pht('Object Type'), - 'r' => pht('Reason'), ))); $filter = new AphrontListFilterView(); @@ -43,7 +43,9 @@ final class PhabricatorFlagListController extends PhabricatorFlagController { $query->setViewer($user); $query->needHandles(true); - switch ($request->getStr('o', 'n')) { + switch ($flag_order) { + // 'r' + // 'a' case 'n': $order = PhabricatorFlagQuery::ORDER_ID; break; @@ -53,9 +55,6 @@ final class PhabricatorFlagListController extends PhabricatorFlagController { case 'o': $order = PhabricatorFlagQuery::ORDER_OBJECT; break; - case 'r': - $order = PhabricatorFlagQuery::ORDER_REASON; - break; default: throw new Exception("Unknown order!"); } @@ -63,11 +62,62 @@ final class PhabricatorFlagListController extends PhabricatorFlagController { $flags = $query->execute(); - $view = new PhabricatorFlagListView(); - $view->setFlags($flags); - $view->setUser($user); + $views = array(); + if ($flag_order == 'n') { + $view = new PhabricatorFlagListView(); + $view->setFlags($flags); + $view->setUser($user); + $view->setFlush(true); + $views[] = array( + 'view' => $view, + ); + } else { + switch ($flag_order) { + case 'c': + $flags_tmp = mgroup($flags, 'getColor'); + $flags = array(); + foreach ($flags_tmp as $color => $flag_group) { + $title = pht('%s Flags', + PhabricatorFlagColor::getColorName($color)); + $flags[$title] = $flag_group; + } + break; + case 'o': + $flags_tmp = mgroup($flags, 'getType'); + $flags = array(); + foreach ($flags_tmp as $color => $flag_group) { + // Appending an 's' to fake plurals + $title = head($flag_group)->getHandle()->getTypeName() . 's'; + $flags[$title] = $flag_group; + } + break; + default: + throw new Exception("Unknown order!"); + } - $nav->appendChild($view); + foreach ($flags as $group_title => $flag_group) { + $view = new PhabricatorFlagListView(); + $view->setFlags($flag_group); + $view->setUser($user); + $view->setFlush(true); + $views[] = array( + 'title' => pht('%s (%d)', $group_title, count($flag_group)), + 'view' => $view, + ); + } + } + + foreach ($views as $view) { + $panel = new AphrontPanelView(); + $panel->setNoBackground(); + + $title = idx($view, 'title'); + if ($title) { + $panel->setHeader($title); + } + $panel->appendChild($view['view']); + $nav->appendChild($panel); + } return $this->buildApplicationPage( $nav, diff --git a/src/applications/flag/query/PhabricatorFlagQuery.php b/src/applications/flag/query/PhabricatorFlagQuery.php index 20fb19e416..1edeedc0c6 100644 --- a/src/applications/flag/query/PhabricatorFlagQuery.php +++ b/src/applications/flag/query/PhabricatorFlagQuery.php @@ -165,10 +165,10 @@ final class PhabricatorFlagQuery { return 'id DESC'; break; case self::ORDER_COLOR: - return 'color DESC'; + return 'color ASC'; break; case self::ORDER_OBJECT: - return 'type ASC'; + return 'type DESC'; break; case self::ORDER_REASON: return 'reasonPHID DESC';