mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-19 15:01:14 +00:00
Use sum instead of inject(0, :+) (#34153).
Patch by Go MAEDA. git-svn-id: http://svn.redmine.org/redmine/trunk@20173 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
6ba3e85df8
commit
9ef5f6789e
@ -276,13 +276,13 @@ module Redmine
|
|||||||
col_width = []
|
col_width = []
|
||||||
unless query.inline_columns.empty?
|
unless query.inline_columns.empty?
|
||||||
col_width = calc_col_width(issues, query, table_width, pdf)
|
col_width = calc_col_width(issues, query, table_width, pdf)
|
||||||
table_width = col_width.inject(0, :+)
|
table_width = col_width.sum
|
||||||
end
|
end
|
||||||
|
|
||||||
# use full width if the query has block columns (description, last_notes or full width custom fieds)
|
# use full width if the query has block columns (description, last_notes or full width custom fieds)
|
||||||
if table_width > 0 && query.block_columns.any?
|
if table_width > 0 && query.block_columns.any?
|
||||||
col_width = col_width.map {|w| w * (page_width - right_margin - left_margin) / table_width}
|
col_width = col_width.map {|w| w * (page_width - right_margin - left_margin) / table_width}
|
||||||
table_width = col_width.inject(0, :+)
|
table_width = col_width.sum
|
||||||
end
|
end
|
||||||
|
|
||||||
# title
|
# title
|
||||||
@ -418,7 +418,7 @@ module Redmine
|
|||||||
if table_width > col_min * col_width_avg.length
|
if table_width > col_min * col_width_avg.length
|
||||||
table_width -= col_min * col_width_avg.length
|
table_width -= col_min * col_width_avg.length
|
||||||
else
|
else
|
||||||
ratio = table_width / col_width_avg.inject(0, :+)
|
ratio = table_width / col_width_avg.sum
|
||||||
return col_width = col_width_avg.map {|w| w * ratio}
|
return col_width = col_width_avg.map {|w| w * ratio}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -451,11 +451,11 @@ module Redmine
|
|||||||
col_width_avg.map! {|x| x / k}
|
col_width_avg.map! {|x| x / k}
|
||||||
|
|
||||||
# calculate columns width
|
# calculate columns width
|
||||||
ratio = table_width / col_width_avg.inject(0, :+)
|
ratio = table_width / col_width_avg.sum
|
||||||
col_width = col_width_avg.map {|w| w * ratio}
|
col_width = col_width_avg.map {|w| w * ratio}
|
||||||
|
|
||||||
# correct max word width if too many columns
|
# correct max word width if too many columns
|
||||||
ratio = table_width / word_width_max.inject(0, :+)
|
ratio = table_width / word_width_max.sum
|
||||||
word_width_max.map! {|v| v * ratio} if ratio < 1
|
word_width_max.map! {|v| v * ratio} if ratio < 1
|
||||||
|
|
||||||
# correct and lock width of some columns
|
# correct and lock width of some columns
|
||||||
@ -479,7 +479,7 @@ module Redmine
|
|||||||
while done == 0
|
while done == 0
|
||||||
# calculate free & locked columns width
|
# calculate free & locked columns width
|
||||||
done = 1
|
done = 1
|
||||||
ratio = table_width / col_width.inject(0, :+)
|
ratio = table_width / col_width.sum
|
||||||
|
|
||||||
# correct columns width
|
# correct columns width
|
||||||
col_width.each_with_index do |w,i|
|
col_width.each_with_index do |w,i|
|
||||||
@ -500,7 +500,7 @@ module Redmine
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
ratio = table_width / col_width.inject(0, :+)
|
ratio = table_width / col_width.sum
|
||||||
col_width.map! {|v| v * ratio + col_min}
|
col_width.map! {|v| v * ratio + col_min}
|
||||||
col_width
|
col_width
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user