1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-23 15:22:41 +01:00

Add "IDs" and "Priority" to pro search

Summary: Ref T2625. Restore these, too.

Test Plan: Executed queries using these fields.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2625

Differential Revision: https://secure.phabricator.com/D6937
This commit is contained in:
epriestley 2013-09-10 11:54:17 -07:00
parent f386099735
commit a8171889bd
2 changed files with 62 additions and 1 deletions

View file

@ -36,6 +36,7 @@ final class ManiphestTaskQuery
private $statuses; private $statuses;
private $priority = null; private $priority = null;
private $priorities;
private $minPriority = null; private $minPriority = null;
private $maxPriority = null; private $maxPriority = null;
@ -123,6 +124,11 @@ final class ManiphestTaskQuery
return $this; return $this;
} }
public function withPriorities(array $priorities) {
$this->priorities = $priorities;
return $this;
}
public function withPrioritiesBetween($min, $max) { public function withPrioritiesBetween($min, $max) {
$this->minPriority = $min; $this->minPriority = $min;
$this->maxPriority = $max; $this->maxPriority = $max;
@ -197,6 +203,7 @@ final class ManiphestTaskQuery
$where[] = $this->buildStatusWhereClause($conn); $where[] = $this->buildStatusWhereClause($conn);
$where[] = $this->buildStatusesWhereClause($conn); $where[] = $this->buildStatusesWhereClause($conn);
$where[] = $this->buildPriorityWhereClause($conn); $where[] = $this->buildPriorityWhereClause($conn);
$where[] = $this->buildPrioritiesWhereClause($conn);
$where[] = $this->buildAuthorWhereClause($conn); $where[] = $this->buildAuthorWhereClause($conn);
$where[] = $this->buildOwnerWhereClause($conn); $where[] = $this->buildOwnerWhereClause($conn);
$where[] = $this->buildSubscriberWhereClause($conn); $where[] = $this->buildSubscriberWhereClause($conn);
@ -366,6 +373,18 @@ final class ManiphestTaskQuery
return null; return null;
} }
private function buildPrioritiesWhereClause(AphrontDatabaseConnection $conn) {
if ($this->priorities) {
return qsprintf(
$conn,
'priority IN (%Ld)',
$this->priorities);
}
return null;
}
private function buildAuthorWhereClause(AphrontDatabaseConnection $conn) { private function buildAuthorWhereClause(AphrontDatabaseConnection $conn) {
if (!$this->authorPHIDs) { if (!$this->authorPHIDs) {
return null; return null;

View file

@ -17,8 +17,20 @@ final class ManiphestTaskSearchEngine
$this->readUsersFromRequest($request, 'authors')); $this->readUsersFromRequest($request, 'authors'));
$saved->setParameter('statuses', $request->getArr('statuses')); $saved->setParameter('statuses', $request->getArr('statuses'));
$saved->setParameter('priorities', $request->getArr('priorities'));
$saved->setParameter('order', $request->getStr('order')); $saved->setParameter('order', $request->getStr('order'));
$ids = $request->getStrList('ids');
foreach ($ids as $key => $id) {
$id = trim($id, ' Tt');
if (!$id || !is_numeric($id)) {
unset($ids[$key]);
} else {
$ids[$key] = $id;
}
}
$saved->setParameter('ids', $ids);
return $saved; return $saved;
} }
@ -45,6 +57,11 @@ final class ManiphestTaskSearchEngine
$query->withStatuses($statuses); $query->withStatuses($statuses);
} }
$priorities = $saved->getParameter('priorities');
if ($priorities) {
$query->withPriorities($priorities);
}
$order = $saved->getParameter('order'); $order = $saved->getParameter('order');
$order = idx($this->getOrderValues(), $order); $order = idx($this->getOrderValues(), $order);
if ($order) { if ($order) {
@ -53,6 +70,11 @@ final class ManiphestTaskSearchEngine
$query->setOrderBy(head($this->getOrderValues())); $query->setOrderBy(head($this->getOrderValues()));
} }
$ids = $saved->getParameter('ids');
if ($ids) {
$query->withIDs($ids);
}
return $query; return $query;
} }
@ -94,6 +116,20 @@ final class ManiphestTaskSearchEngine
isset($statuses[$status])); isset($statuses[$status]));
} }
$priorities = $saved->getParameter('priorities', array());
$priorities = array_fuse($priorities);
$priority_control = id(new AphrontFormCheckboxControl())
->setLabel(pht('Priority'));
foreach (ManiphestTaskPriority::getTaskPriorityMap() as $pri => $name) {
$priority_control->addCheckbox(
'priorities[]',
$pri,
$name,
isset($priorities[$pri]));
}
$ids = $saved->getParameter('ids', array());
$form $form
->appendChild( ->appendChild(
id(new AphrontFormTokenizerControl()) id(new AphrontFormTokenizerControl())
@ -115,12 +151,18 @@ final class ManiphestTaskSearchEngine
->setLabel(pht('Authors')) ->setLabel(pht('Authors'))
->setValue($author_tokens)) ->setValue($author_tokens))
->appendChild($status_control) ->appendChild($status_control)
->appendChild($priority_control)
->appendChild( ->appendChild(
id(new AphrontFormSelectControl()) id(new AphrontFormSelectControl())
->setName('order') ->setName('order')
->setLabel(pht('Order')) ->setLabel(pht('Order'))
->setValue($saved->getParameter('order')) ->setValue($saved->getParameter('order'))
->setOptions($this->getOrderOptions())); ->setOptions($this->getOrderOptions()))
->appendChild(
id(new AphrontFormTextControl())
->setName('ids')
->setLabel(pht('Task IDs'))
->setValue(implode(', ', $ids)));
} }
protected function getURI($path) { protected function getURI($path) {