]> source.dussan.org Git - redmine.git/commitdiff
Add download buttons in Files columns of the issues list (#32240).
authorGo MAEDA <maeda@farend.jp>
Thu, 6 Feb 2020 14:24:51 +0000 (14:24 +0000)
committerGo MAEDA <maeda@farend.jp>
Thu, 6 Feb 2020 14:24:51 +0000 (14:24 +0000)
Patch by Yuichi HARADA.

git-svn-id: http://svn.redmine.org/redmine/trunk@19500 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/application_helper.rb
public/stylesheets/application.css
test/functional/issues_controller_test.rb
test/integration/lib/redmine/field_format/attachment_format_test.rb

index 9fb6a56c2c10d5ff3e6f7e0bed973620d4501be0..b96165695238ac51f49bfe24c5a88d7634ff5088 100644 (file)
@@ -253,7 +253,20 @@ module ApplicationHelper
     when 'Issue'
       object.visible? && html ? link_to_issue(object) : "##{object.id}"
     when 'Attachment'
-      html ? link_to_attachment(object) : object.filename
+      if html
+        content_tag(
+          :span,
+          link_to_attachment(object) +
+          link_to_attachment(
+            object,
+            :class => ['icon-only', 'icon-download'],
+            :title => l(:button_download),
+            :download => true
+          )
+        )
+      else
+        object.filename
+      end
     when 'CustomValue', 'CustomFieldValue'
       if object.custom_field
         f = object.custom_field.format.formatted_custom_value(self, object, html)
index ffda203efdae654d507b53b0e4a3e401a810a262..5f8b06babd26fd86ec1161fb1653e460c0abc79d 100644 (file)
@@ -241,7 +241,9 @@ table.list td {text-align:center; vertical-align:middle; padding-right:10px;}
 table.list td.id { width: 2%; text-align: center;}
 table.list td.name, table.list td.description, table.list td.subject, table.list td.comments, table.list td.roles, table.list td.attachments, table.list td.text,  table.list td.short_description {text-align: left;}
 
-table.list td.attachments a {display:block;}
+table.list td.attachments span {display: block; height: 16px;}
+table.list td.attachments span a.icon-download {display: inline-block; visibility: hidden;}
+table.list td.attachments span:hover a.icon-download {visibility: visible;}
 table.list td.tick {width:15%}
 table.list td.checkbox { width: 15px; padding: 2px 0 0 0; }
 table.list .checkbox input {padding:0px; height: initial;}
index 2dcf06bb16445f1f7b427831a9dbf346e20cec90..488edde6d6c5c317791946d001b3c83ad12428f0 100644 (file)
@@ -1784,8 +1784,14 @@ class IssuesControllerTest < Redmine::ControllerTest
     assert_select 'td.attachments'
     assert_select 'tr#issue-2' do
       assert_select 'td.attachments' do
-        assert_select 'a', :text => 'source.rb'
-        assert_select 'a', :text => 'picture.jpg'
+        assert_select 'span:nth-of-type(1)' do
+          assert_select 'a[href=?]', '/attachments/4', :text => 'source.rb'
+          assert_select 'a[href=?].icon-download', '/attachments/download/4/source.rb'
+        end
+        assert_select 'span:nth-of-type(2)' do
+          assert_select 'a[href=?]', '/attachments/10', :text => 'picture.jpg'
+          assert_select 'a[href=?].icon-download', '/attachments/download/10/picture.jpg'
+        end
       end
     end
   end
index 61f439894954f6ff04701c5d08a25fff097934bc..ccb33a9b6df1e03094fa658a869d3c19f3bcf4ba 100644 (file)
@@ -81,7 +81,7 @@ class AttachmentFieldFormatTest < Redmine::IntegrationTest
     assert_response :success
 
     # link to the attachment
-    link = css_select(".cf_#{@field.id} .value a")
+    link = css_select(".cf_#{@field.id} .value a:not(.icon-download)")
     assert_equal 1, link.size
     assert_equal "testfile.txt", link.text