Merge pull request #5166 from rekonder/aj_SCI_8165

* Fix docx report generation with broken metadate [SCI-8165]
This commit is contained in:
Alex Kriuchykhin 2023-03-20 12:37:41 +01:00 committed by GitHub
commit d30a6407ba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View file

@ -9,7 +9,9 @@ module Reports::Docx::DrawResultTable
@docx.p
@docx.table JSON.parse(table.contents_utf_8)['data'], border_size: Constants::REPORT_DOCX_TABLE_BORDER_SIZE do
JSON.parse(table.metadata)['cells'].each do |cell|
cell_style rows[cell['row']][cell['col']], align: obj.table_cell_alignment(cell['className'])
next unless cell.present? && cell['row'].present? && cell['col'].present? && cell['className'].present?
cell_style rows.dig(cell['row'].to_i, cell['col'].to_i), align: obj.table_cell_alignment(cell['className'])
end
end
@docx.p do

View file

@ -10,7 +10,9 @@ module Reports::Docx::DrawStepTable
if table.metadata
table.metadata['cells'].each do |cell|
data = cell[1]
cell_style rows[data['row'].to_i][data['col'].to_i], align: obj.table_cell_alignment(data['className'])
next unless data.present? && data['row'].present? && data['col'].present? && data['className'].present?
cell_style rows.dig(data['row'].to_i, data['col'].to_i), align: obj.table_cell_alignment(data['className'])
end
end
end