pull request 列表页面添加分页

This commit is contained in:
huang 2016-08-09 15:28:06 +08:00
parent dcdc09d864
commit 867434531d
5 changed files with 29 additions and 1 deletions

View File

@ -21,6 +21,13 @@ class PullRequestsController < ApplicationController
@requests_opened_count = @requests.count @requests_opened_count = @requests.count
@requests_merged_count = @g.merge_requests(@project.gpid).select{|request| request.state == "merged"}.count @requests_merged_count = @g.merge_requests(@project.gpid).select{|request| request.state == "merged"}.count
@requests_closed_count = @g.merge_requests(@project.gpid).select{|request| request.state == "closed"}.count @requests_closed_count = @g.merge_requests(@project.gpid).select{|request| request.state == "closed"}.count
@limit = 10
@is_remote = true
@count = type_count(type, @requests_opened_count, @requests_merged_count, @requests_closed_count)
@pages = Paginator.new @count, @limit, params['page'] || 1
@offset ||= @pages.offset
@requests = paginateHelper @requests, 10
respond_to do |format| respond_to do |format|
format.html format.html
format.js format.js

View File

@ -25,4 +25,15 @@ module PullRequestsHelper
end end
end end
def type_count type, requests_opened_count, requests_merged_count, requests_closed_count
case type
when nil, "1"
requests_opened_count
when "2"
requests_merged_count
when "3"
requests_closed_count
end
end
end end

View File

@ -12,4 +12,13 @@
<div class="cl"></div> <div class="cl"></div>
</li> </li>
<% end %> <% end %>
<div style="text-align:center;">
<div class="pages" style="width:auto; display:inline-block;">
<ul id="homework_pository_ref_pages">
<%= pagination_links_full @pages, @count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true%>
</ul>
<div class="cl"></div>
</div>
</div>
<% end %> <% end %>

View File

@ -13,6 +13,7 @@
<%= render "pull_requests/pull_requests_list" %> <%= render "pull_requests/pull_requests_list" %>
</ul> </ul>
<script> <script>
$("#mergeBanner").parent().css("width","730px"); $("#mergeBanner").parent().css("width","730px");

View File

@ -523,7 +523,7 @@ a:hover.upload_btn_grey{background:#8a8a8a;}
.project-merge-banner li a {padding:14px; font-size:14px; color:#555; display:inline-block;} .project-merge-banner li a {padding:14px; font-size:14px; color:#555; display:inline-block;}
.project-number-dot {display:inline-block; min-width:10px; padding:3px 5px; font-size:12px; color:#888; line-height:1; vertical-align:middle; white-space:nowrap; text-align:center; background-color:#eee; border-radius:10px; margin-left:5px;} .project-number-dot {display:inline-block; min-width:10px; padding:3px 5px; font-size:12px; color:#888; line-height:1; vertical-align:middle; white-space:nowrap; text-align:center; background-color:#eee; border-radius:10px; margin-left:5px;}
.project-merge-content {} .project-merge-content {}
.project-merge-content li {padding:10px; margin:0 -10px; background-color:#f9f9f9; border-bottom:1px solid #e5e5e5;} .project-merge-content>li {padding:10px; margin:0 -10px; background-color:#f9f9f9; border-bottom:1px solid #e5e5e5;}
.no-merge-content {padding:10px 15px; color:#888;} .no-merge-content {padding:10px 15px; color:#888;}
.new-merge-request {border-bottom:1px solid #ddd; padding-bottom:10px;} .new-merge-request {border-bottom:1px solid #ddd; padding-bottom:10px;}
.new-merge-wrap {font-size:13px; color:#484848; border-bottom:1px solid #ddd; padding:10px 0;} .new-merge-wrap {font-size:13px; color:#484848; border-bottom:1px solid #ddd; padding:10px 0;}