Differential D13195 Diff 31935 src/applications/harbormaster/query/HarbormasterBuildPlanSearchEngine.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/harbormaster/query/HarbormasterBuildPlanSearchEngine.php
<?php | <?php | ||||
final class HarbormasterBuildPlanSearchEngine | final class HarbormasterBuildPlanSearchEngine | ||||
extends PhabricatorApplicationSearchEngine { | extends PhabricatorApplicationSearchEngine { | ||||
public function getResultTypeDescription() { | public function getResultTypeDescription() { | ||||
return pht('Harbormaster Build Plans'); | return pht('Harbormaster Build Plans'); | ||||
} | } | ||||
public function getApplicationClassName() { | public function getApplicationClassName() { | ||||
return 'PhabricatorHarbormasterApplication'; | return 'PhabricatorHarbormasterApplication'; | ||||
} | } | ||||
public function buildSavedQueryFromRequest(AphrontRequest $request) { | public function newQuery() { | ||||
$saved = new PhabricatorSavedQuery(); | return new HarbormasterBuildPlanQuery(); | ||||
} | |||||
$saved->setParameter( | |||||
'status', | |||||
$this->readListFromRequest($request, 'status')); | |||||
$this->saveQueryOrder($saved, $request); | |||||
return $saved; | protected function buildCustomSearchFields() { | ||||
return array( | |||||
id(new PhabricatorSearchCheckboxesField()) | |||||
->setLabel(pht('Status')) | |||||
->setKey('status') | |||||
->setAliases(array('statuses')) | |||||
->setOptions( | |||||
array( | |||||
HarbormasterBuildPlan::STATUS_ACTIVE => pht('Active'), | |||||
HarbormasterBuildPlan::STATUS_DISABLED => pht('Disabled'), | |||||
)), | |||||
); | |||||
} | } | ||||
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) { | public function buildQueryFromParameters(array $map) { | ||||
$query = id(new HarbormasterBuildPlanQuery()); | $query = $this->newQuery(); | ||||
$this->setQueryOrder($query, $saved); | |||||
$status = $saved->getParameter('status', array()); | if ($map['status']) { | ||||
if ($status) { | $query->withStatuses($map['status']); | ||||
$query->withStatuses($status); | |||||
} | } | ||||
return $query; | return $query; | ||||
} | } | ||||
public function buildSearchForm( | |||||
AphrontFormView $form, | |||||
PhabricatorSavedQuery $saved) { | |||||
$status = $saved->getParameter('status', array()); | |||||
$form | |||||
->appendChild( | |||||
id(new AphrontFormCheckboxControl()) | |||||
->setLabel('Status') | |||||
->addCheckbox( | |||||
'status[]', | |||||
HarbormasterBuildPlan::STATUS_ACTIVE, | |||||
pht('Active'), | |||||
in_array(HarbormasterBuildPlan::STATUS_ACTIVE, $status)) | |||||
->addCheckbox( | |||||
'status[]', | |||||
HarbormasterBuildPlan::STATUS_DISABLED, | |||||
pht('Disabled'), | |||||
in_array(HarbormasterBuildPlan::STATUS_DISABLED, $status))); | |||||
$this->appendOrderFieldsToForm( | |||||
$form, | |||||
$saved, | |||||
new HarbormasterBuildPlanQuery()); | |||||
} | |||||
protected function getURI($path) { | protected function getURI($path) { | ||||
return '/harbormaster/plan/'.$path; | return '/harbormaster/plan/'.$path; | ||||
} | } | ||||
protected function getBuiltinQueryNames() { | protected function getBuiltinQueryNames() { | ||||
return array( | return array( | ||||
'active' => pht('Active Plans'), | 'active' => pht('Active Plans'), | ||||
'all' => pht('All Plans'), | 'all' => pht('All Plans'), | ||||
▲ Show 20 Lines • Show All 50 Lines • Show Last 20 Lines |