mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-27 01:02:42 +01:00
Use responsive UI elements in Ponder list views
Summary: Use the new `PhabricatorObjectItemListView` in Ponder so it works with the new UI. It will also get some features like flags "for free" in the future. This removes the pager; I'll restore it in the next diff. Test Plan: Looked at feed. Reviewers: pieter, starruler Reviewed By: pieter CC: aran, chad Maniphest Tasks: T1644 Differential Revision: https://secure.phabricator.com/D3507
This commit is contained in:
parent
6b1c27eb0e
commit
9f09144117
4 changed files with 75 additions and 22 deletions
|
@ -32,4 +32,24 @@ abstract class PonderController extends PhabricatorController {
|
||||||
return $response->setContent($page->render());
|
return $response->setContent($page->render());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function buildSideNavView(PonderQuestion $question = null) {
|
||||||
|
$side_nav = new AphrontSideNavFilterView();
|
||||||
|
$side_nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
|
||||||
|
|
||||||
|
$side_nav->addLabel('Create');
|
||||||
|
$side_nav->addFilter('question/ask', 'Ask a Question');
|
||||||
|
|
||||||
|
$side_nav->addSpacer();
|
||||||
|
|
||||||
|
$side_nav->addLabel('Questions');
|
||||||
|
$side_nav->addFilter('feed', 'All Questions');
|
||||||
|
|
||||||
|
$side_nav->addSpacer();
|
||||||
|
|
||||||
|
$side_nav->addLabel('Profile');
|
||||||
|
$side_nav->addFilter('profile', 'User Profile');
|
||||||
|
|
||||||
|
return $side_nav;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,40 +39,29 @@ final class PonderFeedController extends PonderController {
|
||||||
$this->answerOffset = $request->getInt('aoff');
|
$this->answerOffset = $request->getInt('aoff');
|
||||||
|
|
||||||
$pages = array(
|
$pages = array(
|
||||||
'feed' => 'Popular Questions',
|
'feed' => 'All Questions',
|
||||||
'profile' => 'User Profile',
|
'profile' => 'User Profile',
|
||||||
);
|
);
|
||||||
|
|
||||||
$side_nav = new AphrontSideNavFilterView();
|
$side_nav = $this->buildSideNavView();
|
||||||
$side_nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
|
|
||||||
foreach ($pages as $name => $title) {
|
|
||||||
$side_nav->addFilter($name, $title);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->page = $side_nav->selectFilter($this->page, 'feed');
|
$this->page = $side_nav->selectFilter($this->page, 'feed');
|
||||||
|
|
||||||
|
$title = $pages[$this->page];
|
||||||
|
|
||||||
switch ($this->page) {
|
switch ($this->page) {
|
||||||
case 'feed':
|
case 'feed':
|
||||||
$data = PonderQuestionQuery::loadHottest(
|
$questions = PonderQuestionQuery::loadHottest(
|
||||||
$user,
|
$user,
|
||||||
$this->feedOffset,
|
$this->feedOffset,
|
||||||
self::FEED_PAGE_SIZE + 1);
|
self::FEED_PAGE_SIZE + 1);
|
||||||
|
|
||||||
$phids = array();
|
$this->loadHandles(mpull($questions, 'getAuthorPHID'));
|
||||||
foreach ($data as $question) {
|
|
||||||
$phids[] = $question->getAuthorPHID();
|
|
||||||
}
|
|
||||||
$handles = $this->loadViewerHandles($phids);
|
|
||||||
|
|
||||||
|
$view = $this->buildQuestionListView($questions);
|
||||||
$side_nav->appendChild(
|
$side_nav->appendChild(
|
||||||
id(new PonderQuestionFeedView())
|
id(new PhabricatorHeaderView())->setHeader($title));
|
||||||
->setUser($user)
|
$side_nav->appendChild($view);
|
||||||
->setData($data)
|
|
||||||
->setHandles($handles)
|
|
||||||
->setOffset($this->feedOffset)
|
|
||||||
->setPageSize(self::FEED_PAGE_SIZE)
|
|
||||||
->setURI(new PhutilURI("/ponder/feed/"), "off")
|
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
case 'profile':
|
case 'profile':
|
||||||
$questions = PonderQuestionQuery::loadByAuthor(
|
$questions = PonderQuestionQuery::loadByAuthor(
|
||||||
|
@ -107,11 +96,53 @@ final class PonderFeedController extends PonderController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return $this->buildStandardPageResponse(
|
return $this->buildApplicationPage(
|
||||||
$side_nav,
|
$side_nav,
|
||||||
array(
|
array(
|
||||||
'title' => $pages[$this->page]
|
'device' => true,
|
||||||
|
'title' => $title,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function buildQuestionListView(array $questions) {
|
||||||
|
assert_instances_of($questions, 'PonderQuestion');
|
||||||
|
$user = $this->getRequest()->getUser();
|
||||||
|
|
||||||
|
$view = new PhabricatorObjectItemListView();
|
||||||
|
$view->setNoDataString(pht('No matching questions.'));
|
||||||
|
foreach ($questions as $question) {
|
||||||
|
$item = new PhabricatorObjectItemView();
|
||||||
|
$item->setHeader('Q'.$question->getID().' '.$question->getTitle());
|
||||||
|
$item->setHref('/Q'.$question->getID());
|
||||||
|
|
||||||
|
$desc = $question->getContent();
|
||||||
|
if ($desc) {
|
||||||
|
$item->addDetail(
|
||||||
|
pht('Description'),
|
||||||
|
phutil_escape_html(phutil_utf8_shorten($desc, 128)));
|
||||||
|
}
|
||||||
|
|
||||||
|
$item->addDetail(
|
||||||
|
pht('Author'),
|
||||||
|
$this->getHandle($question->getAuthorPHID())->renderLink());
|
||||||
|
|
||||||
|
$item->addDetail(
|
||||||
|
pht('Votes'),
|
||||||
|
$question->getVoteCount());
|
||||||
|
|
||||||
|
$item->addDetail(
|
||||||
|
pht('Answers'),
|
||||||
|
$question->getAnswerCount());
|
||||||
|
|
||||||
|
$created = pht(
|
||||||
|
'Created %s',
|
||||||
|
phabricator_date($question->getDateCreated(), $user));
|
||||||
|
$item->addAttribute($created);
|
||||||
|
|
||||||
|
$view->addItem($item);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $view;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,7 @@ final class PonderQuestionQuery extends PhabricatorOffsetPagedQuery {
|
||||||
->setOffset($offset)
|
->setOffset($offset)
|
||||||
->setLimit($count)
|
->setLimit($count)
|
||||||
->orderByHottest(true)
|
->orderByHottest(true)
|
||||||
|
->orderByNewest(true)
|
||||||
->execute();
|
->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ final class PhabricatorObjectItemView extends AphrontView {
|
||||||
|
|
||||||
private $header;
|
private $header;
|
||||||
private $href;
|
private $href;
|
||||||
|
private $attributes = array();
|
||||||
private $details = array();
|
private $details = array();
|
||||||
private $dates = array();
|
private $dates = array();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue