Mercurial > kallithea
changeset 3676:9d2db665ef31 beta
pagination in pull-requests page + UI
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Thu, 04 Apr 2013 22:33:41 +0200 |
parents | 7a5b11c23288 |
children | 3c79c197e95d |
files | rhodecode/controllers/pullrequests.py rhodecode/public/css/style.css rhodecode/templates/pullrequests/pullrequest_data.html rhodecode/templates/pullrequests/pullrequest_show_all.html |
diffstat | 4 files changed, 75 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/rhodecode/controllers/pullrequests.py Thu Apr 04 20:39:26 2013 +0200 +++ b/rhodecode/controllers/pullrequests.py Thu Apr 04 22:33:41 2013 +0200 @@ -38,6 +38,7 @@ from rhodecode.lib.base import BaseRepoController, render from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator,\ NotAnonymous +from rhodecode.lib.helpers import Page from rhodecode.lib import helpers as h from rhodecode.lib import diffs from rhodecode.lib.utils import action_logger, jsonify @@ -53,6 +54,7 @@ from rhodecode.model.changeset_status import ChangesetStatusModel from rhodecode.model.forms import PullRequestForm from mercurial import scmutil +from rhodecode.lib.utils2 import safe_int log = logging.getLogger(__name__) @@ -140,6 +142,15 @@ def show_all(self, repo_name): c.pull_requests = PullRequestModel().get_all(repo_name) c.repo_name = repo_name + p = safe_int(request.params.get('page', 1), 1) + + c.pullrequests_pager = Page(c.pull_requests, page=p, items_per_page=10) + + c.pullrequest_data = render('/pullrequests/pullrequest_data.html') + + if request.environ.get('HTTP_X_PARTIAL_XHR'): + return c.pullrequest_data + return render('/pullrequests/pullrequest_show_all.html') @NotAnonymous() @@ -201,6 +212,7 @@ c.default_other_repo_info = other_repos_info[c.default_other_repo] c.other_repos_info = json.dumps(other_repos_info) + return render('/pullrequests/pullrequest.html') @NotAnonymous()
--- a/rhodecode/public/css/style.css Thu Apr 04 20:39:26 2013 +0200 +++ b/rhodecode/public/css/style.css Thu Apr 04 22:33:41 2013 +0200 @@ -4568,7 +4568,6 @@ font-weight: bold; } -div.closed h4 a, h3.closed, #pullrequests_container li.closed a { @@ -4576,6 +4575,34 @@ background: #eee; } +div.pr-title { + font-size: 1.6em; +} + +div.pr { + border-bottom: 1px solid #DDD; + margin: 0px 20px; + padding: 10px 0px; +} +div.pr-closed { + background-color: rgba(245,245,245,0.5); +} + +span.pr-closed-tag { + margin-bottom: 1px; + margin-right: 1px; + padding: 1px 3px; + font-size: 10px; + padding: 1px 3px 1px 3px; + font-size: 10px; + color: #336699; + white-space: nowrap; + -webkit-border-radius: 4px; + border-radius: 4px; + border: 1px solid #d9e8f8; + line-height: 1.5em; +} + /**** PERMS *****/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rhodecode/templates/pullrequests/pullrequest_data.html Thu Apr 04 22:33:41 2013 +0200 @@ -0,0 +1,33 @@ +## -*- coding: utf-8 -*- + +% for pr in c.pullrequests_pager: + <div class="pr ${'pr-closed' if pr.is_closed() else ''}"> + <div class="pr-title"> + %if pr.is_closed(): + <div style="float:left;margin: -4px 0px;"><span class="pr-closed-tag">${_('Closed')}</span></div> + %endif + <img src="${h.url('/images/icons/flag_status_%s.png' % str(pr.last_review_status))}" /> + <a href="${h.url('pullrequest_show',repo_name=c.repo_name,pull_request_id=pr.pull_request_id)}"> + ${_('Pull request #%s opened by %s on %s') % (pr.pull_request_id, pr.author.full_name, h.fmt_date(pr.created_on))} + </a> + </div> + <h5 style="border:0px;padding-bottom:0px">${_('Title')}: ${pr.title}</h5> + <div>${pr.description}</div> + </div> +% endfor + +<div class="pagination-wh pagination-left"> +<script type="text/javascript"> +YUE.onDOMReady(function(){ + YUE.delegate("pullrequests","click",function(e, matchedEl, container){ + ypjax(e.target.href,"pullrequests",function(){ + show_more_event(); + tooltip_activate(); + show_changeset_tooltip(); + }); + YUE.preventDefault(e); + },'.pager_link'); +}); +</script> +${c.pullrequests_pager.pager('$link_previous ~2~ $link_next')} +</div>
--- a/rhodecode/templates/pullrequests/pullrequest_show_all.html Thu Apr 04 20:39:26 2013 +0200 +++ b/rhodecode/templates/pullrequests/pullrequest_show_all.html Thu Apr 04 22:33:41 2013 +0200 @@ -14,29 +14,13 @@ <%def name="main()"> ${self.context_bar('showpullrequest')} + <div class="box"> <!-- box / title --> <div class="title"> ${self.breadcrumbs()} </div> - - %for pr in c.pull_requests: - <div class="${'closed' if pr.is_closed() else ''}"> - <h4 style="border:0px;padding:0px"> - <img src="${h.url('/images/icons/flag_status_%s.png' % str(pr.last_review_status))}" /> - <a href="${h.url('pullrequest_show',repo_name=c.repo_name,pull_request_id=pr.pull_request_id)}"> - ${_('Pull request #%s opened by %s on %s') % (pr.pull_request_id, pr.author.full_name, h.fmt_date(pr.created_on))} - </a> - %if pr.is_closed(): - (${_('Closed')}) - %endif - </h4> - <h5 style="border:0px;padding-bottom:0px">${_('Title')}: ${pr.title}</h5> - <div style="padding:0px 24px">${pr.description}</div> - <div style="border-bottom: 1px solid #DDD;margin:10px 20px;padding-bottom:10px"></div> - </div> - %endfor - + ${c.pullrequest_data} </div> </%def>