diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb
index 2fe1e934c..cc5a7a052 100644
--- a/app/controllers/pull_requests_controller.rb
+++ b/app/controllers/pull_requests_controller.rb
@@ -5,7 +5,19 @@ class PullRequestsController < ApplicationController
# 返回json格式
def index
- @requests = @g.merge_requests(@project.gpid)
+ type = params[:type]
+ case type
+ when nil, "1"
+ @requests = @g.merge_requests(@project.gpid).select{|request| request.state == "opened" || request.state == "reopened"}
+ when "2"
+ @requests = @g.merge_requests(@project.gpid).select{|request| request.state == "merged"}
+ end
+ @requests_opened_count = @requests.count
+ @requests_merged_count = params[:type] ? @requests.count : @g.merge_requests(@project.gpid).select{|request| request.state == "merged"}.count
+ respond_to do |format|
+ format.html
+ format.js
+ end
end
def new
diff --git a/app/views/pull_requests/_pull_requests_list.html.erb b/app/views/pull_requests/_pull_requests_list.html.erb
new file mode 100644
index 000000000..820c09c3f
--- /dev/null
+++ b/app/views/pull_requests/_pull_requests_list.html.erb
@@ -0,0 +1,15 @@
+<% if @requests.nil? %>
+
没有可显示的请求
+<% else %>
+ <% @requests.each do |request| %>
+
+ <% request %>
+ <%=link_to request.title, project_pull_request_path(request.id, :project_id => @project.id), :class => "linkGrey3 fb fl"%>
+
+
+ <%= link_to request.author.try(:username), user_path(get_user_by_login_and(request.author.try(:username))), :class => "link-blue" %> 创建于<%= time_tag(request.created_at) %>
+ <%= time_tag(request.updated_at) %>更新
+
+
+ <% end %>
+<% end %>
\ No newline at end of file
diff --git a/app/views/pull_requests/index.html.erb b/app/views/pull_requests/index.html.erb
index 56d72c5ce..f9f7fe4db 100644
--- a/app/views/pull_requests/index.html.erb
+++ b/app/views/pull_requests/index.html.erb
@@ -1,29 +1,15 @@
<%= render :partial => "pull_requests/pull_request_container" %>
- - 打开1
- - 合并1
- - 关闭1
- - 全部3
+ - <%= link_to "待处理#{@requests_opened_count}".html_safe, project_pull_requests_path(:type => "1"), :remote => true %>
+ - <%= link_to "已处理#{@requests_merged_count}".html_safe, project_pull_requests_path(:type => "2"), :remote => true %>
+
<%= link_to "创建Pull Request", new_project_pull_request_path, :class => "BlueCirBtn fr ml10 mt10", :style => "width:110px;" %>
-
- <% if @requests.nil? %>
- 没有可显示的请求
- <% else %>
- <% @requests.each do |request| %>
- -
- <% request %>
- <%=link_to request.title, project_pull_request_path(request.id, :project_id => @project.id), :class => "linkGrey3 fb fl"%>
-
-
- <%= link_to request.author.try(:username), user_path(get_user_by_login_and(request.author.try(:username))), :class => "link-blue" %> 创建于<%= time_tag(request.created_at) %>
- <%= time_tag(request.updated_at) %>更新
-
-
- <% end %>
- <% end %>
+
+
+ <%= render "pull_requests/pull_requests_list" %>