@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+34 -80
+15 -24
src/applications/harbormaster/query/HarbormasterBuildPlanQuery.php
··· 28 28 return $this; 29 29 } 30 30 31 - protected function loadPage() { 32 - $table = new HarbormasterBuildPlan(); 33 - $conn_r = $table->establishConnection('r'); 34 - 35 - $data = queryfx_all( 36 - $conn_r, 37 - 'SELECT * FROM %T %Q %Q %Q', 38 - $table->getTableName(), 39 - $this->buildWhereClause($conn_r), 40 - $this->buildOrderClause($conn_r), 41 - $this->buildLimitClause($conn_r)); 31 + public function newResultObject() { 32 + return new HarbormasterBuildPlan(); 33 + } 42 34 43 - return $table->loadAllFromArray($data); 35 + protected function loadPage() { 36 + return $this->loadStandardPage($this->newResultObject()); 44 37 } 45 38 46 - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { 47 - $where = array(); 39 + protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { 40 + $where = parent::buildWhereClauseParts($conn); 48 41 49 - if ($this->ids) { 42 + if ($this->ids !== null) { 50 43 $where[] = qsprintf( 51 - $conn_r, 44 + $conn, 52 45 'id IN (%Ld)', 53 46 $this->ids); 54 47 } 55 48 56 - if ($this->phids) { 49 + if ($this->phids !== null) { 57 50 $where[] = qsprintf( 58 - $conn_r, 51 + $conn, 59 52 'phid IN (%Ls)', 60 53 $this->phids); 61 54 } 62 55 63 - if ($this->statuses) { 56 + if ($this->statuses !== null) { 64 57 $where[] = qsprintf( 65 - $conn_r, 58 + $conn, 66 59 'planStatus IN (%Ls)', 67 60 $this->statuses); 68 61 } 69 62 70 63 if (strlen($this->datasourceQuery)) { 71 64 $where[] = qsprintf( 72 - $conn_r, 65 + $conn, 73 66 'name LIKE %>', 74 67 $this->datasourceQuery); 75 68 } 76 69 77 - $where[] = $this->buildPagingClause($conn_r); 78 - 79 - return $this->formatWhereClause($where); 70 + return $where; 80 71 } 81 72 82 73 public function getQueryApplicationClass() {
+19 -42
src/applications/harbormaster/query/HarbormasterBuildPlanSearchEngine.php
··· 11 11 return 'PhabricatorHarbormasterApplication'; 12 12 } 13 13 14 - public function buildSavedQueryFromRequest(AphrontRequest $request) { 15 - $saved = new PhabricatorSavedQuery(); 14 + public function newQuery() { 15 + return new HarbormasterBuildPlanQuery(); 16 + } 16 17 17 - $saved->setParameter( 18 - 'status', 19 - $this->readListFromRequest($request, 'status')); 20 - 21 - $this->saveQueryOrder($saved, $request); 22 - 23 - return $saved; 18 + protected function buildCustomSearchFields() { 19 + return array( 20 + id(new PhabricatorSearchCheckboxesField()) 21 + ->setLabel(pht('Status')) 22 + ->setKey('status') 23 + ->setAliases(array('statuses')) 24 + ->setOptions( 25 + array( 26 + HarbormasterBuildPlan::STATUS_ACTIVE => pht('Active'), 27 + HarbormasterBuildPlan::STATUS_DISABLED => pht('Disabled'), 28 + )), 29 + ); 24 30 } 25 31 26 - public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) { 27 - $query = id(new HarbormasterBuildPlanQuery()); 28 - $this->setQueryOrder($query, $saved); 32 + public function buildQueryFromParameters(array $map) { 33 + $query = $this->newQuery(); 29 34 30 - $status = $saved->getParameter('status', array()); 31 - if ($status) { 32 - $query->withStatuses($status); 35 + if ($map['status']) { 36 + $query->withStatuses($map['status']); 33 37 } 34 38 35 39 return $query; 36 - } 37 - 38 - public function buildSearchForm( 39 - AphrontFormView $form, 40 - PhabricatorSavedQuery $saved) { 41 - 42 - $status = $saved->getParameter('status', array()); 43 - 44 - $form 45 - ->appendChild( 46 - id(new AphrontFormCheckboxControl()) 47 - ->setLabel('Status') 48 - ->addCheckbox( 49 - 'status[]', 50 - HarbormasterBuildPlan::STATUS_ACTIVE, 51 - pht('Active'), 52 - in_array(HarbormasterBuildPlan::STATUS_ACTIVE, $status)) 53 - ->addCheckbox( 54 - 'status[]', 55 - HarbormasterBuildPlan::STATUS_DISABLED, 56 - pht('Disabled'), 57 - in_array(HarbormasterBuildPlan::STATUS_DISABLED, $status))); 58 - 59 - $this->appendOrderFieldsToForm( 60 - $form, 61 - $saved, 62 - new HarbormasterBuildPlanQuery()); 63 40 } 64 41 65 42 protected function getURI($path) {
-14
src/applications/search/engine/PhabricatorApplicationSearchEngine.php
··· 891 891 892 892 /* -( Result Ordering )---------------------------------------------------- */ 893 893 894 - 895 - /** 896 - * Save order selection to a @{class:PhabricatorSavedQuery}. 897 - */ 898 - protected function saveQueryOrder( 899 - PhabricatorSavedQuery $saved, 900 - AphrontRequest $request) { 901 - 902 - $saved->setParameter('order', $request->getStr('order')); 903 - 904 - return $this; 905 - } 906 - 907 - 908 894 /** 909 895 * Set query ordering from a saved value. 910 896 */