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,29 +1,32 @@
<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" %>
<div class="new-merge-wrap"> <% @commits.each do |commit| %>
<div class="merge-commit-time"> <div class="new-merge-wrap">
<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> <div class="merge-commit-time">
<!--<p class="mt10 fontGrey2">1次提交</p>--> <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>
<p class="mt10 fontGrey2"><%= link_to commit.author_name, user_path(get_user_by_mail(commit.author_email)), :class => "link-blue" %> 创建于<%= time_tag(commit.created_at) %>前</p> <!--<p class="mt10 fontGrey2">1次提交</p>-->
</div> <p class="mt10 fontGrey2"><%= link_to commit.author_name, user_path(get_user_by_mail(commit.author_email)), :class => "link-blue" %> 创建于<%= time_tag(commit.created_at) %>前</p>
<div class="merge-commit-detail"> </div>
<span class="fontGrey3 fb"><%= commit.title %></span> <div class="merge-commit-detail">
<span class="fontGrey3 fb"><%= commit.title %></span>
</div> </div>
<div class="merge-commit-code"> <div class="merge-commit-code">
<span class="fontGrey3"> <span class="fontGrey3">
<%= link_to truncate(commit.short_id, :length => 20), {:controller => 'repositories', :action => 'commit_diff', :id => @project.id, :changeset => commit.id}, :target => "_blank" %> <%= link_to truncate(commit.short_id, :length => 20), {:controller => 'repositories', :action => 'commit_diff', :id => @project.id, :changeset => commit.id}, :target => "_blank" %>
</span> </span>
</div>
<div class="cl"></div>
</div>
<% 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> </div>
<div class="cl"></div>
</div>
<% 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>

@ -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>
<div id="merge_record_0"> <% if @type == nil || @type == "1" %>
<%= render :partial => "pull_requests/pull_request_comments" %> <div id="merge_record_0">
</div> <%= render :partial => "pull_requests/pull_request_comments" %>
</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