Project

General

Profile

Patch #34153 ยป use-sum.patch

Go MAEDA, 2020-10-22 11:21

View differences:

lib/redmine/export/pdf/issues_pdf_helper.rb
276 276
          col_width = []
277 277
          unless query.inline_columns.empty?
278 278
            col_width = calc_col_width(issues, query, table_width, pdf)
279
            table_width = col_width.inject(0, :+)
279
            table_width = col_width.sum
280 280
          end
281 281

  
282 282
          # use full width if the query has block columns (description, last_notes or full width custom fieds)
283 283
          if table_width > 0 && query.block_columns.any?
284 284
            col_width = col_width.map {|w| w * (page_width - right_margin - left_margin) / table_width}
285
            table_width = col_width.inject(0, :+)
285
            table_width = col_width.sum
286 286
          end
287 287

  
288 288
          # title
......
418 418
            if table_width > col_min * col_width_avg.length
419 419
              table_width -= col_min * col_width_avg.length
420 420
            else
421
              ratio = table_width / col_width_avg.inject(0, :+)
421
              ratio = table_width / col_width_avg.sum
422 422
              return col_width = col_width_avg.map {|w| w * ratio}
423 423
            end
424 424
          end
......
451 451
          col_width_avg.map! {|x| x / k}
452 452

  
453 453
          # calculate columns width
454
          ratio = table_width / col_width_avg.inject(0, :+)
454
          ratio = table_width / col_width_avg.sum
455 455
          col_width = col_width_avg.map {|w| w * ratio}
456 456

  
457 457
          # correct max word width if too many columns
458
          ratio = table_width / word_width_max.inject(0, :+)
458
          ratio = table_width / word_width_max.sum
459 459
          word_width_max.map! {|v| v * ratio} if ratio < 1
460 460

  
461 461
          # correct and lock width of some columns
......
479 479
          while done == 0
480 480
            # calculate free & locked columns width
481 481
            done = 1
482
            ratio = table_width / col_width.inject(0, :+)
482
            ratio = table_width / col_width.sum
483 483

  
484 484
            # correct columns width
485 485
            col_width.each_with_index do |w,i|
......
500 500
            end
501 501
          end
502 502

  
503
          ratio = table_width / col_width.inject(0, :+)
503
          ratio = table_width / col_width.sum
504 504
          col_width.map! {|v| v * ratio + col_min}
505 505
          col_width
506 506
        end
    (1-1/1)