mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 08:52:39 +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:
parent
8c9d61bedc
commit
f386099735
2 changed files with 82 additions and 3 deletions
|
@ -33,6 +33,8 @@ final class ManiphestTaskQuery
|
|||
const STATUS_SPITE = 'status-spite';
|
||||
const STATUS_DUPLICATE = 'status-duplicate';
|
||||
|
||||
private $statuses;
|
||||
|
||||
private $priority = null;
|
||||
|
||||
private $minPriority = null;
|
||||
|
@ -111,6 +113,11 @@ final class ManiphestTaskQuery
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function withStatuses(array $statuses) {
|
||||
$this->statuses = $statuses;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function withPriority($priority) {
|
||||
$this->priority = $priority;
|
||||
return $this;
|
||||
|
@ -188,6 +195,7 @@ final class ManiphestTaskQuery
|
|||
$where[] = $this->buildTaskIDsWhereClause($conn);
|
||||
$where[] = $this->buildTaskPHIDsWhereClause($conn);
|
||||
$where[] = $this->buildStatusWhereClause($conn);
|
||||
$where[] = $this->buildStatusesWhereClause($conn);
|
||||
$where[] = $this->buildPriorityWhereClause($conn);
|
||||
$where[] = $this->buildAuthorWhereClause($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) {
|
||||
if ($this->priority !== null) {
|
||||
return qsprintf(
|
||||
|
|
|
@ -16,6 +16,9 @@ final class ManiphestTaskSearchEngine
|
|||
'authorPHIDs',
|
||||
$this->readUsersFromRequest($request, 'authors'));
|
||||
|
||||
$saved->setParameter('statuses', $request->getArr('statuses'));
|
||||
$saved->setParameter('order', $request->getStr('order'));
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -66,6 +82,18 @@ final class ManiphestTaskSearchEngine
|
|||
|
||||
$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
|
||||
->appendChild(
|
||||
id(new AphrontFormTokenizerControl())
|
||||
|
@ -85,7 +113,14 @@ final class ManiphestTaskSearchEngine
|
|||
->setDatasource('/typeahead/common/accounts/')
|
||||
->setName('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) {
|
||||
|
@ -100,6 +135,7 @@ final class ManiphestTaskSearchEngine
|
|||
$names['authored'] = pht('Authored');
|
||||
}
|
||||
|
||||
$names['open'] = pht('Open Tasks');
|
||||
$names['all'] = pht('All Tasks');
|
||||
|
||||
return $names;
|
||||
|
@ -116,12 +152,37 @@ final class ManiphestTaskSearchEngine
|
|||
case 'all':
|
||||
return $query;
|
||||
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':
|
||||
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);
|
||||
}
|
||||
|
||||
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,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue