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

Convert Harbormaster Build Plans to SearchField

Summary: Ref T8441. Ref T7715. Removes `saveQueryOrder()`.

Test Plan: Used all search features for build plans.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T7715, T8441

Differential Revision: https://secure.phabricator.com/D13195
This commit is contained in:
epriestley 2015-06-08 12:22:28 -07:00
parent 1de0ba58c1
commit b611642a0f
3 changed files with 36 additions and 82 deletions

View file

@ -28,55 +28,46 @@ final class HarbormasterBuildPlanQuery
return $this;
}
protected function loadPage() {
$table = new HarbormasterBuildPlan();
$conn_r = $table->establishConnection('r');
$data = queryfx_all(
$conn_r,
'SELECT * FROM %T %Q %Q %Q',
$table->getTableName(),
$this->buildWhereClause($conn_r),
$this->buildOrderClause($conn_r),
$this->buildLimitClause($conn_r));
return $table->loadAllFromArray($data);
public function newResultObject() {
return new HarbormasterBuildPlan();
}
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
$where = array();
protected function loadPage() {
return $this->loadStandardPage($this->newResultObject());
}
if ($this->ids) {
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
$where = parent::buildWhereClauseParts($conn);
if ($this->ids !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'id IN (%Ld)',
$this->ids);
}
if ($this->phids) {
if ($this->phids !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'phid IN (%Ls)',
$this->phids);
}
if ($this->statuses) {
if ($this->statuses !== null) {
$where[] = qsprintf(
$conn_r,
$conn,
'planStatus IN (%Ls)',
$this->statuses);
}
if (strlen($this->datasourceQuery)) {
$where[] = qsprintf(
$conn_r,
$conn,
'name LIKE %>',
$this->datasourceQuery);
}
$where[] = $this->buildPagingClause($conn_r);
return $this->formatWhereClause($where);
return $where;
}
public function getQueryApplicationClass() {

View file

@ -11,57 +11,34 @@ final class HarbormasterBuildPlanSearchEngine
return 'PhabricatorHarbormasterApplication';
}
public function buildSavedQueryFromRequest(AphrontRequest $request) {
$saved = new PhabricatorSavedQuery();
$saved->setParameter(
'status',
$this->readListFromRequest($request, 'status'));
$this->saveQueryOrder($saved, $request);
return $saved;
public function newQuery() {
return new HarbormasterBuildPlanQuery();
}
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
$query = id(new HarbormasterBuildPlanQuery());
$this->setQueryOrder($query, $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'),
)),
);
}
$status = $saved->getParameter('status', array());
if ($status) {
$query->withStatuses($status);
public function buildQueryFromParameters(array $map) {
$query = $this->newQuery();
if ($map['status']) {
$query->withStatuses($map['status']);
}
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) {
return '/harbormaster/plan/'.$path;
}

View file

@ -891,20 +891,6 @@ abstract class PhabricatorApplicationSearchEngine extends Phobject {
/* -( Result Ordering )---------------------------------------------------- */
/**
* Save order selection to a @{class:PhabricatorSavedQuery}.
*/
protected function saveQueryOrder(
PhabricatorSavedQuery $saved,
AphrontRequest $request) {
$saved->setParameter('order', $request->getStr('order'));
return $this;
}
/**
* Set query ordering from a saved value.
*/