mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 12:00:55 +01:00
Move Countdown rendering to SearchEngine
Summary: Ref T4986. Test Plan: Viewed app, made a panel. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T4986 Differential Revision: https://secure.phabricator.com/D9014
This commit is contained in:
parent
9d1cfcd8ec
commit
46405064e9
2 changed files with 51 additions and 43 deletions
|
@ -1,8 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class PhabricatorCountdownListController
|
final class PhabricatorCountdownListController
|
||||||
extends PhabricatorCountdownController
|
extends PhabricatorCountdownController {
|
||||||
implements PhabricatorApplicationSearchResultsControllerInterface {
|
|
||||||
|
|
||||||
private $queryKey;
|
private $queryKey;
|
||||||
|
|
||||||
|
@ -24,46 +23,5 @@ final class PhabricatorCountdownListController
|
||||||
return $this->delegateToController($controller);
|
return $this->delegateToController($controller);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function renderResultsList(
|
|
||||||
array $countdowns,
|
|
||||||
PhabricatorSavedQuery $query) {
|
|
||||||
assert_instances_of($countdowns, 'PhabricatorCountdown');
|
|
||||||
|
|
||||||
$viewer = $this->getRequest()->getUser();
|
|
||||||
|
|
||||||
$this->loadHandles(mpull($countdowns, 'getAuthorPHID'));
|
|
||||||
|
|
||||||
|
|
||||||
$list = new PHUIObjectItemListView();
|
|
||||||
$list->setUser($viewer);
|
|
||||||
foreach ($countdowns as $countdown) {
|
|
||||||
$id = $countdown->getID();
|
|
||||||
|
|
||||||
$item = id(new PHUIObjectItemView())
|
|
||||||
->setObjectName("C{$id}")
|
|
||||||
->setHeader($countdown->getTitle())
|
|
||||||
->setHref($this->getApplicationURI("{$id}/"))
|
|
||||||
->addByline(
|
|
||||||
pht(
|
|
||||||
'Created by %s',
|
|
||||||
$this->getHandle($countdown->getAuthorPHID())->renderLink()));
|
|
||||||
|
|
||||||
$epoch = $countdown->getEpoch();
|
|
||||||
if ($epoch >= time()) {
|
|
||||||
$item->addIcon(
|
|
||||||
'none',
|
|
||||||
pht('Ends %s', phabricator_datetime($epoch, $viewer)));
|
|
||||||
} else {
|
|
||||||
$item->addIcon(
|
|
||||||
'delete',
|
|
||||||
pht('Ended %s', phabricator_datetime($epoch, $viewer)));
|
|
||||||
$item->setDisabled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
$list->addItem($item);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $list;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,10 @@
|
||||||
final class PhabricatorCountdownSearchEngine
|
final class PhabricatorCountdownSearchEngine
|
||||||
extends PhabricatorApplicationSearchEngine {
|
extends PhabricatorApplicationSearchEngine {
|
||||||
|
|
||||||
|
public function getApplicationClassName() {
|
||||||
|
return 'PhabricatorApplicationCountdown';
|
||||||
|
}
|
||||||
|
|
||||||
public function buildSavedQueryFromRequest(AphrontRequest $request) {
|
public function buildSavedQueryFromRequest(AphrontRequest $request) {
|
||||||
$saved = new PhabricatorSavedQuery();
|
$saved = new PhabricatorSavedQuery();
|
||||||
$saved->setParameter(
|
$saved->setParameter(
|
||||||
|
@ -93,4 +97,50 @@ final class PhabricatorCountdownSearchEngine
|
||||||
return parent::buildSavedQueryFromBuiltin($query_key);
|
return parent::buildSavedQueryFromBuiltin($query_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected function getRequiredHandlePHIDsForResultList(
|
||||||
|
array $countdowns,
|
||||||
|
PhabricatorSavedQuery $query) {
|
||||||
|
return mpull($countdowns, 'getAuthorPHID');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function renderResultList(
|
||||||
|
array $countdowns,
|
||||||
|
PhabricatorSavedQuery $query,
|
||||||
|
array $handles) {
|
||||||
|
assert_instances_of($countdowns, 'PhabricatorCountdown');
|
||||||
|
|
||||||
|
$viewer = $this->requireViewer();
|
||||||
|
|
||||||
|
$list = new PHUIObjectItemListView();
|
||||||
|
$list->setUser($viewer);
|
||||||
|
foreach ($countdowns as $countdown) {
|
||||||
|
$id = $countdown->getID();
|
||||||
|
|
||||||
|
$item = id(new PHUIObjectItemView())
|
||||||
|
->setObjectName("C{$id}")
|
||||||
|
->setHeader($countdown->getTitle())
|
||||||
|
->setHref($this->getApplicationURI("{$id}/"))
|
||||||
|
->addByline(
|
||||||
|
pht(
|
||||||
|
'Created by %s',
|
||||||
|
$handles[$countdown->getAuthorPHID()]->renderLink()));
|
||||||
|
|
||||||
|
$epoch = $countdown->getEpoch();
|
||||||
|
if ($epoch >= time()) {
|
||||||
|
$item->addIcon(
|
||||||
|
'none',
|
||||||
|
pht('Ends %s', phabricator_datetime($epoch, $viewer)));
|
||||||
|
} else {
|
||||||
|
$item->addIcon(
|
||||||
|
'delete',
|
||||||
|
pht('Ended %s', phabricator_datetime($epoch, $viewer)));
|
||||||
|
$item->setDisabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
$list->addItem($item);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $list;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue