Fix rendering of tables with broken metadata in docx reports [SCI-9327]

This commit is contained in:
Oleksii Kriuchykhin 2023-09-19 14:25:40 +02:00
parent 94db5c1155
commit b32f163cdc
2 changed files with 8 additions and 8 deletions

View file

@ -9,8 +9,8 @@ module Reports::Docx::DrawResultTable
table_data = JSON.parse(table.contents_utf_8)['data']
table_data = obj.add_headers_to_table(table_data, false)
if table.metadata.present?
table.metadata['cells']&.each do |cell|
if table.metadata.present? && table.metadata['cells'].is_a?(Array)
table.metadata['cells'].each do |cell|
next unless cell['row'].present? && cell['col'].present?
row_index = cell['row'].to_i + 1
@ -27,8 +27,8 @@ module Reports::Docx::DrawResultTable
cell_style rows[0], bold: true, background: color[:concrete]
cell_style cols[0], bold: true, background: color[:concrete]
if table.metadata.present?
table.metadata['cells']&.each do |cell|
if table.metadata.present? && table.metadata['cells'].is_a?(Array)
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 + 1, cell['col'].to_i + 1),

View file

@ -8,8 +8,8 @@ module Reports::Docx::DrawStepTable
table_data = JSON.parse(table.contents_utf_8)['data']
table_data = obj.add_headers_to_table(table_data, table_type == 'step_well_plates_table')
if table.metadata.present?
table.metadata['cells']&.each do |cell|
if table.metadata.present? && table.metadata['cells'].is_a?(Array)
table.metadata['cells'].each do |cell|
next unless cell['row'].present? && cell['col'].present?
row_index = cell['row'].to_i + 1
@ -26,8 +26,8 @@ module Reports::Docx::DrawStepTable
cell_style rows[0], bold: true, background: color[:concrete]
cell_style cols[0], bold: true, background: color[:concrete]
if table.metadata.present?
table.metadata['cells']&.each do |cell|
if table.metadata.present? && table.metadata['cells'].is_a?(Array)
table.metadata['cells'].each do |cell|
data = cell[1]
next unless data.present? && data['row'].present? && data['col'].present? && data['className'].present?