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" %>
    -