2019-07-01 16:14:16 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-09-17 16:50:01 +08:00
|
|
|
module Reports::Docx::DrawResultTable
|
2021-05-21 22:35:23 +08:00
|
|
|
def draw_result_table(result)
|
2019-07-01 16:14:16 +08:00
|
|
|
table = result.table
|
|
|
|
timestamp = table.created_at
|
2019-07-08 18:51:26 +08:00
|
|
|
color = @color
|
2023-02-13 18:32:18 +08:00
|
|
|
obj = self
|
2019-07-01 16:14:16 +08:00
|
|
|
@docx.p
|
2023-02-13 18:32:18 +08:00
|
|
|
@docx.table JSON.parse(table.contents_utf_8)['data'], border_size: Constants::REPORT_DOCX_TABLE_BORDER_SIZE do
|
2023-03-20 21:12:44 +08:00
|
|
|
if table.metadata.present?
|
|
|
|
JSON.parse(table.metadata)['cells']&.each do |cell|
|
|
|
|
next unless cell.present? && cell['row'].present? && cell['col'].present? && cell['className'].present?
|
2023-03-20 18:32:38 +08:00
|
|
|
|
2023-03-20 21:12:44 +08:00
|
|
|
cell_style rows.dig(cell['row'].to_i, cell['col'].to_i), align: obj.table_cell_alignment(cell['className'])
|
|
|
|
end
|
2023-02-13 18:32:18 +08:00
|
|
|
end
|
|
|
|
end
|
2019-07-01 16:14:16 +08:00
|
|
|
@docx.p do
|
2019-07-12 19:48:14 +08:00
|
|
|
text result.name, italic: true
|
2022-08-02 16:06:00 +08:00
|
|
|
text " #{I18n.t('search.index.archived')} ", bold: true if result.archived?
|
2019-07-01 16:14:16 +08:00
|
|
|
text ' '
|
|
|
|
text I18n.t 'projects.reports.elements.result_table.table_name', name: table.name
|
|
|
|
text ' '
|
|
|
|
text I18n.t('projects.reports.elements.result_text.user_time',
|
2019-07-08 18:51:26 +08:00
|
|
|
timestamp: I18n.l(timestamp, format: :full), user: result.user.full_name), color: color[:gray]
|
2019-07-01 16:14:16 +08:00
|
|
|
end
|
2021-05-21 22:35:23 +08:00
|
|
|
|
|
|
|
draw_result_comments(result) if @settings.dig('task', 'result_comments')
|
2019-07-01 16:14:16 +08:00
|
|
|
end
|
|
|
|
end
|