mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-24 13:38:19 +01:00
Fix alternate filtering conditions in object selector dialog
Summary: These didn't get updated either when the main search got rebuilt. Adjust and modernize them. Also this uses "exclude", which I couldn't find any callsites for but just missed, so restore that. At some point I plan to swap this whole thing to ApplicationSearch and that will let us get rid of a bunch of stuff. Test Plan: Searched for all filters, got sensible results, verified source object doesn't show up as a result. Reviewers: btrahan Reviewed By: btrahan CC: aran, mbishopim3 Differential Revision: https://secure.phabricator.com/D8188
This commit is contained in:
parent
094922bcb9
commit
4e70664ed4
2 changed files with 32 additions and 10 deletions
|
@ -23,31 +23,36 @@ final class PhabricatorSearchSelectController
|
||||||
$query->setParameter('query', $query_str);
|
$query->setParameter('query', $query_str);
|
||||||
$query->setParameter('types', array($this->type));
|
$query->setParameter('types', array($this->type));
|
||||||
|
|
||||||
|
$status_open = PhabricatorSearchRelationship::RELATIONSHIP_OPEN;
|
||||||
|
|
||||||
switch ($request->getStr('filter')) {
|
switch ($request->getStr('filter')) {
|
||||||
case 'assigned':
|
case 'assigned':
|
||||||
$query->setParameter('owner', array($user->getPHID()));
|
$query->setParameter('ownerPHIDs', array($user->getPHID()));
|
||||||
$query->setParameter('open', 1);
|
$query->setParameter('statuses', array($status_open));
|
||||||
break;
|
break;
|
||||||
case 'created';
|
case 'created';
|
||||||
$query->setParameter('author', array($user->getPHID()));
|
$query->setParameter('authorPHIDs', array($user->getPHID()));
|
||||||
// TODO - if / when we allow pholio mocks to be archived, etc
|
// TODO - if / when we allow pholio mocks to be archived, etc
|
||||||
// update this
|
// update this
|
||||||
if ($this->type != PholioPHIDTypeMock::TYPECONST) {
|
if ($this->type != PholioPHIDTypeMock::TYPECONST) {
|
||||||
$query->setParameter('open', 1);
|
$query->setParameter('statuses', array($status_open));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'open':
|
case 'open':
|
||||||
$query->setParameter('open', 1);
|
$query->setParameter('statuses', array($status_open));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$query->setParameter('exclude', $request->getStr('exclude'));
|
$query->setParameter('excludePHIDs', array($request->getStr('exclude')));
|
||||||
$query->setParameter('limit', 100);
|
|
||||||
|
|
||||||
$engine = PhabricatorSearchEngineSelector::newSelector()->newEngine();
|
$results = id(new PhabricatorSearchDocumentQuery())
|
||||||
$results = $engine->executeSearch($query);
|
->setViewer($user)
|
||||||
|
->withSavedQuery($query)
|
||||||
|
->setOffset(0)
|
||||||
|
->setLimit(100)
|
||||||
|
->execute();
|
||||||
|
|
||||||
$phids = array_fill_keys($results, true);
|
$phids = array_fill_keys(mpull($results, 'getPHID'), true);
|
||||||
$phids += $this->queryObjectNames($query_str);
|
$phids += $this->queryObjectNames($query_str);
|
||||||
|
|
||||||
$phids = array_keys($phids);
|
$phids = array_keys($phids);
|
||||||
|
|
|
@ -25,6 +25,19 @@ final class PhabricatorSearchDocumentQuery
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function willFilterPage(array $handles) {
|
protected function willFilterPage(array $handles) {
|
||||||
|
|
||||||
|
// NOTE: This is used by the object selector dialog to exclude the object
|
||||||
|
// you're looking at, so that, e.g., a task can't be set as a dependency
|
||||||
|
// of itself in the UI.
|
||||||
|
|
||||||
|
// TODO: Remove this after object selection moves to ApplicationSearch.
|
||||||
|
|
||||||
|
$exclude = array();
|
||||||
|
if ($this->savedQuery) {
|
||||||
|
$exclude_phids = $this->savedQuery->getParameter('excludePHIDs', array());
|
||||||
|
$exclude = array_fuse($exclude_phids);
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($handles as $key => $handle) {
|
foreach ($handles as $key => $handle) {
|
||||||
if (!$handle->isComplete()) {
|
if (!$handle->isComplete()) {
|
||||||
unset($handles[$key]);
|
unset($handles[$key]);
|
||||||
|
@ -34,6 +47,10 @@ final class PhabricatorSearchDocumentQuery
|
||||||
unset($handles[$key]);
|
unset($handles[$key]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (isset($exclude[$handle->getPHID()])) {
|
||||||
|
unset($handles[$key]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $handles;
|
return $handles;
|
||||||
|
|
Loading…
Add table
Reference in a new issue