mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-23 15:22:41 +01:00
Implement "Sort by Points" on workboards
Summary: Depends on D20275. Fixes T10578. This is a static sorting (like "By Date Created") where you can't change point values by dragging. You can still drag cards between columns, or use the "Edit" icon to change point values. Test Plan: {F6265191} Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T10578 Differential Revision: https://secure.phabricator.com/D20276
This commit is contained in:
parent
c020f027bb
commit
03b7aca019
8 changed files with 106 additions and 5 deletions
|
@ -4059,6 +4059,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorProjectColumnOrder' => 'applications/project/order/PhabricatorProjectColumnOrder.php',
|
'PhabricatorProjectColumnOrder' => 'applications/project/order/PhabricatorProjectColumnOrder.php',
|
||||||
'PhabricatorProjectColumnOwnerOrder' => 'applications/project/order/PhabricatorProjectColumnOwnerOrder.php',
|
'PhabricatorProjectColumnOwnerOrder' => 'applications/project/order/PhabricatorProjectColumnOwnerOrder.php',
|
||||||
'PhabricatorProjectColumnPHIDType' => 'applications/project/phid/PhabricatorProjectColumnPHIDType.php',
|
'PhabricatorProjectColumnPHIDType' => 'applications/project/phid/PhabricatorProjectColumnPHIDType.php',
|
||||||
|
'PhabricatorProjectColumnPointsOrder' => 'applications/project/order/PhabricatorProjectColumnPointsOrder.php',
|
||||||
'PhabricatorProjectColumnPosition' => 'applications/project/storage/PhabricatorProjectColumnPosition.php',
|
'PhabricatorProjectColumnPosition' => 'applications/project/storage/PhabricatorProjectColumnPosition.php',
|
||||||
'PhabricatorProjectColumnPositionQuery' => 'applications/project/query/PhabricatorProjectColumnPositionQuery.php',
|
'PhabricatorProjectColumnPositionQuery' => 'applications/project/query/PhabricatorProjectColumnPositionQuery.php',
|
||||||
'PhabricatorProjectColumnPriorityOrder' => 'applications/project/order/PhabricatorProjectColumnPriorityOrder.php',
|
'PhabricatorProjectColumnPriorityOrder' => 'applications/project/order/PhabricatorProjectColumnPriorityOrder.php',
|
||||||
|
@ -10145,6 +10146,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorProjectColumnOrder' => 'Phobject',
|
'PhabricatorProjectColumnOrder' => 'Phobject',
|
||||||
'PhabricatorProjectColumnOwnerOrder' => 'PhabricatorProjectColumnOrder',
|
'PhabricatorProjectColumnOwnerOrder' => 'PhabricatorProjectColumnOrder',
|
||||||
'PhabricatorProjectColumnPHIDType' => 'PhabricatorPHIDType',
|
'PhabricatorProjectColumnPHIDType' => 'PhabricatorPHIDType',
|
||||||
|
'PhabricatorProjectColumnPointsOrder' => 'PhabricatorProjectColumnOrder',
|
||||||
'PhabricatorProjectColumnPosition' => array(
|
'PhabricatorProjectColumnPosition' => array(
|
||||||
'PhabricatorProjectDAO',
|
'PhabricatorProjectDAO',
|
||||||
'PhabricatorPolicyInterface',
|
'PhabricatorPolicyInterface',
|
||||||
|
|
|
@ -616,7 +616,7 @@ final class PhabricatorProjectBoardViewController
|
||||||
|
|
||||||
$order_key = $this->sortKey;
|
$order_key = $this->sortKey;
|
||||||
|
|
||||||
$ordering_map = PhabricatorProjectColumnOrder::getAllOrders();
|
$ordering_map = PhabricatorProjectColumnOrder::getEnabledOrders();
|
||||||
$ordering = id(clone $ordering_map[$order_key])
|
$ordering = id(clone $ordering_map[$order_key])
|
||||||
->setViewer($viewer);
|
->setViewer($viewer);
|
||||||
|
|
||||||
|
@ -635,6 +635,12 @@ final class PhabricatorProjectBoardViewController
|
||||||
$order_maps[] = $ordering->toDictionary();
|
$order_maps[] = $ordering->toDictionary();
|
||||||
|
|
||||||
$properties = array();
|
$properties = array();
|
||||||
|
foreach ($all_tasks as $task) {
|
||||||
|
$properties[$task->getPHID()] = array(
|
||||||
|
'points' => (double)$task->getPoints(),
|
||||||
|
'status' => $task->getStatus(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$behavior_config = array(
|
$behavior_config = array(
|
||||||
'moveURI' => $this->getApplicationURI('move/'.$project->getID().'/'),
|
'moveURI' => $this->getApplicationURI('move/'.$project->getID().'/'),
|
||||||
|
@ -771,7 +777,7 @@ final class PhabricatorProjectBoardViewController
|
||||||
}
|
}
|
||||||
|
|
||||||
private function isValidSort($sort) {
|
private function isValidSort($sort) {
|
||||||
$map = PhabricatorProjectColumnOrder::getAllOrders();
|
$map = PhabricatorProjectColumnOrder::getEnabledOrders();
|
||||||
return isset($map[$sort]);
|
return isset($map[$sort]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -820,6 +826,9 @@ final class PhabricatorProjectBoardViewController
|
||||||
$project,
|
$project,
|
||||||
PhabricatorPolicyCapability::CAN_EDIT);
|
PhabricatorPolicyCapability::CAN_EDIT);
|
||||||
|
|
||||||
|
$items[] = id(new PhabricatorActionView())
|
||||||
|
->setType(PhabricatorActionView::TYPE_DIVIDER);
|
||||||
|
|
||||||
$items[] = id(new PhabricatorActionView())
|
$items[] = id(new PhabricatorActionView())
|
||||||
->setIcon('fa-floppy-o')
|
->setIcon('fa-floppy-o')
|
||||||
->setName(pht('Save as Default'))
|
->setName(pht('Save as Default'))
|
||||||
|
@ -918,6 +927,9 @@ final class PhabricatorProjectBoardViewController
|
||||||
$project,
|
$project,
|
||||||
PhabricatorPolicyCapability::CAN_EDIT);
|
PhabricatorPolicyCapability::CAN_EDIT);
|
||||||
|
|
||||||
|
$items[] = id(new PhabricatorActionView())
|
||||||
|
->setType(PhabricatorActionView::TYPE_DIVIDER);
|
||||||
|
|
||||||
$items[] = id(new PhabricatorActionView())
|
$items[] = id(new PhabricatorActionView())
|
||||||
->setIcon('fa-floppy-o')
|
->setIcon('fa-floppy-o')
|
||||||
->setName(pht('Save as Default'))
|
->setName(pht('Save as Default'))
|
||||||
|
|
|
@ -21,10 +21,14 @@ final class PhabricatorProjectColumnCreatedOrder
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getMenuOrder() {
|
||||||
|
return 3000;
|
||||||
|
}
|
||||||
|
|
||||||
protected function newSortVectorForObject($object) {
|
protected function newSortVectorForObject($object) {
|
||||||
return array(
|
return array(
|
||||||
(int)-$object->getDateCreated(),
|
-(int)$object->getDateCreated(),
|
||||||
(int)-$object->getID(),
|
-(int)$object->getID(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,4 +17,8 @@ final class PhabricatorProjectColumnNaturalOrder
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getMenuOrder() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,9 +22,22 @@ abstract class PhabricatorProjectColumnOrder
|
||||||
return id(new PhutilClassMapQuery())
|
return id(new PhutilClassMapQuery())
|
||||||
->setAncestorClass(__CLASS__)
|
->setAncestorClass(__CLASS__)
|
||||||
->setUniqueMethod('getColumnOrderKey')
|
->setUniqueMethod('getColumnOrderKey')
|
||||||
|
->setSortMethod('getMenuOrder')
|
||||||
->execute();
|
->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final public static function getEnabledOrders() {
|
||||||
|
$map = self::getAllOrders();
|
||||||
|
|
||||||
|
foreach ($map as $key => $order) {
|
||||||
|
if (!$order->isEnabled()) {
|
||||||
|
unset($map[$key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $map;
|
||||||
|
}
|
||||||
|
|
||||||
final public static function getOrderByKey($key) {
|
final public static function getOrderByKey($key) {
|
||||||
$map = self::getAllOrders();
|
$map = self::getAllOrders();
|
||||||
|
|
||||||
|
@ -71,6 +84,14 @@ abstract class PhabricatorProjectColumnOrder
|
||||||
abstract public function getHasHeaders();
|
abstract public function getHasHeaders();
|
||||||
abstract public function getCanReorder();
|
abstract public function getCanReorder();
|
||||||
|
|
||||||
|
public function getMenuOrder() {
|
||||||
|
return 9000;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isEnabled() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
protected function newColumnTransactions($object, array $header) {
|
protected function newColumnTransactions($object, array $header) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,10 @@ final class PhabricatorProjectColumnOwnerOrder
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getMenuOrder() {
|
||||||
|
return 2000;
|
||||||
|
}
|
||||||
|
|
||||||
protected function newHeaderKeyForObject($object) {
|
protected function newHeaderKeyForObject($object) {
|
||||||
return $this->newHeaderKeyForOwnerPHID($object->getOwnerPHID());
|
return $this->newHeaderKeyForOwnerPHID($object->getOwnerPHID());
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhabricatorProjectColumnPointsOrder
|
||||||
|
extends PhabricatorProjectColumnOrder {
|
||||||
|
|
||||||
|
const ORDERKEY = 'points';
|
||||||
|
|
||||||
|
public function getDisplayName() {
|
||||||
|
return pht('Sort by Points');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function newMenuIconIcon() {
|
||||||
|
return 'fa-map-pin';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isEnabled() {
|
||||||
|
return ManiphestTaskPoints::getIsEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHasHeaders() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCanReorder() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMenuOrder() {
|
||||||
|
return 4000;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function newSortVectorForObject($object) {
|
||||||
|
$points = $object->getPoints();
|
||||||
|
|
||||||
|
// Put cards with no points on top.
|
||||||
|
$has_points = ($points !== null);
|
||||||
|
if (!$has_points) {
|
||||||
|
$overall_order = 0;
|
||||||
|
} else {
|
||||||
|
$overall_order = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return array(
|
||||||
|
$overall_order,
|
||||||
|
-(double)$points,
|
||||||
|
-(int)$object->getID(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -21,6 +21,10 @@ final class PhabricatorProjectColumnPriorityOrder
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getMenuOrder() {
|
||||||
|
return 1000;
|
||||||
|
}
|
||||||
|
|
||||||
protected function newHeaderKeyForObject($object) {
|
protected function newHeaderKeyForObject($object) {
|
||||||
return $this->newHeaderKeyForPriority($object->getPriority());
|
return $this->newHeaderKeyForPriority($object->getPriority());
|
||||||
}
|
}
|
||||||
|
@ -35,7 +39,7 @@ final class PhabricatorProjectColumnPriorityOrder
|
||||||
|
|
||||||
private function newSortVectorForPriority($priority) {
|
private function newSortVectorForPriority($priority) {
|
||||||
return array(
|
return array(
|
||||||
(int)-$priority,
|
-(int)$priority,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue