mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-28 00:10:57 +01:00
Render browse results with global result style
Summary: Ref T11034. This seems a little more promising. Two problems at the moment: - This doesn't actually provide any useful information at all right now. - Many object types have no profile images. Test Plan: {F1695254} {F1695255} Reviewers: chad Reviewed By: chad Maniphest Tasks: T11034 Differential Revision: https://secure.phabricator.com/D16155
This commit is contained in:
parent
851aba80ce
commit
6f275ba144
23 changed files with 258 additions and 52 deletions
|
@ -28,7 +28,7 @@ return array(
|
||||||
'rsrc/css/aphront/table-view.css' => '9258e19f',
|
'rsrc/css/aphront/table-view.css' => '9258e19f',
|
||||||
'rsrc/css/aphront/tokenizer.css' => '056da01b',
|
'rsrc/css/aphront/tokenizer.css' => '056da01b',
|
||||||
'rsrc/css/aphront/tooltip.css' => '1a07aea8',
|
'rsrc/css/aphront/tooltip.css' => '1a07aea8',
|
||||||
'rsrc/css/aphront/typeahead-browse.css' => 'd8581d2c',
|
'rsrc/css/aphront/typeahead-browse.css' => '8904346a',
|
||||||
'rsrc/css/aphront/typeahead.css' => 'd4f16145',
|
'rsrc/css/aphront/typeahead.css' => 'd4f16145',
|
||||||
'rsrc/css/application/almanac/almanac.css' => 'dbb9b3af',
|
'rsrc/css/application/almanac/almanac.css' => 'dbb9b3af',
|
||||||
'rsrc/css/application/auth/auth.css' => '0877ed6e',
|
'rsrc/css/application/auth/auth.css' => '0877ed6e',
|
||||||
|
@ -889,7 +889,7 @@ return array(
|
||||||
'syntax-default-css' => '9923583c',
|
'syntax-default-css' => '9923583c',
|
||||||
'syntax-highlighting-css' => '9fc496d5',
|
'syntax-highlighting-css' => '9fc496d5',
|
||||||
'tokens-css' => '3d0f239e',
|
'tokens-css' => '3d0f239e',
|
||||||
'typeahead-browse-css' => 'd8581d2c',
|
'typeahead-browse-css' => '8904346a',
|
||||||
'unhandled-exception-css' => '4c96257a',
|
'unhandled-exception-css' => '4c96257a',
|
||||||
),
|
),
|
||||||
'requires' => array(
|
'requires' => array(
|
||||||
|
|
|
@ -31,24 +31,50 @@ final class DiffusionRepositoryDatasource
|
||||||
"phabricator-search-icon phui-font-fa phui-icon-view {$type_icon}";
|
"phabricator-search-icon phui-font-fa phui-icon-view {$type_icon}";
|
||||||
|
|
||||||
$results = array();
|
$results = array();
|
||||||
foreach ($repos as $repo) {
|
foreach ($repos as $repository) {
|
||||||
$display_name = $repo->getMonogram().' '.$repo->getName();
|
$monogram = $repository->getMonogram();
|
||||||
|
$name = $repository->getName();
|
||||||
|
|
||||||
$name = $display_name;
|
$display_name = "{$monogram} {$name}";
|
||||||
$slug = $repo->getRepositorySlug();
|
|
||||||
|
$parts = array();
|
||||||
|
$parts[] = $name;
|
||||||
|
|
||||||
|
$slug = $repository->getRepositorySlug();
|
||||||
if (strlen($slug)) {
|
if (strlen($slug)) {
|
||||||
$name = "{$name} {$slug}";
|
$parts[] = $slug;
|
||||||
}
|
}
|
||||||
|
|
||||||
$results[] = id(new PhabricatorTypeaheadResult())
|
$callsign = $repository->getCallsign();
|
||||||
|
if ($callsign) {
|
||||||
|
$parts[] = $callsign;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($repository->getAllMonograms() as $monogram) {
|
||||||
|
$parts[] = $monogram;
|
||||||
|
}
|
||||||
|
|
||||||
|
$name = implode(' ', $parts);
|
||||||
|
|
||||||
|
$vcs = $repository->getVersionControlSystem();
|
||||||
|
$vcs_type = PhabricatorRepositoryType::getNameForRepositoryType($vcs);
|
||||||
|
|
||||||
|
$result = id(new PhabricatorTypeaheadResult())
|
||||||
->setName($name)
|
->setName($name)
|
||||||
->setDisplayName($display_name)
|
->setDisplayName($display_name)
|
||||||
->setURI($repo->getURI())
|
->setURI($repository->getURI())
|
||||||
->setPHID($repo->getPHID())
|
->setPHID($repository->getPHID())
|
||||||
->setPriorityString($repo->getMonogram())
|
->setPriorityString($repository->getMonogram())
|
||||||
->setPriorityType('repo')
|
->setPriorityType('repo')
|
||||||
->setImageSprite($image_sprite)
|
->setImageSprite($image_sprite)
|
||||||
->setDisplayType(pht('Repository'));
|
->setDisplayType(pht('Repository'))
|
||||||
|
->addAttribute($vcs_type);
|
||||||
|
|
||||||
|
if (!$repository->isTracked()) {
|
||||||
|
$result->setClosed(pht('Inactive'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$results[] = $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
|
@ -43,7 +43,10 @@ final class DiffusionTaggedRepositoriesFunctionDatasource
|
||||||
->setColor(null)
|
->setColor(null)
|
||||||
->setPHID('tagged('.$result->getPHID().')')
|
->setPHID('tagged('.$result->getPHID().')')
|
||||||
->setDisplayName(pht('Tagged: %s', $result->getDisplayName()))
|
->setDisplayName(pht('Tagged: %s', $result->getDisplayName()))
|
||||||
->setName('tagged '.$result->getName());
|
->setName('tagged '.$result->getName())
|
||||||
|
->resetAttributes()
|
||||||
|
->addAttribute(pht('Function'))
|
||||||
|
->addAttribute(pht('Select repositories tagged with this project.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
|
@ -7,6 +7,10 @@ final class DrydockBlueprintDatasource
|
||||||
return pht('Type a blueprint name...');
|
return pht('Type a blueprint name...');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getBrowseTitle() {
|
||||||
|
return pht('Browse Blueprints');
|
||||||
|
}
|
||||||
|
|
||||||
public function getDatasourceApplicationClass() {
|
public function getDatasourceApplicationClass() {
|
||||||
return 'PhabricatorDrydockApplication';
|
return 'PhabricatorDrydockApplication';
|
||||||
}
|
}
|
||||||
|
@ -37,6 +41,9 @@ final class DrydockBlueprintDatasource
|
||||||
$result->setClosed(pht('Disabled'));
|
$result->setClosed(pht('Disabled'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$result->addAttribute(
|
||||||
|
$blueprint->getImplementation()->getBlueprintName());
|
||||||
|
|
||||||
$results[] = $result;
|
$results[] = $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,8 @@ final class ManiphestTaskClosedStatusDatasource
|
||||||
->setName($name.' closed')
|
->setName($name.' closed')
|
||||||
->setDisplayName($name)
|
->setDisplayName($name)
|
||||||
->setPHID(self::FUNCTION_TOKEN)
|
->setPHID(self::FUNCTION_TOKEN)
|
||||||
->setUnique(true);
|
->setUnique(true)
|
||||||
|
->addAttribute(pht('Select any closed status.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,8 @@ final class ManiphestTaskOpenStatusDatasource
|
||||||
->setName($name.' open')
|
->setName($name.' open')
|
||||||
->setDisplayName($name)
|
->setDisplayName($name)
|
||||||
->setPHID(self::FUNCTION_TOKEN)
|
->setPHID(self::FUNCTION_TOKEN)
|
||||||
->setUnique(true);
|
->setUnique(true)
|
||||||
|
->addAttribute(pht('Select any open status.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,8 @@ final class ManiphestTaskPriorityDatasource
|
||||||
$result = id(new PhabricatorTypeaheadResult())
|
$result = id(new PhabricatorTypeaheadResult())
|
||||||
->setIcon(ManiphestTaskPriority::getTaskPriorityIcon($value))
|
->setIcon(ManiphestTaskPriority::getTaskPriorityIcon($value))
|
||||||
->setPHID($value)
|
->setPHID($value)
|
||||||
->setName($name);
|
->setName($name)
|
||||||
|
->addAttribute(pht('Priority'));
|
||||||
|
|
||||||
if (ManiphestTaskPriority::isDisabledPriority($value)) {
|
if (ManiphestTaskPriority::isDisabledPriority($value)) {
|
||||||
$result->setClosed(pht('Disabled'));
|
$result->setClosed(pht('Disabled'));
|
||||||
|
|
|
@ -35,6 +35,12 @@ final class ManiphestTaskStatusDatasource
|
||||||
->setPHID($value)
|
->setPHID($value)
|
||||||
->setName($name);
|
->setName($name);
|
||||||
|
|
||||||
|
if (ManiphestTaskStatus::isOpenStatus($value)) {
|
||||||
|
$result->addAttribute(pht('Open Status'));
|
||||||
|
} else {
|
||||||
|
$result->addAttribute(pht('Closed Status'));
|
||||||
|
}
|
||||||
|
|
||||||
if (ManiphestTaskStatus::isDisabledStatus($value)) {
|
if (ManiphestTaskStatus::isDisabledStatus($value)) {
|
||||||
$result->setClosed(pht('Disabled'));
|
$result->setClosed(pht('Disabled'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,8 @@ final class PhabricatorPeopleAnyOwnerDatasource
|
||||||
->setDisplayName($name)
|
->setDisplayName($name)
|
||||||
->setIcon('fa-certificate')
|
->setIcon('fa-certificate')
|
||||||
->setPHID(self::FUNCTION_TOKEN)
|
->setPHID(self::FUNCTION_TOKEN)
|
||||||
->setUnique(true);
|
->setUnique(true)
|
||||||
|
->addAttribute(pht('Select results with any owner.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,18 +3,6 @@
|
||||||
final class PhabricatorPeopleDatasource
|
final class PhabricatorPeopleDatasource
|
||||||
extends PhabricatorTypeaheadDatasource {
|
extends PhabricatorTypeaheadDatasource {
|
||||||
|
|
||||||
private $enrichResults;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Controls enriched rendering, for global search. This is a bit hacky and
|
|
||||||
* should probably be handled in a more general way, but is fairly reasonable
|
|
||||||
* for now.
|
|
||||||
*/
|
|
||||||
public function setEnrichResults($enrich) {
|
|
||||||
$this->enrichResults = $enrich;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getBrowseTitle() {
|
public function getBrowseTitle() {
|
||||||
return pht('Browse Users');
|
return pht('Browse Users');
|
||||||
}
|
}
|
||||||
|
@ -40,7 +28,9 @@ final class PhabricatorPeopleDatasource
|
||||||
|
|
||||||
$users = $this->executeQuery($query);
|
$users = $this->executeQuery($query);
|
||||||
|
|
||||||
if ($this->enrichResults && $users) {
|
$is_browse = $this->getIsBrowse();
|
||||||
|
|
||||||
|
if ($is_browse && $users) {
|
||||||
$phids = mpull($users, 'getPHID');
|
$phids = mpull($users, 'getPHID');
|
||||||
$handles = id(new PhabricatorHandleQuery())
|
$handles = id(new PhabricatorHandleQuery())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
|
@ -50,6 +40,8 @@ final class PhabricatorPeopleDatasource
|
||||||
|
|
||||||
$results = array();
|
$results = array();
|
||||||
foreach ($users as $user) {
|
foreach ($users as $user) {
|
||||||
|
$phid = $user->getPHID();
|
||||||
|
|
||||||
$closed = null;
|
$closed = null;
|
||||||
if ($user->getIsDisabled()) {
|
if ($user->getIsDisabled()) {
|
||||||
$closed = pht('Disabled');
|
$closed = pht('Disabled');
|
||||||
|
@ -64,7 +56,7 @@ final class PhabricatorPeopleDatasource
|
||||||
$result = id(new PhabricatorTypeaheadResult())
|
$result = id(new PhabricatorTypeaheadResult())
|
||||||
->setName($user->getFullName())
|
->setName($user->getFullName())
|
||||||
->setURI('/p/'.$username.'/')
|
->setURI('/p/'.$username.'/')
|
||||||
->setPHID($user->getPHID())
|
->setPHID($phid)
|
||||||
->setPriorityString($username)
|
->setPriorityString($username)
|
||||||
->setPriorityType('user')
|
->setPriorityType('user')
|
||||||
->setAutocomplete('@'.$username)
|
->setAutocomplete('@'.$username)
|
||||||
|
@ -74,13 +66,29 @@ final class PhabricatorPeopleDatasource
|
||||||
$result->setIcon('fa-envelope-o');
|
$result->setIcon('fa-envelope-o');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->enrichResults) {
|
if ($is_browse) {
|
||||||
$display_type = pht('User');
|
$handle = $handles[$phid];
|
||||||
|
|
||||||
|
$result
|
||||||
|
->setIcon($handle->getIcon())
|
||||||
|
->setImageURI($handle->getImageURI())
|
||||||
|
->addAttribute($handle->getSubtitle());
|
||||||
|
|
||||||
|
if ($user->getIsAdmin()) {
|
||||||
|
$result->addAttribute(
|
||||||
|
array(
|
||||||
|
id(new PHUIIconView())->setIcon('fa-star'),
|
||||||
|
' ',
|
||||||
|
pht('Administrator'),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
if ($user->getIsAdmin()) {
|
if ($user->getIsAdmin()) {
|
||||||
$display_type = pht('Administrator');
|
$display_type = pht('Administrator');
|
||||||
|
} else {
|
||||||
|
$display_type = pht('User');
|
||||||
}
|
}
|
||||||
$result->setDisplayType($display_type);
|
$result->setDisplayType($display_type);
|
||||||
$result->setImageURI($handles[$user->getPHID()]->getImageURI());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$results[] = $result;
|
$results[] = $result;
|
||||||
|
|
|
@ -69,7 +69,8 @@ final class PhabricatorPeopleNoOwnerDatasource
|
||||||
->setDisplayName($name)
|
->setDisplayName($name)
|
||||||
->setIcon('fa-ban')
|
->setIcon('fa-ban')
|
||||||
->setPHID('none()')
|
->setPHID('none()')
|
||||||
->setUnique(true);
|
->setUnique(true)
|
||||||
|
->addAttribute(pht('Select results with no owner.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,8 @@ final class PhabricatorViewerDatasource
|
||||||
->setName(pht('Current Viewer'))
|
->setName(pht('Current Viewer'))
|
||||||
->setPHID('viewer()')
|
->setPHID('viewer()')
|
||||||
->setIcon('fa-user')
|
->setIcon('fa-user')
|
||||||
->setUnique(true);
|
->setUnique(true)
|
||||||
|
->addAttribute(pht('Select current viewer.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,9 +55,25 @@ final class PhabricatorProjectDatasource
|
||||||
$has_cols = array_fill_keys(array_keys($projs), true);
|
$has_cols = array_fill_keys(array_keys($projs), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$is_browse = $this->getIsBrowse();
|
||||||
|
if ($is_browse && $projs) {
|
||||||
|
// TODO: This is a little ad-hoc, but we don't currently have
|
||||||
|
// infrastructure for bulk querying custom fields efficiently.
|
||||||
|
$table = new PhabricatorProjectCustomFieldStorage();
|
||||||
|
$descriptions = $table->loadAllWhere(
|
||||||
|
'objectPHID IN (%Ls) AND fieldIndex = %s',
|
||||||
|
array_keys($projs),
|
||||||
|
PhabricatorHash::digestForIndex('std:project:internal:description'));
|
||||||
|
$descriptions = mpull($descriptions, 'getFieldValue', 'getObjectPHID');
|
||||||
|
} else {
|
||||||
|
$descriptions = array();
|
||||||
|
}
|
||||||
|
|
||||||
$results = array();
|
$results = array();
|
||||||
foreach ($projs as $proj) {
|
foreach ($projs as $proj) {
|
||||||
if (!isset($has_cols[$proj->getPHID()])) {
|
$phid = $proj->getPHID();
|
||||||
|
|
||||||
|
if (!isset($has_cols[$phid])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,7 +115,7 @@ final class PhabricatorProjectDatasource
|
||||||
->setDisplayName($proj->getDisplayName())
|
->setDisplayName($proj->getDisplayName())
|
||||||
->setDisplayType($proj->getDisplayIconName())
|
->setDisplayType($proj->getDisplayIconName())
|
||||||
->setURI($proj->getURI())
|
->setURI($proj->getURI())
|
||||||
->setPHID($proj->getPHID())
|
->setPHID($phid)
|
||||||
->setIcon($proj->getDisplayIconIcon())
|
->setIcon($proj->getDisplayIconIcon())
|
||||||
->setColor($proj->getColor())
|
->setColor($proj->getColor())
|
||||||
->setPriorityType('proj')
|
->setPriorityType('proj')
|
||||||
|
@ -111,6 +127,16 @@ final class PhabricatorProjectDatasource
|
||||||
|
|
||||||
$proj_result->setImageURI($proj->getProfileImageURI());
|
$proj_result->setImageURI($proj->getProfileImageURI());
|
||||||
|
|
||||||
|
if ($is_browse) {
|
||||||
|
$proj_result->addAttribute($proj->getDisplayIconName());
|
||||||
|
|
||||||
|
$description = idx($descriptions, $phid);
|
||||||
|
if (strlen($description)) {
|
||||||
|
$summary = PhabricatorMarkupEngine::summarize($description);
|
||||||
|
$proj_result->addAttribute($summary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$results[] = $proj_result;
|
$results[] = $proj_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,20 +86,24 @@ final class PhabricatorProjectLogicalOrNotDatasource
|
||||||
$result
|
$result
|
||||||
->setTokenType(PhabricatorTypeaheadTokenView::TYPE_FUNCTION)
|
->setTokenType(PhabricatorTypeaheadTokenView::TYPE_FUNCTION)
|
||||||
->setIcon('fa-asterisk')
|
->setIcon('fa-asterisk')
|
||||||
->setColor(null);
|
->setColor(null)
|
||||||
|
->resetAttributes()
|
||||||
|
->addAttribute(pht('Function'));
|
||||||
|
|
||||||
if ($return_any) {
|
if ($return_any) {
|
||||||
$return[] = id(clone $result)
|
$return[] = id(clone $result)
|
||||||
->setPHID('any('.$result->getPHID().')')
|
->setPHID('any('.$result->getPHID().')')
|
||||||
->setDisplayName(pht('In Any: %s', $result->getDisplayName()))
|
->setDisplayName(pht('In Any: %s', $result->getDisplayName()))
|
||||||
->setName('any '.$result->getName());
|
->setName('any '.$result->getName())
|
||||||
|
->addAttribute(pht('Include results tagged with this project.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($return_not) {
|
if ($return_not) {
|
||||||
$return[] = id(clone $result)
|
$return[] = id(clone $result)
|
||||||
->setPHID('not('.$result->getPHID().')')
|
->setPHID('not('.$result->getPHID().')')
|
||||||
->setDisplayName(pht('Not In: %s', $result->getDisplayName()))
|
->setDisplayName(pht('Not In: %s', $result->getDisplayName()))
|
||||||
->setName('not '.$result->getName());
|
->setName('not '.$result->getName())
|
||||||
|
->addAttribute(pht('Exclude results tagged with this project.'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,8 @@ final class PhabricatorProjectLogicalViewerDatasource
|
||||||
->setName(pht('Current Viewer\'s Projects'))
|
->setName(pht('Current Viewer\'s Projects'))
|
||||||
->setPHID('viewerprojects()')
|
->setPHID('viewerprojects()')
|
||||||
->setIcon('fa-asterisk')
|
->setIcon('fa-asterisk')
|
||||||
->setUnique(true);
|
->setUnique(true)
|
||||||
|
->addAttribute(pht('Select projects current viewer is a member of.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,10 @@ final class PhabricatorProjectMembersDatasource
|
||||||
->setColor(null)
|
->setColor(null)
|
||||||
->setPHID('members('.$result->getPHID().')')
|
->setPHID('members('.$result->getPHID().')')
|
||||||
->setDisplayName(pht('Members: %s', $result->getDisplayName()))
|
->setDisplayName(pht('Members: %s', $result->getDisplayName()))
|
||||||
->setName($result->getName().' members');
|
->setName($result->getName().' members')
|
||||||
|
->resetAttributes()
|
||||||
|
->addAttribute(pht('Function'))
|
||||||
|
->addAttribute(pht('Select project members.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
|
@ -68,7 +68,8 @@ final class PhabricatorProjectNoProjectsDatasource
|
||||||
->setPHID('null()')
|
->setPHID('null()')
|
||||||
->setIcon('fa-ban')
|
->setIcon('fa-ban')
|
||||||
->setName('null '.$name)
|
->setName('null '.$name)
|
||||||
->setDisplayName($name);
|
->setDisplayName($name)
|
||||||
|
->addAttribute(pht('Select results with no tags.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,14 +16,22 @@ final class PhabricatorSearchDatasource
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getComponentDatasources() {
|
public function getComponentDatasources() {
|
||||||
return array(
|
$sources = array(
|
||||||
id(new PhabricatorPeopleDatasource())->setEnrichResults(true),
|
new PhabricatorPeopleDatasource(),
|
||||||
new PhabricatorProjectDatasource(),
|
new PhabricatorProjectDatasource(),
|
||||||
new PhabricatorApplicationDatasource(),
|
new PhabricatorApplicationDatasource(),
|
||||||
new PhabricatorTypeaheadMonogramDatasource(),
|
new PhabricatorTypeaheadMonogramDatasource(),
|
||||||
new DiffusionRepositoryDatasource(),
|
new DiffusionRepositoryDatasource(),
|
||||||
new DiffusionSymbolDatasource(),
|
new DiffusionSymbolDatasource(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// These results are always rendered in the full browse display mode, so
|
||||||
|
// set the browse flag on all component sources.
|
||||||
|
foreach ($sources as $source) {
|
||||||
|
$source->setIsBrowse(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $sources;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,8 @@ final class PhabricatorTypeaheadModularDatasourceController
|
||||||
}
|
}
|
||||||
|
|
||||||
$composite
|
$composite
|
||||||
->setOffset($offset);
|
->setOffset($offset)
|
||||||
|
->setIsBrowse(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$results = $composite->loadResults();
|
$results = $composite->loadResults();
|
||||||
|
@ -142,8 +143,7 @@ final class PhabricatorTypeaheadModularDatasourceController
|
||||||
|
|
||||||
$items = array();
|
$items = array();
|
||||||
foreach ($results as $result) {
|
foreach ($results as $result) {
|
||||||
$token = PhabricatorTypeaheadTokenView::newFromTypeaheadResult(
|
$information = $this->renderBrowseResult($result);
|
||||||
$result);
|
|
||||||
|
|
||||||
// Disable already-selected tokens.
|
// Disable already-selected tokens.
|
||||||
$disabled = isset($exclude[$result->getPHID()]);
|
$disabled = isset($exclude[$result->getPHID()]);
|
||||||
|
@ -167,8 +167,8 @@ final class PhabricatorTypeaheadModularDatasourceController
|
||||||
'class' => 'typeahead-browse-item grouped',
|
'class' => 'typeahead-browse-item grouped',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
$token,
|
|
||||||
$button,
|
$button,
|
||||||
|
$information,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -350,4 +350,56 @@ final class PhabricatorTypeaheadModularDatasourceController
|
||||||
->appendChild($view);
|
->appendChild($view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function renderBrowseResult(PhabricatorTypeaheadResult $result) {
|
||||||
|
$class = array();
|
||||||
|
$style = array();
|
||||||
|
$separator = " \xC2\xB7 ";
|
||||||
|
|
||||||
|
$class[] = 'phabricator-main-search-typeahead-result';
|
||||||
|
|
||||||
|
$name = phutil_tag(
|
||||||
|
'div',
|
||||||
|
array(
|
||||||
|
'class' => 'result-name',
|
||||||
|
),
|
||||||
|
$result->getDisplayName());
|
||||||
|
|
||||||
|
$icon = $result->getIcon();
|
||||||
|
$icon = id(new PHUIIconView())->setIcon($icon);
|
||||||
|
|
||||||
|
$attributes = $result->getAttributes();
|
||||||
|
$attributes = phutil_implode_html($separator, $attributes);
|
||||||
|
$attributes = array($icon, ' ', $attributes);
|
||||||
|
|
||||||
|
$closed = $result->getClosed();
|
||||||
|
if ($closed) {
|
||||||
|
$class[] = 'result-closed';
|
||||||
|
$attributes = array($closed, $separator, $attributes);
|
||||||
|
}
|
||||||
|
|
||||||
|
$attributes = phutil_tag(
|
||||||
|
'div',
|
||||||
|
array(
|
||||||
|
'class' => 'result-type',
|
||||||
|
),
|
||||||
|
$attributes);
|
||||||
|
|
||||||
|
$image = $result->getImageURI();
|
||||||
|
if ($image) {
|
||||||
|
$style[] = 'background-image: url('.$image.');';
|
||||||
|
$class[] = 'has-image';
|
||||||
|
}
|
||||||
|
|
||||||
|
return phutil_tag(
|
||||||
|
'div',
|
||||||
|
array(
|
||||||
|
'class' => implode(' ', $class),
|
||||||
|
'style' => implode(' ', $style),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
$name,
|
||||||
|
$attributes,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ abstract class PhabricatorTypeaheadCompositeDatasource
|
||||||
}
|
}
|
||||||
|
|
||||||
$stack = $this->getFunctionStack();
|
$stack = $this->getFunctionStack();
|
||||||
|
$is_browse = $this->getIsBrowse();
|
||||||
|
|
||||||
$results = array();
|
$results = array();
|
||||||
foreach ($this->getUsableDatasources() as $source) {
|
foreach ($this->getUsableDatasources() as $source) {
|
||||||
|
@ -70,6 +71,10 @@ abstract class PhabricatorTypeaheadCompositeDatasource
|
||||||
$source->setLimit($offset + $limit);
|
$source->setLimit($offset + $limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($is_browse) {
|
||||||
|
$source->setIsBrowse(true);
|
||||||
|
}
|
||||||
|
|
||||||
$source_results = $source->loadResults();
|
$source_results = $source->loadResults();
|
||||||
$source_results = $source->didLoadResults($source_results);
|
$source_results = $source->didLoadResults($source_results);
|
||||||
$results[] = $source_results;
|
$results[] = $source_results;
|
||||||
|
|
|
@ -12,6 +12,7 @@ abstract class PhabricatorTypeaheadDatasource extends Phobject {
|
||||||
private $limit;
|
private $limit;
|
||||||
private $parameters = array();
|
private $parameters = array();
|
||||||
private $functionStack = array();
|
private $functionStack = array();
|
||||||
|
private $isBrowse;
|
||||||
|
|
||||||
public function setLimit($limit) {
|
public function setLimit($limit) {
|
||||||
$this->limit = $limit;
|
$this->limit = $limit;
|
||||||
|
@ -71,6 +72,15 @@ abstract class PhabricatorTypeaheadDatasource extends Phobject {
|
||||||
return idx($this->parameters, $name, $default);
|
return idx($this->parameters, $name, $default);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setIsBrowse($is_browse) {
|
||||||
|
$this->isBrowse = $is_browse;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getIsBrowse() {
|
||||||
|
return $this->isBrowse;
|
||||||
|
}
|
||||||
|
|
||||||
public function getDatasourceURI() {
|
public function getDatasourceURI() {
|
||||||
$uri = new PhutilURI('/typeahead/class/'.get_class($this).'/');
|
$uri = new PhutilURI('/typeahead/class/'.get_class($this).'/');
|
||||||
$uri->setQueryParams($this->parameters);
|
$uri->setQueryParams($this->parameters);
|
||||||
|
@ -199,7 +209,8 @@ abstract class PhabricatorTypeaheadDatasource extends Phobject {
|
||||||
protected function newFunctionResult() {
|
protected function newFunctionResult() {
|
||||||
return id(new PhabricatorTypeaheadResult())
|
return id(new PhabricatorTypeaheadResult())
|
||||||
->setTokenType(PhabricatorTypeaheadTokenView::TYPE_FUNCTION)
|
->setTokenType(PhabricatorTypeaheadTokenView::TYPE_FUNCTION)
|
||||||
->setIcon('fa-asterisk');
|
->setIcon('fa-asterisk')
|
||||||
|
->addAttribute(pht('Function'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function newInvalidToken($name) {
|
public function newInvalidToken($name) {
|
||||||
|
|
|
@ -17,6 +17,7 @@ final class PhabricatorTypeaheadResult extends Phobject {
|
||||||
private $tokenType;
|
private $tokenType;
|
||||||
private $unique;
|
private $unique;
|
||||||
private $autocomplete;
|
private $autocomplete;
|
||||||
|
private $attributes = array();
|
||||||
|
|
||||||
public function setIcon($icon) {
|
public function setIcon($icon) {
|
||||||
$this->icon = $icon;
|
$this->icon = $icon;
|
||||||
|
@ -188,4 +189,26 @@ final class PhabricatorTypeaheadResult extends Phobject {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getImageURI() {
|
||||||
|
return $this->imageURI;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getClosed() {
|
||||||
|
return $this->closed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function resetAttributes() {
|
||||||
|
$this->attributes = array();
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAttributes() {
|
||||||
|
return $this->attributes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addAttribute($attribute) {
|
||||||
|
$this->attributes[] = $attribute;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,10 +57,26 @@ input.typeahead-browse-input {
|
||||||
|
|
||||||
.typeahead-browse-item button {
|
.typeahead-browse-item button {
|
||||||
float: right;
|
float: right;
|
||||||
margin: 2px 6px;
|
margin: 8px 6px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.typeahead-browse-item a.jx-tokenizer-token {
|
.typeahead-browse-item a.jx-tokenizer-token {
|
||||||
margin-top: 1px;
|
margin-top: 1px;
|
||||||
margin-left: 6px;
|
margin-left: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.typeahead-browse-item .phabricator-main-search-typeahead-result {
|
||||||
|
margin: 2px 0;
|
||||||
|
padding: 0 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.typeahead-browse-item .phabricator-main-search-typeahead-result.has-image {
|
||||||
|
padding-left: 48px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.typeahead-browse-item
|
||||||
|
.phabricator-main-search-typeahead-result.result-closed
|
||||||
|
.result-name {
|
||||||
|
text-decoration: line-through;
|
||||||
|
color: {$lightgreytext};
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue