1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 05:50:55 +01:00

Reduce responsibilities of PhabricatorPasteSearchEngine->buildSearchForm()

Summary:
Ref T2625. The specialized buildSearchForm() method has significant amounts of generic form construction responsibility right now. Lift the generic stuff above the Engine level. Also:

  - Rename "users" to "authors".
  - Use "users", not "searchowners" (which incorrectly includes "upforgrabs").
  - No need for "set_" prefixes anymore since we do GET redirects with query keys.
  - Use newer style for search stuff.

Test Plan:
Searched for stuff?

{F44342}

Reviewers: btrahan, blc

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2625

Differential Revision: https://secure.phabricator.com/D6061
This commit is contained in:
epriestley 2013-05-27 13:43:47 -07:00
parent a67b1f950c
commit 764e4574d1
3 changed files with 33 additions and 26 deletions

View file

@ -58,14 +58,28 @@ final class PhabricatorPasteListController extends PhabricatorPasteController {
$list->setNoDataString(pht("No results found for this query."));
if ($this->queryKey !== null || $filter == "filter/advanced") {
$form = $engine->buildSearchForm($saved_query);
$nav->appendChild($form);
$form = id(new AphrontFormView())
->setNoShading(true)
->setUser($user);
$engine->buildSearchForm($form, $saved_query);
$submit = id(new AphrontFormSubmitControl())
->setValue(pht('Execute Query'));
if ($filter == 'filter/advanced') {
$submit->addCancelButton(
'/search/edit/'.$saved_query->getQueryKey().'/',
pht('Save Custom Query...'));
}
$form->appendChild($submit);
$filter_view = id(new AphrontListFilterView())->appendChild($form);
$nav->appendChild($filter_view);
}
$nav->appendChild(
array(
$list,
));
$nav->appendChild($list);
$crumbs = $this
->buildApplicationCrumbs($nav)

View file

@ -18,7 +18,7 @@ final class PhabricatorPasteSearchEngine
$saved = new PhabricatorSavedQuery();
$saved->setParameter(
'authorPHIDs',
array_values($request->getArr('set_users')));
array_values($request->getArr('authors')));
try {
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
@ -53,31 +53,21 @@ final class PhabricatorPasteSearchEngine
* @param PhabricatorSavedQuery The query to populate the form with.
* @return AphrontFormView The built form.
*/
public function buildSearchForm(PhabricatorSavedQuery $saved_query) {
public function buildSearchForm(
AphrontFormView $form,
PhabricatorSavedQuery $saved_query) {
$phids = $saved_query->getParameter('authorPHIDs', array());
$handles = id(new PhabricatorObjectHandleData($phids))
->setViewer($this->requireViewer())
->loadHandles();
$users_searched = mpull($handles, 'getFullName', 'getPHID');
$form = id(new AphrontFormView())
->setUser($this->requireViewer());
$author_tokens = mpull($handles, 'getFullName', 'getPHID');
$form->appendChild(
id(new AphrontFormTokenizerControl())
->setDatasource('/typeahead/common/searchowner/')
->setName('set_users')
->setLabel(pht('Users'))
->setValue($users_searched));
$form->appendChild(
id(new AphrontFormSubmitControl())
->setValue(pht('Query'))
->addCancelButton(
'/search/edit/'.$saved_query->getQueryKey().'/',
pht('Save Custom Query...')));
return $form;
->setDatasource('/typeahead/common/users/')
->setName('authors')
->setLabel(pht('Authors'))
->setValue($author_tokens));
}
public function getQueryResultsPageURI($query_key) {

View file

@ -46,10 +46,13 @@ abstract class PhabricatorApplicationSearchEngine {
/**
* Builds the search form using the request.
*
* @param AphrontFormView Form to populate.
* @param PhabricatorSavedQuery The query from which to build the form.
* @return void
*/
abstract public function buildSearchForm(PhabricatorSavedQuery $query);
abstract public function buildSearchForm(
AphrontFormView $form,
PhabricatorSavedQuery $query);
/**