1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-24 14:30:56 +01:00

Add a Phurl Typeahead

Summary: Adds a basic typeahead for Phurl Objects.

Test Plan: http://local.phacility.com/typeahead/browse/PhabricatorPhurlURLDatasource/

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D17339
This commit is contained in:
Chad Little 2017-02-11 15:30:56 -08:00
parent 29dc9e9ae1
commit 8b2880cfb7
2 changed files with 37 additions and 0 deletions

View file

@ -3371,6 +3371,7 @@ phutil_register_library_map(array(
'PhabricatorPhurlURLAccessController' => 'applications/phurl/controller/PhabricatorPhurlURLAccessController.php',
'PhabricatorPhurlURLCommentController' => 'applications/phurl/controller/PhabricatorPhurlURLCommentController.php',
'PhabricatorPhurlURLCreateCapability' => 'applications/phurl/capability/PhabricatorPhurlURLCreateCapability.php',
'PhabricatorPhurlURLDatasource' => 'applications/phurl/typeahead/PhabricatorPhurlURLDatasource.php',
'PhabricatorPhurlURLEditConduitAPIMethod' => 'applications/phurl/conduit/PhabricatorPhurlURLEditConduitAPIMethod.php',
'PhabricatorPhurlURLEditController' => 'applications/phurl/controller/PhabricatorPhurlURLEditController.php',
'PhabricatorPhurlURLEditEngine' => 'applications/phurl/editor/PhabricatorPhurlURLEditEngine.php',
@ -8521,6 +8522,7 @@ phutil_register_library_map(array(
'PhabricatorPhurlURLAccessController' => 'PhabricatorPhurlController',
'PhabricatorPhurlURLCommentController' => 'PhabricatorPhurlController',
'PhabricatorPhurlURLCreateCapability' => 'PhabricatorPolicyCapability',
'PhabricatorPhurlURLDatasource' => 'PhabricatorTypeaheadDatasource',
'PhabricatorPhurlURLEditConduitAPIMethod' => 'PhabricatorEditEngineAPIMethod',
'PhabricatorPhurlURLEditController' => 'PhabricatorPhurlController',
'PhabricatorPhurlURLEditEngine' => 'PhabricatorEditEngine',

View file

@ -0,0 +1,35 @@
<?php
final class PhabricatorPhurlURLDatasource
extends PhabricatorTypeaheadDatasource {
public function getBrowseTitle() {
return pht('Browse Phurl URLs');
}
public function getPlaceholderText() {
return pht('Select a phurl...');
}
public function getDatasourceApplicationClass() {
return 'PhabricatorPhurlApplication';
}
public function loadResults() {
$query = id(new PhabricatorPhurlURLQuery());
$urls = $this->executeQuery($query);
$results = array();
foreach ($urls as $url) {
$result = id(new PhabricatorTypeaheadResult())
->setDisplayName($url->getName())
->setName($url->getName()." ".$url->getAlias())
->setPHID($url->getPHID())
->addAttribute($url->getLongURL());
$results[] = $result;
}
return $this->filterResultsAgainstTokens($results);
}
}