From dd9c280d09cbe4051b688ee7ff1c72298a289902 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Wed, 1 Apr 2015 19:22:40 +0500 Subject: [PATCH] show a file diff when click on it in the header stats --- app/assets/javascripts/extra/diff.js.coffee | 6 ++++++ app/assets/javascripts/new_application.js | 1 + app/helpers/diff_helper.rb | 4 +--- 3 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 app/assets/javascripts/extra/diff.js.coffee diff --git a/app/assets/javascripts/extra/diff.js.coffee b/app/assets/javascripts/extra/diff.js.coffee new file mode 100644 index 000000000..77b3e59cd --- /dev/null +++ b/app/assets/javascripts/extra/diff.js.coffee @@ -0,0 +1,6 @@ +$(document).ready -> + $(document).on 'click', '#diff_header .panel-body table a', -> + href = $(this).attr('href') + $(".diff_data.collapse#"+href.slice(1)+"_content").collapse('show') + + return diff --git a/app/assets/javascripts/new_application.js b/app/assets/javascripts/new_application.js index 70d458008..fe206c76b 100644 --- a/app/assets/javascripts/new_application.js +++ b/app/assets/javascripts/new_application.js @@ -39,6 +39,7 @@ //= require extra/scroller //= require extra/fork //= require extra/diff_chevrons +//= require extra/diff //= require_self diff --git a/app/helpers/diff_helper.rb b/app/helpers/diff_helper.rb index 439fb1a96..afa4b193a 100644 --- a/app/helpers/diff_helper.rb +++ b/app/helpers/diff_helper.rb @@ -3,12 +3,10 @@ module DiffHelper MAX_LINES_WITHOUT_COLLAPSE = 50 def render_diff_stats(stats) - path = @pull.try(:id) ? polymorphic_path([@project, @pull]) : '' - res = [""] stats.each_with_index do |stat, ind| res << "" - res << "" + res << "" res << "
#{link_to stat.filename.rtruncate(120), "#{path}#diff-#{ind}"}#{link_to stat.filename.rtruncate(120), "#diff-#{ind}"}" res << I18n.t("layout.projects.inline_changes_count", count: stat.additions + stat.deletions).strip + " (" +