Pull request列表页面分类

This commit is contained in:
huang 2016-08-03 16:54:37 +08:00
parent 9f9eed2e27
commit f8b53b8dfc
5 changed files with 36 additions and 22 deletions

View File

@ -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

View File

@ -0,0 +1,15 @@
<% if @requests.nil? %>
<div class="no-merge-content">没有可显示的请求</div>
<% else %>
<% @requests.each do |request| %>
<li>
<% request %>
<%=link_to request.title, project_pull_request_path(request.id, :project_id => @project.id), :class => "linkGrey3 fb fl"%>
<!--<a href="javascript:void(0);" class="fr fontGrey2 fb"><img src="/images/comments.png" class="mr5" width="15" />0</a><span class="fr mr15 fb fontGrey2">关闭</span>-->
<div class="cl mb5"></div>
<span class="fontGrey2"><%= 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) %></span>
<span class="fr fontGrey2"><%= time_tag(request.updated_at) %>更新</span>
<div class="cl"></div>
</li>
<% end %>
<% end %>

View File

@ -1,29 +1,15 @@
<%= render :partial => "pull_requests/pull_request_container" %>
<ul id="mergeBanner" class="project-merge-banner">
<li><a href="javascript:void(0);">打开<span class="project-number-dot">1</span></a></li>
<li><a href="javascript:void(0);">合并<span class="project-number-dot">1</span></a></li>
<li><a href="javascript:void(0);">关闭<span class="project-number-dot">1</span></a></li>
<li class="active"><a href="javascript:void(0);">全部<span class="project-number-dot">3</span></a></li>
<li class="active"><%= link_to "待处理<span class='project-number-dot'>#{@requests_opened_count}</span>".html_safe, project_pull_requests_path(:type => "1"), :remote => true %></li>
<li><%= link_to "已处理<span class='project-number-dot'>#{@requests_merged_count}</span>".html_safe, project_pull_requests_path(:type => "2"), :remote => true %></li>
<%= link_to "创建Pull Request", new_project_pull_request_path, :class => "BlueCirBtn fr ml10 mt10", :style => "width:110px;" %>
<div class="cl"></div>
</ul>
<div class="cl"></div>
<ul class="project-merge-content">
<% if @requests.nil? %>
<div class="no-merge-content">没有可显示的请求</div>
<% else %>
<% @requests.each do |request| %>
<li>
<% request %>
<%=link_to request.title, project_pull_request_path(request.id, :project_id => @project.id), :class => "linkGrey3 fb fl"%>
<!--<a href="javascript:void(0);" class="fr fontGrey2 fb"><img src="/images/comments.png" class="mr5" width="15" />0</a><span class="fr mr15 fb fontGrey2">关闭</span>-->
<div class="cl mb5"></div>
<span class="fontGrey2"><%= 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) %></span>
<span class="fr fontGrey2"><%= time_tag(request.updated_at) %>更新</span>
<div class="cl"></div>
</li>
<% end %>
<% end %>
<ul class="project-merge-content" id="pull_requests_list">
<%= render "pull_requests/pull_requests_list" %>
</ul>
<script>

View File

@ -0,0 +1 @@
$("#pull_requests_list").html('<%= escape_javascript( render :partial => "pull_requests/pull_requests_list", :locals => {:type => @type} ) %>');

View File

@ -1 +1 @@
$("#merge_record_0").html('<%= render :partial => "pull_requests/pull_request_commits" %>');
$("#merge_record_0").html('<%= escape_javascript( render :partial => "pull_requests/pull_request_commits", :locals => {:type => @type} ) %>');