@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add support for "status" and "order" to pro search

Summary: Ref T2625. Further expands the "pro" search.

Test Plan: Used new options to query tasks.

Reviewers: btrahan, garoevans

Reviewed By: garoevans

CC: aran

Maniphest Tasks: T2625

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

+82 -3
+18
src/applications/maniphest/ManiphestTaskQuery.php
··· 33 33 const STATUS_SPITE = 'status-spite'; 34 34 const STATUS_DUPLICATE = 'status-duplicate'; 35 35 36 + private $statuses; 37 + 36 38 private $priority = null; 37 39 38 40 private $minPriority = null; ··· 111 113 return $this; 112 114 } 113 115 116 + public function withStatuses(array $statuses) { 117 + $this->statuses = $statuses; 118 + return $this; 119 + } 120 + 114 121 public function withPriority($priority) { 115 122 $this->priority = $priority; 116 123 return $this; ··· 188 195 $where[] = $this->buildTaskIDsWhereClause($conn); 189 196 $where[] = $this->buildTaskPHIDsWhereClause($conn); 190 197 $where[] = $this->buildStatusWhereClause($conn); 198 + $where[] = $this->buildStatusesWhereClause($conn); 191 199 $where[] = $this->buildPriorityWhereClause($conn); 192 200 $where[] = $this->buildAuthorWhereClause($conn); 193 201 $where[] = $this->buildOwnerWhereClause($conn); ··· 329 337 'status = %d', 330 338 $constant); 331 339 } 340 + } 341 + 342 + private function buildStatusesWhereClause(AphrontDatabaseConnection $conn) { 343 + if ($this->statuses) { 344 + return qsprintf( 345 + $conn, 346 + 'status IN (%Ld)', 347 + $this->statuses); 348 + } 349 + return null; 332 350 } 333 351 334 352 private function buildPriorityWhereClause(AphrontDatabaseConnection $conn) {
+64 -3
src/applications/maniphest/query/ManiphestTaskSearchEngine.php
··· 16 16 'authorPHIDs', 17 17 $this->readUsersFromRequest($request, 'authors')); 18 18 19 + $saved->setParameter('statuses', $request->getArr('statuses')); 20 + $saved->setParameter('order', $request->getStr('order')); 21 + 19 22 return $saved; 20 23 } 21 24 ··· 37 40 } 38 41 } 39 42 43 + $statuses = $saved->getParameter('statuses'); 44 + if ($statuses) { 45 + $query->withStatuses($statuses); 46 + } 47 + 48 + $order = $saved->getParameter('order'); 49 + $order = idx($this->getOrderValues(), $order); 50 + if ($order) { 51 + $query->setOrderBy($order); 52 + } else { 53 + $query->setOrderBy(head($this->getOrderValues())); 54 + } 55 + 40 56 return $query; 41 57 } 42 58 ··· 66 82 67 83 $with_unassigned = $saved->getParameter('withUnassigned'); 68 84 85 + $statuses = $saved->getParameter('statuses', array()); 86 + $statuses = array_fuse($statuses); 87 + $status_control = id(new AphrontFormCheckboxControl()) 88 + ->setLabel(pht('Status')); 89 + foreach (ManiphestTaskStatus::getTaskStatusMap() as $status => $name) { 90 + $status_control->addCheckbox( 91 + 'statuses[]', 92 + $status, 93 + $name, 94 + isset($statuses[$status])); 95 + } 96 + 69 97 $form 70 98 ->appendChild( 71 99 id(new AphrontFormTokenizerControl()) ··· 85 113 ->setDatasource('/typeahead/common/accounts/') 86 114 ->setName('authors') 87 115 ->setLabel(pht('Authors')) 88 - ->setValue($author_tokens)); 116 + ->setValue($author_tokens)) 117 + ->appendChild($status_control) 118 + ->appendChild( 119 + id(new AphrontFormSelectControl()) 120 + ->setName('order') 121 + ->setLabel(pht('Order')) 122 + ->setValue($saved->getParameter('order')) 123 + ->setOptions($this->getOrderOptions())); 89 124 } 90 125 91 126 protected function getURI($path) { ··· 100 135 $names['authored'] = pht('Authored'); 101 136 } 102 137 138 + $names['open'] = pht('Open Tasks'); 103 139 $names['all'] = pht('All Tasks'); 104 140 105 141 return $names; ··· 116 152 case 'all': 117 153 return $query; 118 154 case 'assigned': 119 - return $query->setParameter('assignedPHIDs', array($viewer_phid)); 155 + return $query 156 + ->setParameter('assignedPHIDs', array($viewer_phid)) 157 + ->setParameter('statuses', array(ManiphestTaskStatus::STATUS_OPEN)); 158 + case 'open': 159 + return $query 160 + ->setParameter('statuses', array(ManiphestTaskStatus::STATUS_OPEN)); 120 161 case 'authored': 121 - return $query->setParameter('authorPHIDs', array($viewer_phid)); 162 + return $query 163 + ->setParameter('authorPHIDs', array($viewer_phid)) 164 + ->setParameter('statuses', array(ManiphestTaskStatus::STATUS_OPEN)); 122 165 } 123 166 124 167 return parent::buildSavedQueryFromBuiltin($query_key); 168 + } 169 + 170 + private function getOrderOptions() { 171 + return array( 172 + 'priority' => pht('Priority'), 173 + 'updated' => pht('Date Updated'), 174 + 'created' => pht('Date Created'), 175 + 'title' => pht('Title'), 176 + ); 177 + } 178 + 179 + private function getOrderValues() { 180 + return array( 181 + 'priority' => ManiphestTaskQuery::ORDER_PRIORITY, 182 + 'updated' => ManiphestTaskQuery::ORDER_MODIFIED, 183 + 'created' => ManiphestTaskQuery::ORDER_CREATED, 184 + 'title' => ManiphestTaskQuery::ORDER_TITLE, 185 + ); 125 186 } 126 187 127 188 }