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

Turn the macro selector into a tokenizer

Summary: Ref T3562. Here's the 10 minute "value" option.

Test Plan: See screenshots.

Reviewers: chad, btrahan

Reviewed By: chad

CC: aran

Maniphest Tasks: T3562

Differential Revision: https://secure.phabricator.com/D7658
This commit is contained in:
epriestley 2013-11-25 19:22:06 -08:00
parent 325c8853c9
commit 6985c71117
3 changed files with 26 additions and 6 deletions

View file

@ -7,20 +7,20 @@ final class PhabricatorMacroMemeDialogController
$request = $this->getRequest();
$user = $request->getUser();
$name = $request->getStr('macro');
$phid = head($request->getArr('macro'));
$above = $request->getStr('above');
$below = $request->getStr('below');
$e_macro = true;
$errors = array();
if ($request->isDialogFormPost()) {
if (!$name) {
if (!$phid) {
$e_macro = pht('Required');
$errors[] = pht('Macro name is required.');
} else {
$macro = id(new PhabricatorMacroQuery())
->setViewer($user)
->withNames(array($name))
->withPHIDs(array($phid))
->executeOne();
if (!$macro) {
$e_macro = pht('Invalid');
@ -31,7 +31,7 @@ final class PhabricatorMacroMemeDialogController
if (!$errors) {
$options = new PhutilSimpleOptions();
$data = array(
'src' => $name,
'src' => $macro->getName(),
'above' => $above,
'below' => $below,
);
@ -46,10 +46,11 @@ final class PhabricatorMacroMemeDialogController
$view = id(new PHUIFormLayoutView())
->appendChild(
id(new AphrontFormTextControl())
id(new AphrontFormTokenizerControl())
->setLabel(pht('Macro'))
->setName('macro')
->setValue($name)
->setLimit(1)
->setDatasource('/typeahead/common/macros/')
->setError($e_macro))
->appendChild(
id(new AphrontFormTextControl())

View file

@ -36,6 +36,7 @@ final class PhabricatorTypeaheadCommonDatasourceController
$need_symbols = false;
$need_jump_objects = false;
$need_build_plans = false;
$need_macros = false;
switch ($this->type) {
case 'mainsearch':
$need_users = true;
@ -97,6 +98,9 @@ final class PhabricatorTypeaheadCommonDatasourceController
case 'buildplans':
$need_build_plans = true;
break;
case 'macros':
$need_macros = true;
break;
}
$results = array();
@ -113,6 +117,7 @@ final class PhabricatorTypeaheadCommonDatasourceController
->setPHID(ManiphestTaskOwner::PROJECT_NO_PROJECT);
}
if ($need_users) {
$columns = array(
'isSystemAgent',
@ -234,6 +239,19 @@ final class PhabricatorTypeaheadCommonDatasourceController
}
}
if ($need_macros) {
$macros = id(new PhabricatorMacroQuery())
->setViewer($viewer)
->withStatus(PhabricatorMacroQuery::STATUS_ACTIVE)
->execute();
$macros = mpull($macros, 'getName', 'getPHID');
foreach ($macros as $phid => $name) {
$results[] = id(new PhabricatorTypeaheadResult())
->setPHID($phid)
->setName($name);
}
}
if ($need_projs) {
$projs = id(new PhabricatorProjectQuery())
->setViewer($viewer)

View file

@ -97,6 +97,7 @@ final class AphrontFormTokenizerControl extends AphrontFormControl {
'packages' => pht('Type a package name...'),
'arcanistproject' => pht('Type an arc project name...'),
'accountsorprojects' => pht('Type a user or project name...'),
'macros' => pht('Type a macro name...'),
);
return idx($map, $request);