mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-20 12:30:56 +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:
parent
1de0ba58c1
commit
b611642a0f
3 changed files with 36 additions and 82 deletions
|
@ -28,55 +28,46 @@ final class HarbormasterBuildPlanQuery
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function loadPage() {
|
public function newResultObject() {
|
||||||
$table = new HarbormasterBuildPlan();
|
return 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
|
protected function loadPage() {
|
||||||
$where = array();
|
return $this->loadStandardPage($this->newResultObject());
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->ids) {
|
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
|
||||||
|
$where = parent::buildWhereClauseParts($conn);
|
||||||
|
|
||||||
|
if ($this->ids !== null) {
|
||||||
$where[] = qsprintf(
|
$where[] = qsprintf(
|
||||||
$conn_r,
|
$conn,
|
||||||
'id IN (%Ld)',
|
'id IN (%Ld)',
|
||||||
$this->ids);
|
$this->ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->phids) {
|
if ($this->phids !== null) {
|
||||||
$where[] = qsprintf(
|
$where[] = qsprintf(
|
||||||
$conn_r,
|
$conn,
|
||||||
'phid IN (%Ls)',
|
'phid IN (%Ls)',
|
||||||
$this->phids);
|
$this->phids);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->statuses) {
|
if ($this->statuses !== null) {
|
||||||
$where[] = qsprintf(
|
$where[] = qsprintf(
|
||||||
$conn_r,
|
$conn,
|
||||||
'planStatus IN (%Ls)',
|
'planStatus IN (%Ls)',
|
||||||
$this->statuses);
|
$this->statuses);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen($this->datasourceQuery)) {
|
if (strlen($this->datasourceQuery)) {
|
||||||
$where[] = qsprintf(
|
$where[] = qsprintf(
|
||||||
$conn_r,
|
$conn,
|
||||||
'name LIKE %>',
|
'name LIKE %>',
|
||||||
$this->datasourceQuery);
|
$this->datasourceQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
$where[] = $this->buildPagingClause($conn_r);
|
return $where;
|
||||||
|
|
||||||
return $this->formatWhereClause($where);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getQueryApplicationClass() {
|
public function getQueryApplicationClass() {
|
||||||
|
|
|
@ -11,57 +11,34 @@ final class HarbormasterBuildPlanSearchEngine
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
|
protected function buildCustomSearchFields() {
|
||||||
$query = id(new HarbormasterBuildPlanQuery());
|
return array(
|
||||||
$this->setQueryOrder($query, $saved);
|
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());
|
public function buildQueryFromParameters(array $map) {
|
||||||
if ($status) {
|
$query = $this->newQuery();
|
||||||
$query->withStatuses($status);
|
|
||||||
|
if ($map['status']) {
|
||||||
|
$query->withStatuses($map['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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -891,20 +891,6 @@ abstract class PhabricatorApplicationSearchEngine extends Phobject {
|
||||||
|
|
||||||
/* -( Result Ordering )---------------------------------------------------- */
|
/* -( 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.
|
* Set query ordering from a saved value.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue