From 0f3b5244926becbca102cbe8eb5887543a3c93bc Mon Sep 17 00:00:00 2001 From: Martin Artnik Date: Fri, 30 Jun 2023 14:11:03 +0200 Subject: [PATCH] Fix and amend result table metadata saving [SCI-8774] --- app/assets/javascripts/results/result_tables.js.erb | 10 +++++++++- app/controllers/result_tables_controller.rb | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/results/result_tables.js.erb b/app/assets/javascripts/results/result_tables.js.erb index 60c88ce47..b8a9b680b 100644 --- a/app/assets/javascripts/results/result_tables.js.erb +++ b/app/assets/javascripts/results/result_tables.js.erb @@ -41,11 +41,19 @@ contents.attr('value', data); metadata.attr('value', JSON.stringify({cells: hot.getCellsMeta().map( (x) => { + const {row, col} = x; + const plugins = hot.plugin; + const cellId = plugins.utils.translateCellCoords({row, col}); + const calculated = plugins.matrix.getItem(cellId)?.value || + hot.getDataAtCell(row, col) || + null; + if (x) { return { col: x.col, row: x.row, - className: x.className || '' + className: x.className || '', + calculated: calculated } } else { return null diff --git a/app/controllers/result_tables_controller.rb b/app/controllers/result_tables_controller.rb index c85f96864..ff2c654f9 100644 --- a/app/controllers/result_tables_controller.rb +++ b/app/controllers/result_tables_controller.rb @@ -70,6 +70,7 @@ class ResultTablesController < ApplicationController @result.table.last_modified_by = current_user @result.table.team = current_team @result.assign_attributes(update_params) + @result.table.metadata = JSON.parse(update_params[:table_attributes][:metadata]) flash_success = t("result_tables.update.success_flash", module: @my_module.name) if @result.archived_changed?(from: false, to: true)