From 111a27fc98d65678b17c4105e211bd2310f7166f Mon Sep 17 00:00:00 2001 From: Karel Picman Date: Wed, 20 Jul 2016 07:25:34 +0200 Subject: [PATCH] Wrong tool-tip for dmsf macro #545 --- app/models/dmsf_file.rb | 16 ---------------- app/models/dmsf_file_revision.rb | 10 ++++++++++ app/views/dmsf/_file.html.erb | 2 +- app/views/dmsf/_file_trash.html.erb | 2 +- lib/redmine_dmsf/macros.rb | 4 ++-- 5 files changed, 14 insertions(+), 20 deletions(-) diff --git a/app/models/dmsf_file.rb b/app/models/dmsf_file.rb index f638bbab..bd8b2a3c 100644 --- a/app/models/dmsf_file.rb +++ b/app/models/dmsf_file.rb @@ -452,20 +452,4 @@ class DmsfFile < ActiveRecord::Base false end - def tooltip - text = '' - if self.last_revision - if self.last_revision.description.present? - text = self.last_revision.description - end - if self.last_revision.comment.present? - if text.present? - text += ' ' - end - text += self.last_revision.comment - end - end - text.html_safe - end - end diff --git a/app/models/dmsf_file_revision.rb b/app/models/dmsf_file_revision.rb index c628fc82..310e4174 100644 --- a/app/models/dmsf_file_revision.rb +++ b/app/models/dmsf_file_revision.rb @@ -284,4 +284,14 @@ class DmsfFileRevision < ActiveRecord::Base end end + def tooltip + text = '' + text = self.description if self.description.present? + if self.comment.present? + text += ' ' if text.present? + text += self.comment + end + text.html_safe + end + end \ No newline at end of file diff --git a/app/views/dmsf/_file.html.erb b/app/views/dmsf/_file.html.erb index 3a1af275..951b8e01 100644 --- a/app/views/dmsf/_file.html.erb +++ b/app/views/dmsf/_file.html.erb @@ -33,7 +33,7 @@ file_view_url, :target => '_blank', :class => "icon icon-file #{DmsfHelper.filetype_css(file.name)}", - :title => file.tooltip, + :title => file.last_revision.try(:tooltip), 'data-downloadurl' => "#{file.last_revision.detect_content_type}:#{h(file.name)}:#{file_view_url}") %>
<%= h(link ? link.path : file.display_name) %>
<%= ''.html_safe if @tree_view %> diff --git a/app/views/dmsf/_file_trash.html.erb b/app/views/dmsf/_file_trash.html.erb index 1e8d9f93..bd84be1f 100644 --- a/app/views/dmsf/_file_trash.html.erb +++ b/app/views/dmsf/_file_trash.html.erb @@ -24,7 +24,7 @@ :title => l(:title_check_for_restore_or_delete), :id => "file_#{id}") %> <%= content_tag(:span, h(title), - :title => h(file.tooltip), + :title => h(file.last_revision.try(:tooltip)), :class => "icon icon-file #{DmsfHelper.filetype_css(file.name)}") %>
<%= h(link ? link.path : file.display_name) %>
diff --git a/lib/redmine_dmsf/macros.rb b/lib/redmine_dmsf/macros.rb index 4cdfcf43..51aaa514 100644 --- a/lib/redmine_dmsf/macros.rb +++ b/lib/redmine_dmsf/macros.rb @@ -40,7 +40,7 @@ Redmine::WikiFormatting::Macros.register do return link_to(h(args[1] ? args[1] : file.title), file_view_url, :target => '_blank', - :title => h(file.tooltip), + :title => h(revision.tooltip), 'data-downloadurl' => "#{file.last_revision.detect_content_type}:#{h(file.name)}:#{file_view_url}") else raise l(:notice_not_authorized) @@ -161,7 +161,7 @@ Redmine::WikiFormatting::Macros.register do end link_to(img, file_view_url, :target => '_blank', - :title => h(file.tooltip), + :title => h(file.last_revision.try(:tooltip)), 'data-downloadurl' => "#{file.last_revision.detect_content_type}:#{h(file.name)}:#{file_view_url}") else raise "Document ID #{file_id} not found"