#183 Full path to the target file by file links in the main view

This commit is contained in:
Karel Picman 2014-03-05 11:24:08 +01:00
parent 820a4920b9
commit 7817ee5f19
4 changed files with 12 additions and 6 deletions

View File

@ -170,11 +170,7 @@ class DmsfFile < ActiveRecord::Base
def notify_activate def notify_activate
self.notification = true self.notification = true
self.save! self.save!
end end
def display_name
return self.name
end
# Returns an array of projects that current user can copy file to # Returns an array of projects that current user can copy file to
def self.allowed_target_projects_on_copy def self.allowed_target_projects_on_copy

View File

@ -69,5 +69,10 @@ class DmsfLink < ActiveRecord::Base
end end
nil nil
end end
def path
file = self.target_file
file.dmsf_path.map { |element| element.is_a?(DmsfFile) ? element.name : element.title }.join('/') if file
end
end end

View File

@ -31,7 +31,7 @@
:class => "icon icon-file #{DmsfHelper.filetype_css(file.name)}", :class => "icon icon-file #{DmsfHelper.filetype_css(file.name)}",
:title => l(:title_title_version_version_download, :title => h(file.title), :version => file.version), :title => l(:title_title_version_version_download, :title => h(file.title), :version => file.version),
'data-downloadurl' => "#{file.last_revision.detect_content_type}:#{h(file.name)}:#{file_download_url}") %> 'data-downloadurl' => "#{file.last_revision.detect_content_type}:#{h(file.name)}:#{file_download_url}") %>
<div class="filename" title="<%= l(:title_filename_for_download)%>"><%= h(file.display_name) %></div> <div class="filename" title="<%= l(:title_filename_for_download)%>"><%= h(link ? link.path : file.name) %></div>
</td> </td>
<td class="size"><%= number_to_human_size(file.last_revision.size) %></td> <td class="size"><%= number_to_human_size(file.last_revision.size) %></td>
<td class="modified"> <td class="modified">

View File

@ -137,6 +137,11 @@ class DmsfLinksTest < RedmineDmsf::Test::UnitTest
DmsfLink.find_link_by_file_name(@file_link.project, @file_link.folder, @file_link.target_file.name) DmsfLink.find_link_by_file_name(@file_link.project, @file_link.folder, @file_link.target_file.name)
end end
def test_path
assert_equal @file_link.path,
@file_link.target_file.dmsf_path_str
end
def test_destroy def test_destroy
@folder_link.destroy @folder_link.destroy
assert_nil DmsfLink.find_by_id 1 assert_nil DmsfLink.find_by_id 1