PUll request代码简化及reverse评论

dev_blankdatabase
huang 9 years ago
parent 41ad5ca444
commit 3df8a46634

@ -95,7 +95,7 @@ class PullRequestsController < ApplicationController
@commits_count = @commits.count @commits_count = @commits.count
@changes = @g.merge_request_changes(@project.gpid, params[:id]).try(:changes) @changes = @g.merge_request_changes(@project.gpid, params[:id]).try(:changes)
@changes_count = @changes.count @changes_count = @changes.count
@comments = @g.merge_request_comments(@project.gpid, params[:id]) @comments = @g.merge_request_comments(@project.gpid, params[:id]).reverse
@comments_count = @comments.count @comments_count = @comments.count
@limit = 10 @limit = 10
@ -178,7 +178,7 @@ class PullRequestsController < ApplicationController
# Gitlab.merge_request_comments(5, 1) # Gitlab.merge_request_comments(5, 1)
def pull_request_comments def pull_request_comments
begin begin
@comments = @g.merge_request_comments(@project.gpid, params[:id]) @comments = @g.merge_request_comments(@project.gpid, params[:id]).reverse
@comments_count = @comments.count @comments_count = @comments.count
@limit = 10 @limit = 10
@ -198,6 +198,7 @@ class PullRequestsController < ApplicationController
# merge_request_id (required) - The ID of MR # merge_request_id (required) - The ID of MR
def pull_request_commits def pull_request_commits
begin begin
@type = params[:type]
@commits = @g.merge_request_commits(@project.gpid, params[:id]) @commits = @g.merge_request_commits(@project.gpid, params[:id])
@commits_count = @commits.count @commits_count = @commits.count
@ -218,6 +219,7 @@ class PullRequestsController < ApplicationController
# merge_request_id (required) - The ID of MR # merge_request_id (required) - The ID of MR
def pull_request_changes def pull_request_changes
begin begin
@type = params[:type]
@changes = @g.merge_request_changes(@project.gpid, params[:id]).try(:changes) @changes = @g.merge_request_changes(@project.gpid, params[:id]).try(:changes)
@changes_count = @changes.count @changes_count = @changes.count

@ -1,4 +1,4 @@
<% unless @changes.blank? %> <% if !@changes.blank? && @type == "3" %>
<% @changes.each do |cd| %> <% @changes.each do |cd| %>
<div class="showing-changes-row fontGrey2" style="width:710px;"> <div class="showing-changes-row fontGrey2" style="width:710px;">
<a class="linkGrey3" id="changed-files"> <a class="linkGrey3" id="changed-files">

@ -5,7 +5,7 @@
<a href="javascript:void(0);" class="BlueCirBtn mt10" onclick="pull_request_commit()">提交请求</a> <a href="javascript:void(0);" class="BlueCirBtn mt10" onclick="pull_request_commit()">提交请求</a>
<% end %> <% end %>
</div> </div>
<% @comments.reverse.each do |comment| %> <% @comments.each do |comment| %>
<div class="merge-discussion-content merge-discussion-automatic"> <div class="merge-discussion-content merge-discussion-automatic">
<%= link_to comment.author.try(:username), user_path(get_user_by_login_and(comment.author.try(:username))), :class => "link-blue mr15 fl" %> <%= link_to comment.author.try(:username), user_path(get_user_by_login_and(comment.author.try(:username))), :class => "link-blue mr15 fl" %>
<span class="fl fontGrey2"><%= time_tag(comment.created_at) %>前</span> <span class="fl fontGrey2"><%= time_tag(comment.created_at) %>前</span>

@ -1,5 +1,6 @@
<div class="new-merge-row b_grey fontGrey2"><span class="ml10"> 根据最近提交时间排列</span></div> <div class="new-merge-row b_grey fontGrey2"><span class="ml10"> 根据最近提交时间排列</span></div>
<% @commits.each do |commit| %> <% if !@commits.blank? && @type == "2" %>
<% @commits.each do |commit| %>
<div class="new-merge-wrap"> <div class="new-merge-wrap">
<div class="merge-commit-time"> <div class="merge-commit-time">
<img width="16" class="ui-datepicker-trigger mr15" style="cursor:default; margin-top:3px; margin-left:0;" /><span class="fontGrey3"><%= format_date(commit.created_at) %></span> <img width="16" class="ui-datepicker-trigger mr15" style="cursor:default; margin-top:3px; margin-left:0;" /><span class="fontGrey3"><%= format_date(commit.created_at) %></span>
@ -17,13 +18,15 @@
</div> </div>
<div class="cl"></div> <div class="cl"></div>
</div> </div>
<% end %> <% end %>
<div style="text-align:center;"> <div style="text-align:center;">
<div class="pages" style="width:auto; display:inline-block;"> <div class="pages" style="width:auto; display:inline-block;">
<ul id="homework_pository_ref_pages"> <ul id="homework_pository_ref_pages">
<%= pagination_links_full @pages, @count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true%> <%= pagination_links_full @pages, @count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true%>
</ul> </ul>
<div class="cl"></div> <div class="cl"></div>
</div> </div>
</div> </div>
<% end %>

@ -40,19 +40,22 @@
</div> </div>
<ul class="merge-record" style="border-top:1px solid #ddd;"> <ul class="merge-record" style="border-top:1px solid #ddd;">
<li><%= link_to "留言<span class='project-number-dot'>#{@comments_count}</span>".html_safe, pull_request_comments_project_pull_request_path(@request.id, :project_id => @project.id), :remote => true, :class => "active" %></li> <li><%= link_to "留言<span class='project-number-dot'>#{@comments_count}</span>".html_safe, pull_request_comments_project_pull_request_path(@request.id, :project_id => @project.id, :type => "1"), :remote => true, :class => "active" %></li>
<li><%= link_to "提交<span class='project-number-dot'>#{@commits_count}</span>".html_safe, pull_request_commits_project_pull_request_path(@request.id, :project_id => @project.id), :remote => true %></li> <li><%= link_to "提交<span class='project-number-dot'>#{@commits_count}</span>".html_safe, pull_request_commits_project_pull_request_path(@request.id, :project_id => @project.id, :type => "2"), :remote => true %></li>
<li><%= link_to "改动<span class='project-number-dot'>#{@changes_count}</span>".html_safe, pull_request_changes_project_pull_request_path(@request.id, :project_id => @project.id), :remote => true %></li> <li><%= link_to "改动<span class='project-number-dot'>#{@changes_count}</span>".html_safe, pull_request_changes_project_pull_request_path(@request.id, :project_id => @project.id, :type => "3"), :remote => true %></li>
</ul> </ul>
<% if @type == nil || @type == "1" %>
<div id="merge_record_0"> <div id="merge_record_0">
<%= render :partial => "pull_requests/pull_request_comments" %> <%= render :partial => "pull_requests/pull_request_comments" %>
</div> </div>
<% end %>
<div id="merge_record_1" class="undis"> <div id="merge_record_1" class="undis">
<%= render :partial => "pull_requests/pull_request_commits" %> <%= render :partial => "pull_requests/pull_request_commits" %>
</div> </div>
<div id="merge_record_2" class="undis"> <div id="merge_record_2" class="undis">
<%= render :partial => "pull_requests/pull_request_changes" %> <%= render :partial => "pull_requests/pull_request_changes" %>
</div> </div>
<% end %> <% end %>
</div> </div>

Loading…
Cancel
Save