Fix docx table generator if metadata are nil [SCI-8165]

This commit is contained in:
Andrej 2023-03-20 14:12:44 +01:00
parent 64441f791f
commit 8bf9e2425b

View file

@ -8,10 +8,12 @@ module Reports::Docx::DrawResultTable
obj = self
@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|
next unless cell.present? && cell['row'].present? && cell['col'].present? && cell['className'].present?
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?
cell_style rows.dig(cell['row'].to_i, cell['col'].to_i), align: obj.table_cell_alignment(cell['className'])
cell_style rows.dig(cell['row'].to_i, cell['col'].to_i), align: obj.table_cell_alignment(cell['className'])
end
end
end
@docx.p do