Merge pull request #4053 from HDinger/fix/21338-special-icons-for-added-deleted-folders-in-repository-revision-view

[21338] Special Icons for added/deleted folders in Repository/Revision view
pull/4137/head
Oliver Günther 9 years ago
commit 0102f7fde7
  1. 24
      app/helpers/repositories_helper.rb
  2. 6
      lib/redmine/unified_diff.rb

@ -91,6 +91,27 @@ module RepositoriesHelper
render_changes_tree(tree[:s])
end
# Mapping from internal action to (folder|file)-icon type
def change_action_mapping
{
'A' => :add,
'B' => :remove
}
end
# This calculates whether a folder was added, deleted or modified. It is based on the assumption that
# a folder was added/deleted when all content was added/deleted since the folder changes were not tracked.
def calculate_folder_action(tree)
seen = Set.new
tree.each do |_, entry|
if folderStyle = change_action_mapping[entry[:c].try(:action)]
seen << folderStyle
end
end
seen.size == 1 ? seen.first : :open
end
def render_changes_tree(tree)
return '' if tree.nil?
@ -108,7 +129,8 @@ module RepositoriesHelper
project_id: @project,
path: path_param,
rev: @changeset.identifier)
output << "<li class='#{style} icon icon-folder-open'>#{text}</li>"
output << "<li class='#{style} icon icon-folder-#{calculate_folder_action(s)}'>#{text}</li>"
output << render_changes_tree(s)
elsif c = tree[file][:c]
style << " change-#{c.action}"

@ -236,7 +236,7 @@ module Redmine
def html_line_left
if offsets
line_left.dup.insert(offsets.first, '<span>').insert(offsets.last, '</span>').html_safe
line_left.dup.insert(offsets.first, '<span>').insert(offsets.last, '</span>')
else
line_left
end
@ -244,7 +244,7 @@ module Redmine
def html_line_right
if offsets
line_right.dup.insert(offsets.first, '<span>').insert(offsets.last, '</span>').html_safe
line_right.dup.insert(offsets.first, '<span>').insert(offsets.last, '</span>')
else
line_right
end
@ -252,7 +252,7 @@ module Redmine
def html_line
if offsets
line.dup.insert(offsets.first, '<span>').insert(offsets.last, '</span>').html_safe
line.dup.insert(offsets.first, '<span>').insert(offsets.last, '</span>')
else
line
end

Loading…
Cancel
Save