Page MenuHomePhabricator

D20276.id48391.diff
No OneTemporary

D20276.id48391.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -4059,6 +4059,7 @@
'PhabricatorProjectColumnOrder' => 'applications/project/order/PhabricatorProjectColumnOrder.php',
'PhabricatorProjectColumnOwnerOrder' => 'applications/project/order/PhabricatorProjectColumnOwnerOrder.php',
'PhabricatorProjectColumnPHIDType' => 'applications/project/phid/PhabricatorProjectColumnPHIDType.php',
+ 'PhabricatorProjectColumnPointsOrder' => 'applications/project/order/PhabricatorProjectColumnPointsOrder.php',
'PhabricatorProjectColumnPosition' => 'applications/project/storage/PhabricatorProjectColumnPosition.php',
'PhabricatorProjectColumnPositionQuery' => 'applications/project/query/PhabricatorProjectColumnPositionQuery.php',
'PhabricatorProjectColumnPriorityOrder' => 'applications/project/order/PhabricatorProjectColumnPriorityOrder.php',
@@ -10145,6 +10146,7 @@
'PhabricatorProjectColumnOrder' => 'Phobject',
'PhabricatorProjectColumnOwnerOrder' => 'PhabricatorProjectColumnOrder',
'PhabricatorProjectColumnPHIDType' => 'PhabricatorPHIDType',
+ 'PhabricatorProjectColumnPointsOrder' => 'PhabricatorProjectColumnOrder',
'PhabricatorProjectColumnPosition' => array(
'PhabricatorProjectDAO',
'PhabricatorPolicyInterface',
diff --git a/src/applications/project/controller/PhabricatorProjectBoardViewController.php b/src/applications/project/controller/PhabricatorProjectBoardViewController.php
--- a/src/applications/project/controller/PhabricatorProjectBoardViewController.php
+++ b/src/applications/project/controller/PhabricatorProjectBoardViewController.php
@@ -616,7 +616,7 @@
$order_key = $this->sortKey;
- $ordering_map = PhabricatorProjectColumnOrder::getAllOrders();
+ $ordering_map = PhabricatorProjectColumnOrder::getEnabledOrders();
$ordering = id(clone $ordering_map[$order_key])
->setViewer($viewer);
@@ -635,6 +635,12 @@
$order_maps[] = $ordering->toDictionary();
$properties = array();
+ foreach ($all_tasks as $task) {
+ $properties[$task->getPHID()] = array(
+ 'points' => (double)$task->getPoints(),
+ 'status' => $task->getStatus(),
+ );
+ }
$behavior_config = array(
'moveURI' => $this->getApplicationURI('move/'.$project->getID().'/'),
@@ -771,7 +777,7 @@
}
private function isValidSort($sort) {
- $map = PhabricatorProjectColumnOrder::getAllOrders();
+ $map = PhabricatorProjectColumnOrder::getEnabledOrders();
return isset($map[$sort]);
}
@@ -820,6 +826,9 @@
$project,
PhabricatorPolicyCapability::CAN_EDIT);
+ $items[] = id(new PhabricatorActionView())
+ ->setType(PhabricatorActionView::TYPE_DIVIDER);
+
$items[] = id(new PhabricatorActionView())
->setIcon('fa-floppy-o')
->setName(pht('Save as Default'))
@@ -918,6 +927,9 @@
$project,
PhabricatorPolicyCapability::CAN_EDIT);
+ $items[] = id(new PhabricatorActionView())
+ ->setType(PhabricatorActionView::TYPE_DIVIDER);
+
$items[] = id(new PhabricatorActionView())
->setIcon('fa-floppy-o')
->setName(pht('Save as Default'))
diff --git a/src/applications/project/order/PhabricatorProjectColumnCreatedOrder.php b/src/applications/project/order/PhabricatorProjectColumnCreatedOrder.php
--- a/src/applications/project/order/PhabricatorProjectColumnCreatedOrder.php
+++ b/src/applications/project/order/PhabricatorProjectColumnCreatedOrder.php
@@ -21,10 +21,14 @@
return false;
}
+ public function getMenuOrder() {
+ return 3000;
+ }
+
protected function newSortVectorForObject($object) {
return array(
- (int)-$object->getDateCreated(),
- (int)-$object->getID(),
+ -(int)$object->getDateCreated(),
+ -(int)$object->getID(),
);
}
diff --git a/src/applications/project/order/PhabricatorProjectColumnNaturalOrder.php b/src/applications/project/order/PhabricatorProjectColumnNaturalOrder.php
--- a/src/applications/project/order/PhabricatorProjectColumnNaturalOrder.php
+++ b/src/applications/project/order/PhabricatorProjectColumnNaturalOrder.php
@@ -17,4 +17,8 @@
return true;
}
+ public function getMenuOrder() {
+ return 0;
+ }
+
}
diff --git a/src/applications/project/order/PhabricatorProjectColumnOrder.php b/src/applications/project/order/PhabricatorProjectColumnOrder.php
--- a/src/applications/project/order/PhabricatorProjectColumnOrder.php
+++ b/src/applications/project/order/PhabricatorProjectColumnOrder.php
@@ -22,9 +22,22 @@
return id(new PhutilClassMapQuery())
->setAncestorClass(__CLASS__)
->setUniqueMethod('getColumnOrderKey')
+ ->setSortMethod('getMenuOrder')
->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) {
$map = self::getAllOrders();
@@ -71,6 +84,14 @@
abstract public function getHasHeaders();
abstract public function getCanReorder();
+ public function getMenuOrder() {
+ return 9000;
+ }
+
+ public function isEnabled() {
+ return true;
+ }
+
protected function newColumnTransactions($object, array $header) {
return array();
}
diff --git a/src/applications/project/order/PhabricatorProjectColumnOwnerOrder.php b/src/applications/project/order/PhabricatorProjectColumnOwnerOrder.php
--- a/src/applications/project/order/PhabricatorProjectColumnOwnerOrder.php
+++ b/src/applications/project/order/PhabricatorProjectColumnOwnerOrder.php
@@ -21,6 +21,10 @@
return true;
}
+ public function getMenuOrder() {
+ return 2000;
+ }
+
protected function newHeaderKeyForObject($object) {
return $this->newHeaderKeyForOwnerPHID($object->getOwnerPHID());
}
diff --git a/src/applications/project/order/PhabricatorProjectColumnPointsOrder.php b/src/applications/project/order/PhabricatorProjectColumnPointsOrder.php
new file mode 100644
--- /dev/null
+++ b/src/applications/project/order/PhabricatorProjectColumnPointsOrder.php
@@ -0,0 +1,51 @@
+<?php
+
+final class PhabricatorProjectColumnPointsOrder
+ extends PhabricatorProjectColumnOrder {
+
+ const ORDERKEY = 'points';
+
+ public function getDisplayName() {
+ return pht('Sort by Points');
+ }
+
+ protected function newMenuIconIcon() {
+ // TODO: Can we find a better icon for "Points"?
+ return 'fa-balance-scale';
+ }
+
+ 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(),
+ );
+ }
+
+}
diff --git a/src/applications/project/order/PhabricatorProjectColumnPriorityOrder.php b/src/applications/project/order/PhabricatorProjectColumnPriorityOrder.php
--- a/src/applications/project/order/PhabricatorProjectColumnPriorityOrder.php
+++ b/src/applications/project/order/PhabricatorProjectColumnPriorityOrder.php
@@ -21,6 +21,10 @@
return true;
}
+ public function getMenuOrder() {
+ return 1000;
+ }
+
protected function newHeaderKeyForObject($object) {
return $this->newHeaderKeyForPriority($object->getPriority());
}
@@ -35,7 +39,7 @@
private function newSortVectorForPriority($priority) {
return array(
- (int)-$priority,
+ -(int)$priority,
);
}

File Metadata

Mime Type
text/plain
Expires
Sun, Mar 23, 7:54 PM (1 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7718942
Default Alt Text
D20276.id48391.diff (7 KB)

Event Timeline