mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-19 05:12:41 +01:00
Use typeaheads instead of checkbox lists for task status / priority
Summary: Ref T4100. This makes it slightly harder to choose, say, all priorities above X or all priorities except Y. We could add `open()`, `closed()`, `min()`, `max()`, and `not()` functions if there's a meaningful demand for them. I suspect some of these are maybe worthwhile while others aren't as worthwhile. Test Plan: {F380058} Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T4100 Differential Revision: https://secure.phabricator.com/D12528
This commit is contained in:
parent
fcaf56332f
commit
f69f53124c
8 changed files with 67 additions and 48 deletions
|
@ -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');
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue