1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-20 13:52:40 +01:00

Added separation of flags according to ordering

Summary:
Refs T2841 - Exactly what it says on the tin

Turned some ordering around.

 - Color is `ASC` to be in line with the flag dialog
 - Object type is `DESC`, since `TASK` and `DREV` are sure more of
   interest than `CMIT`

NOTE: May not work properly without D5514, since only a few
object handle types implement `getTypeName()` properly. The fallback
return value is `null`, after which we group when sorting per object
type. Dis gun b gud!

.

NOTE: Technically does not de-pend on D5517, though you may get a merge conflict. Prefer this one if you for some reason happen to push this one before D5517

Test Plan:
{F38202}
{F38203}
{F38204}

Reviewers: epriestley, btrahan

CC: aran, Korvin

Maniphest Tasks: T2841

Differential Revision: https://secure.phabricator.com/D5518

Conflicts:

	src/applications/flag/controller/PhabricatorFlagListController.php
This commit is contained in:
Anh Nhan Nguyen 2013-04-03 11:07:30 -07:00 committed by epriestley
parent 9ca8c8cd9c
commit 7c9bd8bf35
2 changed files with 62 additions and 12 deletions

View file

@ -5,6 +5,7 @@ final class PhabricatorFlagListController extends PhabricatorFlagController {
public function processRequest() { public function processRequest() {
$request = $this->getRequest(); $request = $this->getRequest();
$user = $request->getUser(); $user = $request->getUser();
$flag_order = $request->getStr('o', 'n');
$nav = new AphrontSideNavFilterView(); $nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI('/flag/view/')); $nav->setBaseURI(new PhutilURI('/flag/view/'));
@ -25,13 +26,12 @@ final class PhabricatorFlagListController extends PhabricatorFlagController {
->setName('o') ->setName('o')
->setLabel(pht('Sort Order')) ->setLabel(pht('Sort Order'))
->setBaseURI($request->getRequestURI(), 'o') ->setBaseURI($request->getRequestURI(), 'o')
->setValue($request->getStr('o', 'n')) ->setValue($flag_order)
->setButtons( ->setButtons(
array( array(
'n' => pht('Date'), 'n' => pht('Date'),
'c' => pht('Color'), 'c' => pht('Color'),
'o' => pht('Object Type'), 'o' => pht('Object Type'),
'r' => pht('Reason'),
))); )));
$filter = new AphrontListFilterView(); $filter = new AphrontListFilterView();
@ -43,7 +43,9 @@ final class PhabricatorFlagListController extends PhabricatorFlagController {
$query->setViewer($user); $query->setViewer($user);
$query->needHandles(true); $query->needHandles(true);
switch ($request->getStr('o', 'n')) { switch ($flag_order) {
// 'r'
// 'a'
case 'n': case 'n':
$order = PhabricatorFlagQuery::ORDER_ID; $order = PhabricatorFlagQuery::ORDER_ID;
break; break;
@ -53,9 +55,6 @@ final class PhabricatorFlagListController extends PhabricatorFlagController {
case 'o': case 'o':
$order = PhabricatorFlagQuery::ORDER_OBJECT; $order = PhabricatorFlagQuery::ORDER_OBJECT;
break; break;
case 'r':
$order = PhabricatorFlagQuery::ORDER_REASON;
break;
default: default:
throw new Exception("Unknown order!"); throw new Exception("Unknown order!");
} }
@ -63,11 +62,62 @@ final class PhabricatorFlagListController extends PhabricatorFlagController {
$flags = $query->execute(); $flags = $query->execute();
$views = array();
if ($flag_order == 'n') {
$view = new PhabricatorFlagListView(); $view = new PhabricatorFlagListView();
$view->setFlags($flags); $view->setFlags($flags);
$view->setUser($user); $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( return $this->buildApplicationPage(
$nav, $nav,

View file

@ -165,10 +165,10 @@ final class PhabricatorFlagQuery {
return 'id DESC'; return 'id DESC';
break; break;
case self::ORDER_COLOR: case self::ORDER_COLOR:
return 'color DESC'; return 'color ASC';
break; break;
case self::ORDER_OBJECT: case self::ORDER_OBJECT:
return 'type ASC'; return 'type DESC';
break; break;
case self::ORDER_REASON: case self::ORDER_REASON:
return 'reasonPHID DESC'; return 'reasonPHID DESC';