diff --git a/src/applications/maniphest/constants/ManiphestTaskPriority.php b/src/applications/maniphest/constants/ManiphestTaskPriority.php index 4ec7643683..38a56f767b 100644 --- a/src/applications/maniphest/constants/ManiphestTaskPriority.php +++ b/src/applications/maniphest/constants/ManiphestTaskPriority.php @@ -101,6 +101,9 @@ final class ManiphestTaskPriority extends ManiphestConstants { return idx(self::getColorMap(), $priority, 'black'); } + public static function getTaskPriorityIcon($priority) { + return 'fa-arrow-right'; + } private static function getConfig() { $config = PhabricatorEnv::getEnvConfig('maniphest.priorities'); diff --git a/src/applications/maniphest/constants/ManiphestTaskStatus.php b/src/applications/maniphest/constants/ManiphestTaskStatus.php index abbb1b1d18..b021dae40f 100644 --- a/src/applications/maniphest/constants/ManiphestTaskStatus.php +++ b/src/applications/maniphest/constants/ManiphestTaskStatus.php @@ -85,14 +85,16 @@ final class ManiphestTaskStatus extends ManiphestConstants { public static function renderFullDescription($status) { if (self::isOpenStatus($status)) { $color = 'status'; - $icon = 'fa-square-o bluegrey'; + $icon_color = 'bluegrey'; } else { $color = 'status-dark'; - $icon = 'fa-check-square-o'; + $icon_color = ''; } + $icon = self::getStatusIcon($status); + $img = id(new PHUIIconView()) - ->setIconFont($icon); + ->setIconFont($icon.' '.$icon_color); $tag = phutil_tag( 'span', @@ -166,7 +168,16 @@ final class ManiphestTaskStatus extends ManiphestConstants { } public static function getStatusIcon($status) { - return self::getStatusAttribute($status, 'transaction.icon'); + $icon = self::getStatusAttribute($status, 'transaction.icon'); + if ($icon) { + return $icon; + } + + if (self::isOpenStatus($status)) { + return 'fa-square-o'; + } else { + return 'fa-check-square-o'; + } } public static function getStatusPrefixMap() { diff --git a/src/applications/maniphest/query/ManiphestTaskSearchEngine.php b/src/applications/maniphest/query/ManiphestTaskSearchEngine.php index adeced3031..030d5dfdb3 100644 --- a/src/applications/maniphest/query/ManiphestTaskSearchEngine.php +++ b/src/applications/maniphest/query/ManiphestTaskSearchEngine.php @@ -219,28 +219,7 @@ final class ManiphestTaskSearchEngine $subscriber_phids = $saved->getParameter('subscriberPHIDs', array()); $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])); - } - $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])); - } $blocking_control = id(new AphrontFormSelectControl()) ->setLabel(pht('Blocking')) @@ -293,13 +272,23 @@ final class ManiphestTaskSearchEngine ->setName('subscribers') ->setLabel(pht('Subscribers')) ->setValue($subscriber_phids)) + ->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)) ->appendChild( id(new AphrontFormTextControl()) ->setName('fulltext') ->setLabel(pht('Contains Words')) ->setValue($saved->getParameter('fulltext'))) - ->appendChild($status_control) - ->appendChild($priority_control) ->appendChild($blocking_control) ->appendChild($blocked_control); diff --git a/src/applications/maniphest/typeahead/ManiphestTaskPriorityDatasource.php b/src/applications/maniphest/typeahead/ManiphestTaskPriorityDatasource.php index 59c9a08042..4e7dd639d6 100644 --- a/src/applications/maniphest/typeahead/ManiphestTaskPriorityDatasource.php +++ b/src/applications/maniphest/typeahead/ManiphestTaskPriorityDatasource.php @@ -16,20 +16,26 @@ final class ManiphestTaskPriorityDatasource } public function loadResults() { - $viewer = $this->getViewer(); - $raw_query = $this->getRawQuery(); + $results = $this->buildResults(); + return $this->filterResultsAgainstTokens($results); + } + public function renderTokens(array $values) { + return $this->renderTokensFromResults($this->buildResults(), $values); + } + + private function buildResults() { $results = array(); $priority_map = ManiphestTaskPriority::getTaskPriorityMap(); foreach ($priority_map as $value => $name) { - // NOTE: $value is not a PHID but is unique. This'll work. - $results[] = id(new PhabricatorTypeaheadResult()) + $results[$value] = id(new PhabricatorTypeaheadResult()) + ->setIcon(ManiphestTaskPriority::getTaskPriorityIcon($value)) ->setPHID($value) ->setName($name); } - return $this->filterResultsAgainstTokens($results); + return $results; } } diff --git a/src/applications/maniphest/typeahead/ManiphestTaskStatusDatasource.php b/src/applications/maniphest/typeahead/ManiphestTaskStatusDatasource.php index 7ef047e72e..7b8ed6ca76 100644 --- a/src/applications/maniphest/typeahead/ManiphestTaskStatusDatasource.php +++ b/src/applications/maniphest/typeahead/ManiphestTaskStatusDatasource.php @@ -16,19 +16,26 @@ final class ManiphestTaskStatusDatasource } public function loadResults() { - $viewer = $this->getViewer(); - $raw_query = $this->getRawQuery(); + $results = $this->buildResults(); + return $this->filterResultsAgainstTokens($results); + } + public function renderTokens(array $values) { + return $this->renderTokensFromResults($this->buildResults(), $values); + } + + private function buildResults() { $results = array(); $status_map = ManiphestTaskStatus::getTaskStatusMap(); foreach ($status_map as $value => $name) { - // NOTE: $value is not a PHID but is unique. This'll work. - $results[] = id(new PhabricatorTypeaheadResult()) + $results[$value] = id(new PhabricatorTypeaheadResult()) + ->setIcon(ManiphestTaskStatus::getStatusIcon($value)) ->setPHID($value) ->setName($name); } - return $this->filterResultsAgainstTokens($results); + return $results; } + } diff --git a/src/applications/search/typeahead/PhabricatorSearchDocumentTypeDatasource.php b/src/applications/search/typeahead/PhabricatorSearchDocumentTypeDatasource.php index 511363e7ed..407ab1cad4 100644 --- a/src/applications/search/typeahead/PhabricatorSearchDocumentTypeDatasource.php +++ b/src/applications/search/typeahead/PhabricatorSearchDocumentTypeDatasource.php @@ -21,16 +21,7 @@ final class PhabricatorSearchDocumentTypeDatasource } public function renderTokens(array $values) { - $results = $this->buildResults(); - $results = array_select_keys($results, $values); - - $tokens = array(); - foreach ($results as $result) { - $tokens[] = PhabricatorTypeaheadTokenView::newFromTypeaheadResult( - $result); - } - - return $tokens; + return $this->renderTokensFromResults($this->buildResults(), $values); } private function buildResults() { diff --git a/src/applications/typeahead/controller/PhabricatorTypeaheadModularDatasourceController.php b/src/applications/typeahead/controller/PhabricatorTypeaheadModularDatasourceController.php index c4813aab18..f0f274b894 100644 --- a/src/applications/typeahead/controller/PhabricatorTypeaheadModularDatasourceController.php +++ b/src/applications/typeahead/controller/PhabricatorTypeaheadModularDatasourceController.php @@ -73,7 +73,7 @@ final class PhabricatorTypeaheadModularDatasourceController // If this is a request for a specific token after the user clicks // "Select", return the token in wire format so it can be added to // the tokenizer. - if ($select_phid) { + if ($select_phid !== null) { $map = mpull($results, null, 'getPHID'); $token = idx($map, $select_phid); if (!$token) { diff --git a/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php b/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php index caca8351c7..cdf7208f25 100644 --- a/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php +++ b/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php @@ -423,4 +423,16 @@ abstract class PhabricatorTypeaheadDatasource extends Phobject { return nonempty(last($this->functionStack), null); } + protected function renderTokensFromResults(array $results, array $values) { + $results = array_select_keys($results, $values); + + $tokens = array(); + foreach ($results as $result) { + $tokens[] = PhabricatorTypeaheadTokenView::newFromTypeaheadResult( + $result); + } + + return $tokens; + } + }