1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 22:10:55 +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 $priority = null;
private $priorities;
private $minPriority = null;
private $maxPriority = null;
@ -123,6 +124,11 @@ final class ManiphestTaskQuery
return $this;
}
public function withPriorities(array $priorities) {
$this->priorities = $priorities;
return $this;
}
public function withPrioritiesBetween($min, $max) {
$this->minPriority = $min;
$this->maxPriority = $max;
@ -197,6 +203,7 @@ final class ManiphestTaskQuery
$where[] = $this->buildStatusWhereClause($conn);
$where[] = $this->buildStatusesWhereClause($conn);
$where[] = $this->buildPriorityWhereClause($conn);
$where[] = $this->buildPrioritiesWhereClause($conn);
$where[] = $this->buildAuthorWhereClause($conn);
$where[] = $this->buildOwnerWhereClause($conn);
$where[] = $this->buildSubscriberWhereClause($conn);
@ -366,6 +373,18 @@ final class ManiphestTaskQuery
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) {
if (!$this->authorPHIDs) {
return null;

View file

@ -17,8 +17,20 @@ final class ManiphestTaskSearchEngine
$this->readUsersFromRequest($request, 'authors'));
$saved->setParameter('statuses', $request->getArr('statuses'));
$saved->setParameter('priorities', $request->getArr('priorities'));
$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;
}
@ -45,6 +57,11 @@ final class ManiphestTaskSearchEngine
$query->withStatuses($statuses);
}
$priorities = $saved->getParameter('priorities');
if ($priorities) {
$query->withPriorities($priorities);
}
$order = $saved->getParameter('order');
$order = idx($this->getOrderValues(), $order);
if ($order) {
@ -53,6 +70,11 @@ final class ManiphestTaskSearchEngine
$query->setOrderBy(head($this->getOrderValues()));
}
$ids = $saved->getParameter('ids');
if ($ids) {
$query->withIDs($ids);
}
return $query;
}
@ -94,6 +116,20 @@ final class ManiphestTaskSearchEngine
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
->appendChild(
id(new AphrontFormTokenizerControl())
@ -115,12 +151,18 @@ final class ManiphestTaskSearchEngine
->setLabel(pht('Authors'))
->setValue($author_tokens))
->appendChild($status_control)
->appendChild($priority_control)
->appendChild(
id(new AphrontFormSelectControl())
->setName('order')
->setLabel(pht('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) {