mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-06 11:58:30 +01:00
Move Slowvote rendering into SearchEngine
Summary: Ref T4986. This adds a bit of structure for handles, since we used to have Controller utilities but no longer do. Hopefully these will start going faster soon... Test Plan: - Checked feed for collateral damage. - Checked slowvote for collateral damage. - Made a slowvote panel. {F151550} Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T4986 Differential Revision: https://secure.phabricator.com/D9010
This commit is contained in:
parent
dadd9a9dd9
commit
8f42f4b538
5 changed files with 79 additions and 54 deletions
|
@ -5066,11 +5066,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorSlowvoteDAO' => 'PhabricatorLiskDAO',
|
'PhabricatorSlowvoteDAO' => 'PhabricatorLiskDAO',
|
||||||
'PhabricatorSlowvoteEditController' => 'PhabricatorSlowvoteController',
|
'PhabricatorSlowvoteEditController' => 'PhabricatorSlowvoteController',
|
||||||
'PhabricatorSlowvoteEditor' => 'PhabricatorApplicationTransactionEditor',
|
'PhabricatorSlowvoteEditor' => 'PhabricatorApplicationTransactionEditor',
|
||||||
'PhabricatorSlowvoteListController' =>
|
'PhabricatorSlowvoteListController' => 'PhabricatorSlowvoteController',
|
||||||
array(
|
|
||||||
0 => 'PhabricatorSlowvoteController',
|
|
||||||
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
|
|
||||||
),
|
|
||||||
'PhabricatorSlowvoteOption' => 'PhabricatorSlowvoteDAO',
|
'PhabricatorSlowvoteOption' => 'PhabricatorSlowvoteDAO',
|
||||||
'PhabricatorSlowvotePHIDTypePoll' => 'PhabricatorPHIDType',
|
'PhabricatorSlowvotePHIDTypePoll' => 'PhabricatorPHIDType',
|
||||||
'PhabricatorSlowvotePoll' =>
|
'PhabricatorSlowvotePoll' =>
|
||||||
|
|
|
@ -124,9 +124,10 @@ final class PhabricatorFeedSearchEngine
|
||||||
return parent::buildSavedQueryFromBuiltin($query_key);
|
return parent::buildSavedQueryFromBuiltin($query_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function renderResults(
|
public function renderResultList(
|
||||||
array $objects,
|
array $objects,
|
||||||
PhabricatorSavedQuery $query) {
|
PhabricatorSavedQuery $query,
|
||||||
|
array $handles) {
|
||||||
|
|
||||||
$builder = new PhabricatorFeedBuilder($objects);
|
$builder = new PhabricatorFeedBuilder($objects);
|
||||||
$builder->setShowHovercards(true);
|
$builder->setShowHovercards(true);
|
||||||
|
|
|
@ -561,6 +561,31 @@ abstract class PhabricatorApplicationSearchEngine {
|
||||||
public function renderResults(
|
public function renderResults(
|
||||||
array $objects,
|
array $objects,
|
||||||
PhabricatorSavedQuery $query) {
|
PhabricatorSavedQuery $query) {
|
||||||
|
|
||||||
|
$phids = $this->getRequiredHandlePHIDsForResultList($objects, $query);
|
||||||
|
|
||||||
|
if ($phids) {
|
||||||
|
$handles = id(new PhabricatorHandleQuery())
|
||||||
|
->setViewer($this->requireViewer())
|
||||||
|
->witHPHIDs($phids)
|
||||||
|
->execute();
|
||||||
|
} else {
|
||||||
|
$handles = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->renderResultList($objects, $query, $handles);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRequiredHandlePHIDsForResultList(
|
||||||
|
array $objects,
|
||||||
|
PhabricatorSavedQuery $query) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function renderResultList(
|
||||||
|
array $objects,
|
||||||
|
PhabricatorSavedQuery $query,
|
||||||
|
array $handles) {
|
||||||
throw new Exception(pht('Not supported here yet!'));
|
throw new Exception(pht('Not supported here yet!'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
|
||||||
* @group slowvote
|
|
||||||
*/
|
|
||||||
final class PhabricatorSlowvoteListController
|
final class PhabricatorSlowvoteListController
|
||||||
extends PhabricatorSlowvoteController
|
extends PhabricatorSlowvoteController {
|
||||||
implements PhabricatorApplicationSearchResultsControllerInterface {
|
|
||||||
|
|
||||||
private $queryKey;
|
private $queryKey;
|
||||||
|
|
||||||
|
@ -27,46 +23,4 @@ final class PhabricatorSlowvoteListController
|
||||||
return $this->delegateToController($controller);
|
return $this->delegateToController($controller);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function renderResultsList(
|
|
||||||
array $polls,
|
|
||||||
PhabricatorSavedQuery $query) {
|
|
||||||
assert_instances_of($polls, 'PhabricatorSlowvotePoll');
|
|
||||||
$viewer = $this->getRequest()->getUser();
|
|
||||||
|
|
||||||
$list = id(new PHUIObjectItemListView())
|
|
||||||
->setUser($viewer);
|
|
||||||
|
|
||||||
$phids = mpull($polls, 'getAuthorPHID');
|
|
||||||
$handles = $this->loadViewerHandles($phids);
|
|
||||||
|
|
||||||
foreach ($polls as $poll) {
|
|
||||||
$date_created = phabricator_datetime($poll->getDateCreated(), $viewer);
|
|
||||||
if ($poll->getAuthorPHID()) {
|
|
||||||
$author = $handles[$poll->getAuthorPHID()]->renderLink();
|
|
||||||
} else {
|
|
||||||
$author = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$item = id(new PHUIObjectItemView())
|
|
||||||
->setObjectName('V'.$poll->getID())
|
|
||||||
->setHeader($poll->getQuestion())
|
|
||||||
->setHref('/V'.$poll->getID())
|
|
||||||
->setDisabled($poll->getIsClosed())
|
|
||||||
->addIcon('none', $date_created);
|
|
||||||
|
|
||||||
$description = $poll->getDescription();
|
|
||||||
if (strlen($description)) {
|
|
||||||
$item->addAttribute(phutil_utf8_shorten($poll->getDescription(), 120));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($author) {
|
|
||||||
$item->addByline(pht('Author: %s', $author));
|
|
||||||
}
|
|
||||||
|
|
||||||
$list->addItem($item);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $list;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,4 +115,53 @@ final class PhabricatorSlowvoteSearchEngine
|
||||||
return parent::buildSavedQueryFromBuiltin($query_key);
|
return parent::buildSavedQueryFromBuiltin($query_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getRequiredHandlePHIDsForResultList(
|
||||||
|
array $polls,
|
||||||
|
PhabricatorSavedQuery $query) {
|
||||||
|
return mpull($polls, 'getAuthorPHID');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function renderResultList(
|
||||||
|
array $polls,
|
||||||
|
PhabricatorSavedQuery $query,
|
||||||
|
array $handles) {
|
||||||
|
|
||||||
|
assert_instances_of($polls, 'PhabricatorSlowvotePoll');
|
||||||
|
$viewer = $this->requireViewer();
|
||||||
|
|
||||||
|
$list = id(new PHUIObjectItemListView())
|
||||||
|
->setUser($viewer);
|
||||||
|
|
||||||
|
$phids = mpull($polls, 'getAuthorPHID');
|
||||||
|
|
||||||
|
foreach ($polls as $poll) {
|
||||||
|
$date_created = phabricator_datetime($poll->getDateCreated(), $viewer);
|
||||||
|
if ($poll->getAuthorPHID()) {
|
||||||
|
$author = $handles[$poll->getAuthorPHID()]->renderLink();
|
||||||
|
} else {
|
||||||
|
$author = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$item = id(new PHUIObjectItemView())
|
||||||
|
->setObjectName('V'.$poll->getID())
|
||||||
|
->setHeader($poll->getQuestion())
|
||||||
|
->setHref('/V'.$poll->getID())
|
||||||
|
->setDisabled($poll->getIsClosed())
|
||||||
|
->addIcon('none', $date_created);
|
||||||
|
|
||||||
|
$description = $poll->getDescription();
|
||||||
|
if (strlen($description)) {
|
||||||
|
$item->addAttribute(phutil_utf8_shorten($poll->getDescription(), 120));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($author) {
|
||||||
|
$item->addByline(pht('Author: %s', $author));
|
||||||
|
}
|
||||||
|
|
||||||
|
$list->addItem($item);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $list;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue