mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-30 04:09:38 +00:00
Makes Attachments column available on the issue list (#25515).
git-svn-id: http://svn.redmine.org/redmine/trunk@16473 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
0a40b19c99
commit
5c7aaa4d1e
@ -228,6 +228,8 @@ module QueriesHelper
|
||||
link_to_if(value > 0, format_hours(value), project_time_entries_path(item.project, :issue_id => "#{item.id}"))
|
||||
when :total_spent_hours
|
||||
link_to_if(value > 0, format_hours(value), project_time_entries_path(item.project, :issue_id => "~#{item.id}"))
|
||||
when :attachments
|
||||
value.to_a.map {|a| format_object(a)}.join(" ").html_safe
|
||||
else
|
||||
format_object(value)
|
||||
end
|
||||
@ -243,20 +245,25 @@ module QueriesHelper
|
||||
end
|
||||
|
||||
def csv_value(column, object, value)
|
||||
format_object(value, false) do |value|
|
||||
case value.class.name
|
||||
when 'Float'
|
||||
sprintf("%.2f", value).gsub('.', l(:general_csv_decimal_separator))
|
||||
when 'IssueRelation'
|
||||
value.to_s(object)
|
||||
when 'Issue'
|
||||
if object.is_a?(TimeEntry)
|
||||
"#{value.tracker} ##{value.id}: #{value.subject}"
|
||||
case column.name
|
||||
when :attachments
|
||||
value.to_a.map {|a| a.filename}.join("\n")
|
||||
else
|
||||
format_object(value, false) do |value|
|
||||
case value.class.name
|
||||
when 'Float'
|
||||
sprintf("%.2f", value).gsub('.', l(:general_csv_decimal_separator))
|
||||
when 'IssueRelation'
|
||||
value.to_s(object)
|
||||
when 'Issue'
|
||||
if object.is_a?(TimeEntry)
|
||||
"#{value.tracker} ##{value.id}: #{value.subject}"
|
||||
else
|
||||
value.id
|
||||
end
|
||||
else
|
||||
value.id
|
||||
value
|
||||
end
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -45,6 +45,7 @@ class IssueQuery < Query
|
||||
QueryColumn.new(:closed_on, :sortable => "#{Issue.table_name}.closed_on", :default_order => 'desc'),
|
||||
QueryColumn.new(:last_updated_by, :sortable => lambda {User.fields_for_order_statement("last_journal_user")}),
|
||||
QueryColumn.new(:relations, :caption => :label_related_issues),
|
||||
QueryColumn.new(:attachments, :caption => :label_attachment_plural),
|
||||
QueryColumn.new(:description, :inline => false),
|
||||
QueryColumn.new(:last_notes, :caption => :label_last_notes, :inline => false)
|
||||
]
|
||||
@ -278,7 +279,7 @@ class IssueQuery < Query
|
||||
limit(options[:limit]).
|
||||
offset(options[:offset])
|
||||
|
||||
scope = scope.preload([:tracker, :author, :assigned_to, :fixed_version, :category] & columns.map(&:name))
|
||||
scope = scope.preload([:tracker, :author, :assigned_to, :fixed_version, :category, :attachments] & columns.map(&:name))
|
||||
if has_custom_field_column?
|
||||
scope = scope.preload(:custom_values)
|
||||
end
|
||||
|
||||
@ -374,8 +374,11 @@ module Redmine
|
||||
show_value(cv, false)
|
||||
else
|
||||
value = issue.send(column.name)
|
||||
if column.name == :subject
|
||||
case column.name
|
||||
when :subject
|
||||
value = " " * level + value
|
||||
when :attachments
|
||||
value = value.to_a.map {|a| a.filename}.join("\n")
|
||||
end
|
||||
if value.is_a?(Date)
|
||||
format_date(value)
|
||||
|
||||
@ -223,7 +223,8 @@ table.list, .table-list { border: 1px solid #e4e4e4; border-collapse: collapse;
|
||||
table.list th, .table-list-header { background-color:#EEEEEE; padding: 4px; white-space:nowrap; font-weight:bold; }
|
||||
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 {text-align: left;}
|
||||
table.list td.name, table.list td.description, table.list td.subject, table.list td.comments, table.list td.roles, table.list td.attachments {text-align: left;}
|
||||
table.list td.attachments a {display:block;}
|
||||
table.list td.tick {width:15%}
|
||||
table.list td.checkbox { width: 15px; padding: 2px 0 0 0; }
|
||||
table.list td.checkbox input {padding:0px;}
|
||||
|
||||
@ -1023,6 +1023,26 @@ class IssuesControllerTest < Redmine::ControllerTest
|
||||
assert_equal ["John Smith", "John Smith", ""], css_select('td.last_updated_by').map(&:text)
|
||||
end
|
||||
|
||||
def test_index_with_attachments_column
|
||||
get :index, :c => %w(subject attachments), :set_filter => '1', :sort => 'id'
|
||||
assert_response :success
|
||||
|
||||
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'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_index_with_attachments_column_as_csv
|
||||
get :index, :c => %w(subject attachments), :set_filter => '1', :sort => 'id', :format => 'csv'
|
||||
assert_response :success
|
||||
|
||||
assert_include "\"source.rb\npicture.jpg\"", response.body
|
||||
end
|
||||
|
||||
def test_index_with_estimated_hours_total
|
||||
Issue.delete_all
|
||||
Issue.generate!(:estimated_hours => 5.5)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user