1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-25 06:50:55 +01:00

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
This commit is contained in:
epriestley 2013-09-10 11:07:34 -07:00
parent 8c9d61bedc
commit f386099735
2 changed files with 82 additions and 3 deletions

View file

@ -33,6 +33,8 @@ final class ManiphestTaskQuery
const STATUS_SPITE = 'status-spite'; const STATUS_SPITE = 'status-spite';
const STATUS_DUPLICATE = 'status-duplicate'; const STATUS_DUPLICATE = 'status-duplicate';
private $statuses;
private $priority = null; private $priority = null;
private $minPriority = null; private $minPriority = null;
@ -111,6 +113,11 @@ final class ManiphestTaskQuery
return $this; return $this;
} }
public function withStatuses(array $statuses) {
$this->statuses = $statuses;
return $this;
}
public function withPriority($priority) { public function withPriority($priority) {
$this->priority = $priority; $this->priority = $priority;
return $this; return $this;
@ -188,6 +195,7 @@ final class ManiphestTaskQuery
$where[] = $this->buildTaskIDsWhereClause($conn); $where[] = $this->buildTaskIDsWhereClause($conn);
$where[] = $this->buildTaskPHIDsWhereClause($conn); $where[] = $this->buildTaskPHIDsWhereClause($conn);
$where[] = $this->buildStatusWhereClause($conn); $where[] = $this->buildStatusWhereClause($conn);
$where[] = $this->buildStatusesWhereClause($conn);
$where[] = $this->buildPriorityWhereClause($conn); $where[] = $this->buildPriorityWhereClause($conn);
$where[] = $this->buildAuthorWhereClause($conn); $where[] = $this->buildAuthorWhereClause($conn);
$where[] = $this->buildOwnerWhereClause($conn); $where[] = $this->buildOwnerWhereClause($conn);
@ -331,6 +339,16 @@ final class ManiphestTaskQuery
} }
} }
private function buildStatusesWhereClause(AphrontDatabaseConnection $conn) {
if ($this->statuses) {
return qsprintf(
$conn,
'status IN (%Ld)',
$this->statuses);
}
return null;
}
private function buildPriorityWhereClause(AphrontDatabaseConnection $conn) { private function buildPriorityWhereClause(AphrontDatabaseConnection $conn) {
if ($this->priority !== null) { if ($this->priority !== null) {
return qsprintf( return qsprintf(

View file

@ -16,6 +16,9 @@ final class ManiphestTaskSearchEngine
'authorPHIDs', 'authorPHIDs',
$this->readUsersFromRequest($request, 'authors')); $this->readUsersFromRequest($request, 'authors'));
$saved->setParameter('statuses', $request->getArr('statuses'));
$saved->setParameter('order', $request->getStr('order'));
return $saved; return $saved;
} }
@ -37,6 +40,19 @@ final class ManiphestTaskSearchEngine
} }
} }
$statuses = $saved->getParameter('statuses');
if ($statuses) {
$query->withStatuses($statuses);
}
$order = $saved->getParameter('order');
$order = idx($this->getOrderValues(), $order);
if ($order) {
$query->setOrderBy($order);
} else {
$query->setOrderBy(head($this->getOrderValues()));
}
return $query; return $query;
} }
@ -66,6 +82,18 @@ final class ManiphestTaskSearchEngine
$with_unassigned = $saved->getParameter('withUnassigned'); $with_unassigned = $saved->getParameter('withUnassigned');
$statuses = $saved->getParameter('statuses', array());
$statuses = array_fuse($statuses);
$status_control = id(new AphrontFormCheckboxControl())
->setLabel(pht('Status'));
foreach (ManiphestTaskStatus::getTaskStatusMap() as $status => $name) {
$status_control->addCheckbox(
'statuses[]',
$status,
$name,
isset($statuses[$status]));
}
$form $form
->appendChild( ->appendChild(
id(new AphrontFormTokenizerControl()) id(new AphrontFormTokenizerControl())
@ -85,7 +113,14 @@ final class ManiphestTaskSearchEngine
->setDatasource('/typeahead/common/accounts/') ->setDatasource('/typeahead/common/accounts/')
->setName('authors') ->setName('authors')
->setLabel(pht('Authors')) ->setLabel(pht('Authors'))
->setValue($author_tokens)); ->setValue($author_tokens))
->appendChild($status_control)
->appendChild(
id(new AphrontFormSelectControl())
->setName('order')
->setLabel(pht('Order'))
->setValue($saved->getParameter('order'))
->setOptions($this->getOrderOptions()));
} }
protected function getURI($path) { protected function getURI($path) {
@ -100,6 +135,7 @@ final class ManiphestTaskSearchEngine
$names['authored'] = pht('Authored'); $names['authored'] = pht('Authored');
} }
$names['open'] = pht('Open Tasks');
$names['all'] = pht('All Tasks'); $names['all'] = pht('All Tasks');
return $names; return $names;
@ -116,12 +152,37 @@ final class ManiphestTaskSearchEngine
case 'all': case 'all':
return $query; return $query;
case 'assigned': case 'assigned':
return $query->setParameter('assignedPHIDs', array($viewer_phid)); return $query
->setParameter('assignedPHIDs', array($viewer_phid))
->setParameter('statuses', array(ManiphestTaskStatus::STATUS_OPEN));
case 'open':
return $query
->setParameter('statuses', array(ManiphestTaskStatus::STATUS_OPEN));
case 'authored': case 'authored':
return $query->setParameter('authorPHIDs', array($viewer_phid)); return $query
->setParameter('authorPHIDs', array($viewer_phid))
->setParameter('statuses', array(ManiphestTaskStatus::STATUS_OPEN));
} }
return parent::buildSavedQueryFromBuiltin($query_key); return parent::buildSavedQueryFromBuiltin($query_key);
} }
private function getOrderOptions() {
return array(
'priority' => pht('Priority'),
'updated' => pht('Date Updated'),
'created' => pht('Date Created'),
'title' => pht('Title'),
);
}
private function getOrderValues() {
return array(
'priority' => ManiphestTaskQuery::ORDER_PRIORITY,
'updated' => ManiphestTaskQuery::ORDER_MODIFIED,
'created' => ManiphestTaskQuery::ORDER_CREATED,
'title' => ManiphestTaskQuery::ORDER_TITLE,
);
}
} }