mirror of
https://we.phorge.it/source/phorge.git
synced 2025-03-06 09:29:28 +01:00
Improve pagination in ChatLog application
Summary: - Add an extra paginator at the top. - Add a link to jump to the bottom (where the latest messages are). - Align paginators with edge of content rather than the page. Test Plan: Looked at the chatlog. Reviewers: epriestley, chad, #blessed_reviewers CC: chad, Korvin, epriestley, aran Differential Revision: https://secure.phabricator.com/D7280
This commit is contained in:
parent
8cc64a9678
commit
ff4fa1885b
4 changed files with 148 additions and 17 deletions
|
@ -3066,7 +3066,7 @@ celerity_register_resource_map(array(
|
||||||
),
|
),
|
||||||
'phabricator-chatlog-css' =>
|
'phabricator-chatlog-css' =>
|
||||||
array(
|
array(
|
||||||
'uri' => '/res/5542e247/rsrc/css/application/chatlog/chatlog.css',
|
'uri' => '/res/cf9b0aa7/rsrc/css/application/chatlog/chatlog.css',
|
||||||
'type' => 'css',
|
'type' => 'css',
|
||||||
'requires' =>
|
'requires' =>
|
||||||
array(
|
array(
|
||||||
|
|
|
@ -139,6 +139,48 @@ final class PhabricatorChatLogChannelLogController
|
||||||
$message));
|
$message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$links = array();
|
||||||
|
|
||||||
|
$first_uri = $pager->getFirstPageURI();
|
||||||
|
if ($first_uri) {
|
||||||
|
$links[] = phutil_tag(
|
||||||
|
'a',
|
||||||
|
array(
|
||||||
|
'href' => $first_uri,
|
||||||
|
),
|
||||||
|
"\xC2\xAB ". pht("Newest"));
|
||||||
|
}
|
||||||
|
|
||||||
|
$prev_uri = $pager->getPrevPageURI();
|
||||||
|
if ($prev_uri) {
|
||||||
|
$links[] = phutil_tag(
|
||||||
|
'a',
|
||||||
|
array(
|
||||||
|
'href' => $prev_uri,
|
||||||
|
),
|
||||||
|
"\xE2\x80\xB9 " . pht("Newer"));
|
||||||
|
}
|
||||||
|
|
||||||
|
$next_uri = $pager->getNextPageURI();
|
||||||
|
if ($next_uri) {
|
||||||
|
$links[] = phutil_tag(
|
||||||
|
'a',
|
||||||
|
array(
|
||||||
|
'href' => $next_uri,
|
||||||
|
),
|
||||||
|
pht("Older") . " \xE2\x80\xBA");
|
||||||
|
}
|
||||||
|
|
||||||
|
$pager_top = phutil_tag(
|
||||||
|
'div',
|
||||||
|
array('class' => 'phabricator-chat-log-pager-top'),
|
||||||
|
$links);
|
||||||
|
|
||||||
|
$pager_bottom = phutil_tag(
|
||||||
|
'div',
|
||||||
|
array('class' => 'phabricator-chat-log-pager-bottom'),
|
||||||
|
$links);
|
||||||
|
|
||||||
$crumbs = $this
|
$crumbs = $this
|
||||||
->buildApplicationCrumbs()
|
->buildApplicationCrumbs()
|
||||||
->addCrumb(
|
->addCrumb(
|
||||||
|
@ -176,19 +218,44 @@ final class PhabricatorChatLogChannelLogController
|
||||||
),
|
),
|
||||||
$table);
|
$table);
|
||||||
|
|
||||||
|
$jump_link = phutil_tag(
|
||||||
|
'a',
|
||||||
|
array(
|
||||||
|
'href' => '#latest'
|
||||||
|
),
|
||||||
|
pht("Jump to Bottom") . " \xE2\x96\xBE");
|
||||||
|
|
||||||
|
$jump = phutil_tag(
|
||||||
|
'div',
|
||||||
|
array(
|
||||||
|
'class' => 'phabricator-chat-log-jump'
|
||||||
|
),
|
||||||
|
$jump_link);
|
||||||
|
|
||||||
|
$jump_target = phutil_tag(
|
||||||
|
'div',
|
||||||
|
array(
|
||||||
|
'id' => 'latest'
|
||||||
|
));
|
||||||
|
|
||||||
$content = phutil_tag(
|
$content = phutil_tag(
|
||||||
'div',
|
'div',
|
||||||
array(
|
array(
|
||||||
'class' => 'phabricator-chat-log-wrap'
|
'class' => 'phabricator-chat-log-wrap'
|
||||||
),
|
),
|
||||||
$log);
|
array(
|
||||||
|
$jump,
|
||||||
|
$pager_top,
|
||||||
|
$log,
|
||||||
|
$jump_target,
|
||||||
|
$pager_bottom,
|
||||||
|
));
|
||||||
|
|
||||||
return $this->buildApplicationPage(
|
return $this->buildApplicationPage(
|
||||||
array(
|
array(
|
||||||
$crumbs,
|
$crumbs,
|
||||||
$filter,
|
$filter,
|
||||||
$content,
|
$content,
|
||||||
$pager,
|
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'title' => pht('Channel Log'),
|
'title' => pht('Channel Log'),
|
||||||
|
|
|
@ -86,6 +86,51 @@ final class AphrontCursorPagerView extends AphrontView {
|
||||||
($this->beforeID && $this->moreResults);
|
($this->beforeID && $this->moreResults);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getFirstPageURI() {
|
||||||
|
if (!$this->uri) {
|
||||||
|
throw new Exception(
|
||||||
|
pht("You must call setURI() before you can call getFirstPageURI()."));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$this->afterID && !($this->beforeID && $this->moreResults)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->uri
|
||||||
|
->alter('before', null)
|
||||||
|
->alter('after', null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPrevPageURI() {
|
||||||
|
if (!$this->uri) {
|
||||||
|
throw new Exception(
|
||||||
|
pht("You must call setURI() before you can call getPrevPageURI()."));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$this->prevPageID) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->uri
|
||||||
|
->alter('after', null)
|
||||||
|
->alter('before', $this->prevPageID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNextPageURI() {
|
||||||
|
if (!$this->uri) {
|
||||||
|
throw new Exception(
|
||||||
|
pht("You must call setURI() before you can call getNextPageURI()."));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$this->nextPageID) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->uri
|
||||||
|
->alter('after', $this->nextPageID)
|
||||||
|
->alter('before', null);
|
||||||
|
}
|
||||||
|
|
||||||
public function render() {
|
public function render() {
|
||||||
if (!$this->uri) {
|
if (!$this->uri) {
|
||||||
throw new Exception(
|
throw new Exception(
|
||||||
|
@ -94,37 +139,34 @@ final class AphrontCursorPagerView extends AphrontView {
|
||||||
|
|
||||||
$links = array();
|
$links = array();
|
||||||
|
|
||||||
if ($this->afterID || ($this->beforeID && $this->moreResults)) {
|
$first_uri = $this->getFirstPageURI();
|
||||||
|
if ($first_uri) {
|
||||||
$links[] = phutil_tag(
|
$links[] = phutil_tag(
|
||||||
'a',
|
'a',
|
||||||
array(
|
array(
|
||||||
'href' => $this->uri
|
'href' => $first_uri,
|
||||||
->alter('before', null)
|
|
||||||
->alter('after', null),
|
|
||||||
),
|
),
|
||||||
"\xC2\xAB ". pht("First"));
|
"\xC2\xAB ". pht("First"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->prevPageID) {
|
$prev_uri = $this->getPrevPageURI();
|
||||||
|
if ($prev_uri) {
|
||||||
$links[] = phutil_tag(
|
$links[] = phutil_tag(
|
||||||
'a',
|
'a',
|
||||||
array(
|
array(
|
||||||
'href' => $this->uri
|
'href' => $prev_uri,
|
||||||
->alter('after', null)
|
|
||||||
->alter('before', $this->prevPageID),
|
|
||||||
),
|
),
|
||||||
"\xE2\x80\xB9 " . pht("Prev"));
|
"\xE2\x80\xB9 " . pht("Prev"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->nextPageID) {
|
$next_uri = $this->getNextPageURI();
|
||||||
|
if ($next_uri) {
|
||||||
$links[] = phutil_tag(
|
$links[] = phutil_tag(
|
||||||
'a',
|
'a',
|
||||||
array(
|
array(
|
||||||
'href' => $this->uri
|
'href' => $next_uri,
|
||||||
->alter('after', $this->nextPageID)
|
|
||||||
->alter('before', null),
|
|
||||||
),
|
),
|
||||||
"Next \xE2\x80\xBA");
|
pht("Next") . " \xE2\x80\xBA");
|
||||||
}
|
}
|
||||||
|
|
||||||
return phutil_tag(
|
return phutil_tag(
|
||||||
|
|
|
@ -10,8 +10,30 @@
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.phabricator-chat-log-pager-top {
|
||||||
|
padding: 16px 4px 8px;
|
||||||
|
font-weight: bold;
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.phabricator-chat-log-pager-bottom {
|
||||||
|
padding: 8px 4px 16px;
|
||||||
|
font-weight: bold;
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.phabricator-chat-log-pager-top a, .phabricator-chat-log-pager-bottom a {
|
||||||
|
padding: 2px 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.phabricator-chat-log-jump {
|
||||||
|
padding: 16px 4px 8px;
|
||||||
|
font-weight: bold;
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
|
||||||
.phabricator-chat-log-panel {
|
.phabricator-chat-log-panel {
|
||||||
margin: 20px auto;
|
clear: both;
|
||||||
border-left: 1px solid #e7e7e7;
|
border-left: 1px solid #e7e7e7;
|
||||||
border-right: 1px solid #e7e7e7;
|
border-right: 1px solid #e7e7e7;
|
||||||
border-bottom: 1px solid #c0c5d1;
|
border-bottom: 1px solid #c0c5d1;
|
||||||
|
|
Loading…
Add table
Reference in a new issue