Page MenuHomePhabricator

D12435.id29880.diff
No OneTemporary

D12435.id29880.diff

diff --git a/src/applications/harbormaster/query/HarbormasterBuildPlanQuery.php b/src/applications/harbormaster/query/HarbormasterBuildPlanQuery.php
--- a/src/applications/harbormaster/query/HarbormasterBuildPlanQuery.php
+++ b/src/applications/harbormaster/query/HarbormasterBuildPlanQuery.php
@@ -6,6 +6,7 @@
private $ids;
private $phids;
private $statuses;
+ private $datasourceQuery;
public function withIDs(array $ids) {
$this->ids = $ids;
@@ -22,6 +23,11 @@
return $this;
}
+ public function withDatasourceQuery($query) {
+ $this->datasourceQuery = $query;
+ return $this;
+ }
+
protected function loadPage() {
$table = new HarbormasterBuildPlan();
$conn_r = $table->establishConnection('r');
@@ -61,6 +67,13 @@
$this->statuses);
}
+ if (strlen($this->datasourceQuery)) {
+ $where[] = qsprintf(
+ $conn_r,
+ 'name LIKE %>',
+ $this->datasourceQuery);
+ }
+
$where[] = $this->buildPagingClause($conn_r);
return $this->formatWhereClause($where);
@@ -70,4 +83,31 @@
return 'PhabricatorHarbormasterApplication';
}
+ public function getOrderableColumns() {
+ return parent::getOrderableColumns() + array(
+ 'name' => array(
+ 'column' => 'name',
+ 'type' => 'string',
+ 'reverse' => true,
+ ),
+ );
+ }
+
+ public function getPagingValueMap($cursor, array $keys) {
+ $plan = $this->loadCursorObject($cursor);
+ return array(
+ 'id' => $plan->getID(),
+ 'name' => $plan->getName(),
+ );
+ }
+
+ public function getBuiltinOrders() {
+ return array(
+ 'name' => array(
+ 'vector' => array('name', 'id'),
+ 'name' => pht('Name'),
+ ),
+ ) + parent::getBuiltinOrders();
+ }
+
}
diff --git a/src/applications/harbormaster/query/HarbormasterBuildPlanSearchEngine.php b/src/applications/harbormaster/query/HarbormasterBuildPlanSearchEngine.php
--- a/src/applications/harbormaster/query/HarbormasterBuildPlanSearchEngine.php
+++ b/src/applications/harbormaster/query/HarbormasterBuildPlanSearchEngine.php
@@ -18,11 +18,14 @@
'status',
$this->readListFromRequest($request, 'status'));
+ $this->saveQueryOrder($saved, $request);
+
return $saved;
}
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
$query = id(new HarbormasterBuildPlanQuery());
+ $this->setQueryOrder($query, $saved);
$status = $saved->getParameter('status', array());
if ($status) {
@@ -34,9 +37,9 @@
public function buildSearchForm(
AphrontFormView $form,
- PhabricatorSavedQuery $saved_query) {
+ PhabricatorSavedQuery $saved) {
- $status = $saved_query->getParameter('status', array());
+ $status = $saved->getParameter('status', array());
$form
->appendChild(
@@ -52,6 +55,11 @@
HarbormasterBuildPlan::STATUS_DISABLED,
pht('Disabled'),
in_array(HarbormasterBuildPlan::STATUS_DISABLED, $status)));
+
+ $this->appendOrderFieldsToForm(
+ $form,
+ $saved,
+ new HarbormasterBuildPlanQuery());
}
protected function getURI($path) {
diff --git a/src/applications/harbormaster/storage/configuration/HarbormasterBuildPlan.php b/src/applications/harbormaster/storage/configuration/HarbormasterBuildPlan.php
--- a/src/applications/harbormaster/storage/configuration/HarbormasterBuildPlan.php
+++ b/src/applications/harbormaster/storage/configuration/HarbormasterBuildPlan.php
@@ -23,13 +23,16 @@
return array(
self::CONFIG_AUX_PHID => true,
self::CONFIG_COLUMN_SCHEMA => array(
- 'name' => 'text255',
+ 'name' => 'sort128',
'planStatus' => 'text32',
),
self::CONFIG_KEY_SCHEMA => array(
'key_status' => array(
'columns' => array('planStatus'),
),
+ 'key_name' => array(
+ 'columns' => array('name'),
+ ),
),
) + parent::getConfiguration();
}
diff --git a/src/applications/harbormaster/typeahead/HarbormasterBuildPlanDatasource.php b/src/applications/harbormaster/typeahead/HarbormasterBuildPlanDatasource.php
--- a/src/applications/harbormaster/typeahead/HarbormasterBuildPlanDatasource.php
+++ b/src/applications/harbormaster/typeahead/HarbormasterBuildPlanDatasource.php
@@ -17,9 +17,11 @@
$results = array();
- $plans = id(new HarbormasterBuildPlanQuery())
- ->setViewer($viewer)
- ->execute();
+ $query = id(new HarbormasterBuildPlanQuery())
+ ->setOrder('name')
+ ->withDatasourceQuery($raw_query);
+
+ $plans = $this->executeQuery($query);
foreach ($plans as $plan) {
$closed = null;
if ($plan->isDisabled()) {

File Metadata

Mime Type
text/plain
Expires
Sun, Dec 22, 12:08 AM (21 h, 19 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6916651
Default Alt Text
D12435.id29880.diff (4 KB)

Event Timeline