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