2013-09-10 19:04:26 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class ManiphestTaskSearchEngine
|
|
|
|
extends PhabricatorApplicationSearchEngine {
|
|
|
|
|
2014-05-16 04:17:38 +02:00
|
|
|
private $showBatchControls;
|
2014-05-20 20:42:05 +02:00
|
|
|
private $baseURI;
|
|
|
|
private $isBoardView;
|
|
|
|
|
|
|
|
public function setIsBoardView($is_board_view) {
|
|
|
|
$this->isBoardView = $is_board_view;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getIsBoardView() {
|
|
|
|
return $this->isBoardView;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setBaseURI($base_uri) {
|
|
|
|
$this->baseURI = $base_uri;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getBaseURI() {
|
|
|
|
return $this->baseURI;
|
|
|
|
}
|
2014-05-16 04:17:38 +02:00
|
|
|
|
|
|
|
public function setShowBatchControls($show_batch_controls) {
|
|
|
|
$this->showBatchControls = $show_batch_controls;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2014-06-12 22:22:20 +02:00
|
|
|
public function getResultTypeDescription() {
|
|
|
|
return pht('Tasks');
|
|
|
|
}
|
|
|
|
|
2015-02-05 00:47:48 +01:00
|
|
|
public function getApplicationClassName() {
|
2014-07-23 02:03:09 +02:00
|
|
|
return 'PhabricatorManiphestApplication';
|
2014-05-16 04:17:38 +02:00
|
|
|
}
|
|
|
|
|
2013-09-17 01:03:09 +02:00
|
|
|
public function getCustomFieldObject() {
|
|
|
|
return new ManiphestTask();
|
|
|
|
}
|
|
|
|
|
2013-09-10 19:04:26 +02:00
|
|
|
public function buildSavedQueryFromRequest(AphrontRequest $request) {
|
|
|
|
$saved = new PhabricatorSavedQuery();
|
|
|
|
|
2013-09-10 19:44:42 +02:00
|
|
|
$saved->setParameter(
|
|
|
|
'assignedPHIDs',
|
|
|
|
$this->readUsersFromRequest($request, 'assigned'));
|
|
|
|
|
|
|
|
$saved->setParameter(
|
|
|
|
'authorPHIDs',
|
|
|
|
$this->readUsersFromRequest($request, 'authors'));
|
|
|
|
|
2013-09-28 01:02:08 +02:00
|
|
|
$saved->setParameter(
|
|
|
|
'subscriberPHIDs',
|
2015-04-23 14:13:12 +02:00
|
|
|
$this->readSubscribersFromRequest($request, 'subscribers'));
|
2013-09-28 01:02:08 +02:00
|
|
|
|
2014-04-24 19:35:28 +02:00
|
|
|
$saved->setParameter(
|
|
|
|
'statuses',
|
|
|
|
$this->readListFromRequest($request, 'statuses'));
|
|
|
|
|
|
|
|
$saved->setParameter(
|
|
|
|
'priorities',
|
|
|
|
$this->readListFromRequest($request, 'priorities'));
|
|
|
|
|
2015-01-12 22:42:37 +01:00
|
|
|
$saved->setParameter(
|
|
|
|
'blocking',
|
|
|
|
$this->readBoolFromRequest($request, 'blocking'));
|
|
|
|
$saved->setParameter(
|
|
|
|
'blocked',
|
|
|
|
$this->readBoolFromRequest($request, 'blocked'));
|
|
|
|
|
2013-09-12 23:48:52 +02:00
|
|
|
$saved->setParameter('group', $request->getStr('group'));
|
2013-09-10 20:07:34 +02:00
|
|
|
$saved->setParameter('order', $request->getStr('order'));
|
|
|
|
|
2013-09-10 20:54:17 +02:00
|
|
|
$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);
|
|
|
|
|
2013-09-12 22:03:05 +02:00
|
|
|
$saved->setParameter('fulltext', $request->getStr('fulltext'));
|
|
|
|
|
2013-09-12 22:03:14 +02:00
|
|
|
$saved->setParameter(
|
2015-04-23 12:58:04 +02:00
|
|
|
'projects',
|
|
|
|
$this->readProjectsFromRequest($request, 'projects'));
|
2013-09-12 22:03:14 +02:00
|
|
|
|
2013-09-12 22:03:39 +02:00
|
|
|
$saved->setParameter('createdStart', $request->getStr('createdStart'));
|
|
|
|
$saved->setParameter('createdEnd', $request->getStr('createdEnd'));
|
2014-03-17 23:53:07 +01:00
|
|
|
$saved->setParameter('modifiedStart', $request->getStr('modifiedStart'));
|
|
|
|
$saved->setParameter('modifiedEnd', $request->getStr('modifiedEnd'));
|
2013-09-12 22:03:39 +02:00
|
|
|
|
Allow Maniphest queries to have configurable page sizes
Summary:
Current page size is `1000`. This is nice to have in some cases, but makes pages slower than necessary in others. Task lists are generally dominated by rendering costs.
For example, my default is "recent tasks", which just lists all tasks ordered by date created. Showing 100 tasks here instead of 1000 makes this several times faster without compromising utility.
I don't want to force the default to 100, though, since sometimes listing everything is quite useful and I think an advantage of Maniphest is that it generally deals reasonably well with large task sets.
(This `limit` property is actually read by the default implementation of `getPageSize()` in the parent class.)
Test Plan: Made queries with page sizes 1, 100, 12, 9, 3000, etc.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D6976
2013-09-13 17:44:00 +02:00
|
|
|
$limit = $request->getInt('limit');
|
|
|
|
if ($limit > 0) {
|
|
|
|
$saved->setParameter('limit', $limit);
|
|
|
|
}
|
|
|
|
|
2013-09-17 01:03:09 +02:00
|
|
|
$this->readCustomFieldsFromRequest($request, $saved);
|
|
|
|
|
2013-09-10 19:04:26 +02:00
|
|
|
return $saved;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
|
2014-12-18 22:53:45 +01:00
|
|
|
$query = id(new ManiphestTaskQuery())
|
|
|
|
->needProjectPHIDs(true);
|
2013-09-10 19:04:26 +02:00
|
|
|
|
2015-04-23 14:13:12 +02:00
|
|
|
$viewer = $this->requireViewer();
|
|
|
|
|
|
|
|
$datasource = id(new PhabricatorTypeaheadUserParameterizedDatasource())
|
|
|
|
->setViewer($viewer);
|
|
|
|
|
|
|
|
$author_phids = $saved->getParameter('authorPHIDs', array());
|
|
|
|
$author_phids = $datasource->evaluateTokens($author_phids);
|
2013-09-10 19:44:42 +02:00
|
|
|
if ($author_phids) {
|
|
|
|
$query->withAuthors($author_phids);
|
|
|
|
}
|
|
|
|
|
2015-04-23 14:13:12 +02:00
|
|
|
$datasource = id(new PhabricatorMetaMTAMailableFunctionDatasource())
|
|
|
|
->setViewer($viewer);
|
|
|
|
$subscriber_phids = $saved->getParameter('subscriberPHIDs', array());
|
|
|
|
$subscriber_phids = $datasource->evaluateTokens($subscriber_phids);
|
2013-09-28 01:02:08 +02:00
|
|
|
if ($subscriber_phids) {
|
|
|
|
$query->withSubscribers($subscriber_phids);
|
|
|
|
}
|
|
|
|
|
2015-04-23 12:07:24 +02:00
|
|
|
$datasource = id(new PhabricatorPeopleOwnerDatasource())
|
2015-04-19 17:23:56 +02:00
|
|
|
->setViewer($this->requireViewer());
|
|
|
|
|
|
|
|
$assigned_phids = $this->readAssignedPHIDs($saved);
|
|
|
|
$assigned_phids = $datasource->evaluateTokens($assigned_phids);
|
|
|
|
if ($assigned_phids) {
|
|
|
|
$query->withOwners($assigned_phids);
|
2013-09-10 19:44:42 +02:00
|
|
|
}
|
2013-09-10 19:04:26 +02:00
|
|
|
|
2013-09-10 20:07:34 +02:00
|
|
|
$statuses = $saved->getParameter('statuses');
|
|
|
|
if ($statuses) {
|
|
|
|
$query->withStatuses($statuses);
|
|
|
|
}
|
|
|
|
|
2013-09-10 20:54:17 +02:00
|
|
|
$priorities = $saved->getParameter('priorities');
|
|
|
|
if ($priorities) {
|
|
|
|
$query->withPriorities($priorities);
|
|
|
|
}
|
|
|
|
|
2015-01-12 22:42:37 +01:00
|
|
|
|
|
|
|
$query->withBlockingTasks($saved->getParameter('blocking'));
|
|
|
|
$query->withBlockedTasks($saved->getParameter('blocked'));
|
|
|
|
|
2014-08-02 10:22:16 +02:00
|
|
|
$this->applyOrderByToQuery(
|
|
|
|
$query,
|
|
|
|
$this->getOrderValues(),
|
|
|
|
$saved->getParameter('order'));
|
2013-09-10 20:07:34 +02:00
|
|
|
|
2013-09-12 23:48:52 +02:00
|
|
|
$group = $saved->getParameter('group');
|
|
|
|
$group = idx($this->getGroupValues(), $group);
|
|
|
|
if ($group) {
|
|
|
|
$query->setGroupBy($group);
|
|
|
|
} else {
|
|
|
|
$query->setGroupBy(head($this->getGroupValues()));
|
|
|
|
}
|
|
|
|
|
2013-09-10 20:54:17 +02:00
|
|
|
$ids = $saved->getParameter('ids');
|
|
|
|
if ($ids) {
|
|
|
|
$query->withIDs($ids);
|
|
|
|
}
|
|
|
|
|
2013-09-12 22:03:05 +02:00
|
|
|
$fulltext = $saved->getParameter('fulltext');
|
|
|
|
if (strlen($fulltext)) {
|
|
|
|
$query->withFullTextSearch($fulltext);
|
|
|
|
}
|
|
|
|
|
2015-04-23 12:58:04 +02:00
|
|
|
$projects = $this->readProjectTokens($saved);
|
|
|
|
$adjusted = id(clone $saved)->setParameter('projects', $projects);
|
|
|
|
$this->setQueryProjects($query, $adjusted);
|
2013-09-12 22:03:14 +02:00
|
|
|
|
2013-09-12 22:03:39 +02:00
|
|
|
$start = $this->parseDateTime($saved->getParameter('createdStart'));
|
|
|
|
$end = $this->parseDateTime($saved->getParameter('createdEnd'));
|
|
|
|
|
|
|
|
if ($start) {
|
|
|
|
$query->withDateCreatedAfter($start);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($end) {
|
|
|
|
$query->withDateCreatedBefore($end);
|
|
|
|
}
|
|
|
|
|
2014-03-17 23:53:07 +01:00
|
|
|
$mod_start = $this->parseDateTime($saved->getParameter('modifiedStart'));
|
|
|
|
$mod_end = $this->parseDateTime($saved->getParameter('modifiedEnd'));
|
|
|
|
|
|
|
|
if ($mod_start) {
|
|
|
|
$query->withDateModifiedAfter($mod_start);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($mod_end) {
|
|
|
|
$query->withDateModifiedBefore($mod_end);
|
|
|
|
}
|
|
|
|
|
2013-09-17 01:03:09 +02:00
|
|
|
$this->applyCustomFieldsToQuery($query, $saved);
|
|
|
|
|
2013-09-10 19:04:26 +02:00
|
|
|
return $query;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function buildSearchForm(
|
|
|
|
AphrontFormView $form,
|
2013-09-10 19:44:42 +02:00
|
|
|
PhabricatorSavedQuery $saved) {
|
|
|
|
|
2015-04-19 17:23:56 +02:00
|
|
|
$assigned_phids = $this->readAssignedPHIDs($saved);
|
|
|
|
|
2013-09-10 19:44:42 +02:00
|
|
|
$author_phids = $saved->getParameter('authorPHIDs', array());
|
2015-04-23 12:58:04 +02:00
|
|
|
$projects = $this->readProjectTokens($saved);
|
2013-09-12 22:03:14 +02:00
|
|
|
|
2015-04-23 12:58:04 +02:00
|
|
|
$subscriber_phids = $saved->getParameter('subscriberPHIDs', array());
|
2013-09-10 19:44:42 +02:00
|
|
|
|
2013-09-10 20:07:34 +02:00
|
|
|
$statuses = $saved->getParameter('statuses', array());
|
2013-09-10 20:54:17 +02:00
|
|
|
$priorities = $saved->getParameter('priorities', array());
|
|
|
|
|
2015-01-12 22:42:37 +01:00
|
|
|
$blocking_control = id(new AphrontFormSelectControl())
|
|
|
|
->setLabel(pht('Blocking'))
|
|
|
|
->setName('blocking')
|
|
|
|
->setValue($this->getBoolFromQuery($saved, 'blocking'))
|
|
|
|
->setOptions(array(
|
|
|
|
'' => pht('Show All Tasks'),
|
|
|
|
'true' => pht('Show Tasks Blocking Other Tasks'),
|
2015-03-31 23:10:55 +02:00
|
|
|
'false' => pht('Show Tasks Not Blocking Other Tasks'),
|
|
|
|
));
|
|
|
|
|
2015-01-12 22:42:37 +01:00
|
|
|
$blocked_control = id(new AphrontFormSelectControl())
|
|
|
|
->setLabel(pht('Blocked'))
|
|
|
|
->setName('blocked')
|
|
|
|
->setValue($this->getBoolFromQuery($saved, 'blocked'))
|
|
|
|
->setOptions(array(
|
|
|
|
'' => pht('Show All Tasks'),
|
|
|
|
'true' => pht('Show Tasks Blocked By Other Tasks'),
|
2015-03-31 23:10:55 +02:00
|
|
|
'false' => pht('Show Tasks Not Blocked By Other Tasks'),
|
|
|
|
));
|
2015-01-12 22:42:37 +01:00
|
|
|
|
2013-09-10 20:54:17 +02:00
|
|
|
$ids = $saved->getParameter('ids', array());
|
|
|
|
|
2014-08-02 10:22:16 +02:00
|
|
|
$builtin_orders = $this->getOrderOptions();
|
|
|
|
$custom_orders = $this->getCustomFieldOrderOptions();
|
|
|
|
$all_orders = $builtin_orders + $custom_orders;
|
|
|
|
|
2013-09-10 19:44:42 +02:00
|
|
|
$form
|
2015-03-31 23:10:55 +02:00
|
|
|
->appendControl(
|
2013-09-10 19:44:42 +02:00
|
|
|
id(new AphrontFormTokenizerControl())
|
2015-04-23 12:07:24 +02:00
|
|
|
->setDatasource(new PhabricatorPeopleOwnerDatasource())
|
2013-09-10 19:44:42 +02:00
|
|
|
->setName('assigned')
|
|
|
|
->setLabel(pht('Assigned To'))
|
2015-03-31 23:10:55 +02:00
|
|
|
->setValue($assigned_phids))
|
|
|
|
->appendControl(
|
2013-09-12 22:03:14 +02:00
|
|
|
id(new AphrontFormTokenizerControl())
|
2015-04-23 12:58:04 +02:00
|
|
|
->setDatasource(new PhabricatorProjectLogicalDatasource())
|
|
|
|
->setName('projects')
|
|
|
|
->setLabel(pht('Projects'))
|
|
|
|
->setValue($projects))
|
2015-03-31 23:10:55 +02:00
|
|
|
->appendControl(
|
2013-09-10 19:44:42 +02:00
|
|
|
id(new AphrontFormTokenizerControl())
|
2015-04-23 14:13:12 +02:00
|
|
|
->setDatasource(new PhabricatorTypeaheadUserParameterizedDatasource())
|
2013-09-10 19:44:42 +02:00
|
|
|
->setName('authors')
|
|
|
|
->setLabel(pht('Authors'))
|
2015-03-31 23:10:55 +02:00
|
|
|
->setValue($author_phids))
|
|
|
|
->appendControl(
|
2013-09-28 01:02:08 +02:00
|
|
|
id(new AphrontFormTokenizerControl())
|
2015-04-23 14:13:12 +02:00
|
|
|
->setDatasource(new PhabricatorMetaMTAMailableFunctionDatasource())
|
2013-09-28 01:02:08 +02:00
|
|
|
->setName('subscribers')
|
|
|
|
->setLabel(pht('Subscribers'))
|
2015-03-31 23:10:55 +02:00
|
|
|
->setValue($subscriber_phids))
|
2015-04-23 14:48:26 +02:00
|
|
|
->appendControl(
|
|
|
|
id(new AphrontFormTokenizerControl())
|
|
|
|
->setDatasource(new ManiphestTaskStatusDatasource())
|
|
|
|
->setLabel(pht('Statuses'))
|
|
|
|
->setName('statuses')
|
|
|
|
->setValue($statuses))
|
|
|
|
->appendControl(
|
|
|
|
id(new AphrontFormTokenizerControl())
|
|
|
|
->setDatasource(new ManiphestTaskPriorityDatasource())
|
|
|
|
->setLabel(pht('Priorities'))
|
|
|
|
->setName('priorities')
|
|
|
|
->setValue($priorities))
|
2014-12-11 17:57:31 +01:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormTextControl())
|
|
|
|
->setName('fulltext')
|
|
|
|
->setLabel(pht('Contains Words'))
|
|
|
|
->setValue($saved->getParameter('fulltext')))
|
2015-01-12 22:42:37 +01:00
|
|
|
->appendChild($blocking_control)
|
|
|
|
->appendChild($blocked_control);
|
2014-05-20 20:42:05 +02:00
|
|
|
|
|
|
|
if (!$this->getIsBoardView()) {
|
|
|
|
$form
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSelectControl())
|
|
|
|
->setName('group')
|
|
|
|
->setLabel(pht('Group By'))
|
|
|
|
->setValue($saved->getParameter('group'))
|
|
|
|
->setOptions($this->getGroupOptions()))
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSelectControl())
|
|
|
|
->setName('order')
|
|
|
|
->setLabel(pht('Order By'))
|
|
|
|
->setValue($saved->getParameter('order'))
|
2014-08-02 10:22:16 +02:00
|
|
|
->setOptions($all_orders));
|
2014-05-20 20:42:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$form
|
2013-09-10 20:54:17 +02:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormTextControl())
|
|
|
|
->setName('ids')
|
|
|
|
->setLabel(pht('Task IDs'))
|
|
|
|
->setValue(implode(', ', $ids)));
|
2013-09-12 22:03:39 +02:00
|
|
|
|
2013-09-17 01:03:09 +02:00
|
|
|
$this->appendCustomFieldsToForm($form, $saved);
|
|
|
|
|
2013-09-12 22:03:39 +02:00
|
|
|
$this->buildDateRange(
|
|
|
|
$form,
|
|
|
|
$saved,
|
|
|
|
'createdStart',
|
|
|
|
pht('Created After'),
|
|
|
|
'createdEnd',
|
|
|
|
pht('Created Before'));
|
Allow Maniphest queries to have configurable page sizes
Summary:
Current page size is `1000`. This is nice to have in some cases, but makes pages slower than necessary in others. Task lists are generally dominated by rendering costs.
For example, my default is "recent tasks", which just lists all tasks ordered by date created. Showing 100 tasks here instead of 1000 makes this several times faster without compromising utility.
I don't want to force the default to 100, though, since sometimes listing everything is quite useful and I think an advantage of Maniphest is that it generally deals reasonably well with large task sets.
(This `limit` property is actually read by the default implementation of `getPageSize()` in the parent class.)
Test Plan: Made queries with page sizes 1, 100, 12, 9, 3000, etc.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D6976
2013-09-13 17:44:00 +02:00
|
|
|
|
2014-03-17 23:53:07 +01:00
|
|
|
$this->buildDateRange(
|
|
|
|
$form,
|
|
|
|
$saved,
|
|
|
|
'modifiedStart',
|
|
|
|
pht('Updated After'),
|
|
|
|
'modifiedEnd',
|
|
|
|
pht('Updated Before'));
|
|
|
|
|
2014-05-20 20:42:05 +02:00
|
|
|
if (!$this->getIsBoardView()) {
|
|
|
|
$form
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormTextControl())
|
|
|
|
->setName('limit')
|
|
|
|
->setLabel(pht('Page Size'))
|
|
|
|
->setValue($saved->getParameter('limit', 100)));
|
|
|
|
}
|
2013-09-10 19:04:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function getURI($path) {
|
2014-05-20 20:42:05 +02:00
|
|
|
if ($this->baseURI) {
|
|
|
|
return $this->baseURI.$path;
|
|
|
|
}
|
2013-09-10 19:04:26 +02:00
|
|
|
return '/maniphest/'.$path;
|
|
|
|
}
|
|
|
|
|
2015-01-06 21:34:51 +01:00
|
|
|
protected function getBuiltinQueryNames() {
|
2013-09-10 19:04:26 +02:00
|
|
|
$names = array();
|
|
|
|
|
|
|
|
if ($this->requireViewer()->isLoggedIn()) {
|
|
|
|
$names['assigned'] = pht('Assigned');
|
|
|
|
$names['authored'] = pht('Authored');
|
2013-11-14 19:13:20 +01:00
|
|
|
$names['subscribed'] = pht('Subscribed');
|
2013-09-10 19:04:26 +02:00
|
|
|
}
|
|
|
|
|
2013-09-10 20:07:34 +02:00
|
|
|
$names['open'] = pht('Open Tasks');
|
2013-09-10 19:04:26 +02:00
|
|
|
$names['all'] = pht('All Tasks');
|
|
|
|
|
|
|
|
return $names;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function buildSavedQueryFromBuiltin($query_key) {
|
|
|
|
|
|
|
|
$query = $this->newSavedQuery();
|
|
|
|
$query->setQueryKey($query_key);
|
|
|
|
|
2013-09-10 19:44:42 +02:00
|
|
|
$viewer_phid = $this->requireViewer()->getPHID();
|
|
|
|
|
2013-09-10 19:04:26 +02:00
|
|
|
switch ($query_key) {
|
|
|
|
case 'all':
|
|
|
|
return $query;
|
|
|
|
case 'assigned':
|
2013-09-10 20:07:34 +02:00
|
|
|
return $query
|
|
|
|
->setParameter('assignedPHIDs', array($viewer_phid))
|
2014-02-18 00:59:31 +01:00
|
|
|
->setParameter(
|
|
|
|
'statuses',
|
|
|
|
ManiphestTaskStatus::getOpenStatusConstants());
|
2013-11-14 19:13:20 +01:00
|
|
|
case 'subscribed':
|
|
|
|
return $query
|
|
|
|
->setParameter('subscriberPHIDs', array($viewer_phid))
|
2014-02-18 00:59:31 +01:00
|
|
|
->setParameter(
|
|
|
|
'statuses',
|
|
|
|
ManiphestTaskStatus::getOpenStatusConstants());
|
2013-09-10 20:07:34 +02:00
|
|
|
case 'open':
|
|
|
|
return $query
|
2014-02-18 00:59:31 +01:00
|
|
|
->setParameter(
|
|
|
|
'statuses',
|
|
|
|
ManiphestTaskStatus::getOpenStatusConstants());
|
2013-09-10 19:04:26 +02:00
|
|
|
case 'authored':
|
2013-09-10 20:07:34 +02:00
|
|
|
return $query
|
2013-09-13 01:58:09 +02:00
|
|
|
->setParameter('authorPHIDs', array($viewer_phid))
|
|
|
|
->setParameter('order', 'created')
|
|
|
|
->setParameter('group', 'none');
|
2013-09-10 19:04:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return parent::buildSavedQueryFromBuiltin($query_key);
|
|
|
|
}
|
|
|
|
|
2013-09-10 20:07:34 +02:00
|
|
|
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,
|
2014-07-23 02:03:09 +02:00
|
|
|
'updated' => ManiphestTaskQuery::ORDER_MODIFIED,
|
|
|
|
'created' => ManiphestTaskQuery::ORDER_CREATED,
|
|
|
|
'title' => ManiphestTaskQuery::ORDER_TITLE,
|
2013-09-10 20:07:34 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2013-09-12 23:48:52 +02:00
|
|
|
private function getGroupOptions() {
|
|
|
|
return array(
|
|
|
|
'priority' => pht('Priority'),
|
|
|
|
'assigned' => pht('Assigned'),
|
2014-07-23 02:03:09 +02:00
|
|
|
'status' => pht('Status'),
|
|
|
|
'project' => pht('Project'),
|
|
|
|
'none' => pht('None'),
|
2013-09-12 23:48:52 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function getGroupValues() {
|
|
|
|
return array(
|
|
|
|
'priority' => ManiphestTaskQuery::GROUP_PRIORITY,
|
|
|
|
'assigned' => ManiphestTaskQuery::GROUP_OWNER,
|
2014-07-23 02:03:09 +02:00
|
|
|
'status' => ManiphestTaskQuery::GROUP_STATUS,
|
|
|
|
'project' => ManiphestTaskQuery::GROUP_PROJECT,
|
|
|
|
'none' => ManiphestTaskQuery::GROUP_NONE,
|
2013-09-12 23:48:52 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2014-05-16 04:17:38 +02:00
|
|
|
protected function renderResultList(
|
|
|
|
array $tasks,
|
|
|
|
PhabricatorSavedQuery $saved,
|
|
|
|
array $handles) {
|
|
|
|
|
|
|
|
$viewer = $this->requireViewer();
|
|
|
|
|
2014-06-25 00:59:06 +02:00
|
|
|
if ($this->isPanelContext()) {
|
|
|
|
$can_edit_priority = false;
|
|
|
|
$can_bulk_edit = false;
|
|
|
|
} else {
|
|
|
|
$can_edit_priority = PhabricatorPolicyFilter::hasCapability(
|
|
|
|
$viewer,
|
|
|
|
$this->getApplication(),
|
2014-07-25 00:20:39 +02:00
|
|
|
ManiphestEditPriorityCapability::CAPABILITY);
|
2014-06-25 00:59:06 +02:00
|
|
|
|
|
|
|
$can_bulk_edit = PhabricatorPolicyFilter::hasCapability(
|
|
|
|
$viewer,
|
|
|
|
$this->getApplication(),
|
2014-07-25 00:20:39 +02:00
|
|
|
ManiphestBulkEditCapability::CAPABILITY);
|
2014-06-25 00:59:06 +02:00
|
|
|
}
|
2014-05-16 04:17:38 +02:00
|
|
|
|
|
|
|
return id(new ManiphestTaskResultListView())
|
|
|
|
->setUser($viewer)
|
|
|
|
->setTasks($tasks)
|
|
|
|
->setSavedQuery($saved)
|
|
|
|
->setCanEditPriority($can_edit_priority)
|
|
|
|
->setCanBatchEdit($can_bulk_edit)
|
|
|
|
->setShowBatchControls($this->showBatchControls);
|
|
|
|
}
|
|
|
|
|
2015-04-19 17:23:56 +02:00
|
|
|
private function readAssignedPHIDs(PhabricatorSavedQuery $saved) {
|
|
|
|
$assigned_phids = $saved->getParameter('assignedPHIDs', array());
|
|
|
|
|
|
|
|
// This may be present in old saved queries from before parameterized
|
|
|
|
// typeaheads, and is retained for compatibility. We could remove it by
|
|
|
|
// migrating old saved queries.
|
|
|
|
if ($saved->getParameter('withUnassigned')) {
|
2015-04-23 12:07:24 +02:00
|
|
|
$assigned_phids[] = PhabricatorPeopleNoOwnerDatasource::FUNCTION_TOKEN;
|
2015-04-19 17:23:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return $assigned_phids;
|
|
|
|
}
|
|
|
|
|
2015-04-23 12:58:04 +02:00
|
|
|
private function readProjectTokens(PhabricatorSavedQuery $saved) {
|
|
|
|
$projects = $saved->getParameter('projects', array());
|
|
|
|
|
|
|
|
$all = $saved->getParameter('allProjectPHIDs', array());
|
|
|
|
foreach ($all as $phid) {
|
|
|
|
$projects[] = $phid;
|
|
|
|
}
|
|
|
|
|
|
|
|
$any = $saved->getParameter('anyProjectPHIDs', array());
|
|
|
|
foreach ($any as $phid) {
|
|
|
|
$projects[] = 'any('.$phid.')';
|
|
|
|
}
|
|
|
|
|
|
|
|
$not = $saved->getParameter('excludeProjectPHIDs', array());
|
|
|
|
foreach ($not as $phid) {
|
|
|
|
$projects[] = 'not('.$phid.')';
|
|
|
|
}
|
|
|
|
|
|
|
|
$users = $saved->getParameter('userProjectPHIDs', array());
|
|
|
|
foreach ($users as $phid) {
|
|
|
|
$projects[] = 'projects('.$phid.')';
|
|
|
|
}
|
|
|
|
|
|
|
|
$no = $saved->getParameter('withNoProject');
|
|
|
|
if ($no) {
|
|
|
|
$projects[] = 'null()';
|
|
|
|
}
|
|
|
|
|
|
|
|
return $projects;
|
|
|
|
}
|
|
|
|
|
2013-09-10 19:04:26 +02:00
|
|
|
}
|