Update the native table calculations display in reports [SCI-8739]

This commit is contained in:
Giga Chubinidze 2023-07-19 22:48:21 +04:00
parent db8583c39c
commit fac8945870
2 changed files with 28 additions and 0 deletions

View file

@ -8,6 +8,20 @@ module Reports::Docx::DrawResultTable
obj = self
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|
next unless cell['row'].present? && cell['col'].present?
row_index = cell['row'].to_i + 1
col_index = cell['col'].to_i + 1
calculated_value = cell['calculated']
if calculated_value.present?
table_data[row_index][col_index] = calculated_value
end
end
end
@docx.p
@docx.table table_data, border_size: Constants::REPORT_DOCX_TABLE_BORDER_SIZE do
cell_style rows[0], bold: true, background: color[:concrete]

View file

@ -7,6 +7,20 @@ module Reports::Docx::DrawStepTable
obj = self
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|
next unless cell['row'].present? && cell['col'].present?
row_index = cell['row'].to_i + 1
col_index = cell['col'].to_i + 1
calculated_value = cell['calculated']
if calculated_value.present?
table_data[row_index][col_index] = calculated_value
end
end
end
@docx.p
@docx.table table_data, border_size: Constants::REPORT_DOCX_TABLE_BORDER_SIZE do
cell_style rows[0], bold: true, background: color[:concrete]