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:
parent
9ca8c8cd9c
commit
7c9bd8bf35
2 changed files with 62 additions and 12 deletions
|
@ -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,
|
||||
|
|
|
@ -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';
|
||||
|
|
Loading…
Reference in a new issue